Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

Re: Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

by Volition » Sat Aug 08, 2009 1:04 am

By the way guys here is the code of the script i'm using at the moment. It's not much different but i'm not sure if originally i had fixed the delete file problem.
I also have to manuall go into the history file and delet a whole stack of tracks as i find every time i rescan it fills it up with a list of the whole db. It's easey for me to work out which ones to delete. It does get tiresome, but i haven't made the effort to look into this further.

If anyone knows of a setting to change in sc let me know. Otherwise that is something i need to get fixed on the SC plugin side.

Code: Select all

Option Explicit
'1. Save this text as 'SqueezeSync.vbs' in the Scripts-folder of MediaMonkey
'2. Add this Section to Scripts.ini

'[SqueezeSync]
'FileName=SqueezeSync.vbs
'ProcName=SqueezeSync
'DisplayName=SqueezeSync
'Language=VBScript
'ScriptType=0

'3. Edit the path to your playcounter-file in the code below.
'4. Restart MediaMonkey
'5. You'll find "PlayCountImport" under Tools/Scripts

Public Const path = "z:\harddisk\My Music\Trackstat\TrackStat_iTunes_Hist.txt" 'PUT THE PATH TO YOUR FILE HERE

Sub SqueezeSync
   Dim str, arr, songpath, sit, itm, playdate, newrate, pldat, propdat
   Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
   if fso.FileExists(path) then
      Dim txt : Set txt = fso.OpenTextFile(path,1,False)
      SDB.Database.BeginTransaction
      Do While Not txt.AtEndOfStream
         SDB.ProcessMessages
         str = Trim(txt.ReadLine)
         arr = Split(str,"|")

 'arr(0) is Title
 'arr(1)
 'arr(2)
 'arr(3) is SongPath
 'arr(4) is Played or Rated
 'arr(5) is Date in this format 20081209074549 yyyymmddhhmmss

 'arr(6) is Rating

         songpath = Mid(arr(3),2)
         newrate = arr(6)
         Set sit = SDB.Database.QuerySongs("AND (Songs.SongPath = '"&Replace(songpath,"'","''")&"')")
         If Not (sit.EOF) Then
            Set itm = sit.Item
            if arr(4) = "rated" then
            	itm.rating = newrate
            else
            		itm.Playcounter = itm.Playcounter + 1
            		pldat = arr(5)
         				propdat = Left(pldat, 4) & "-" & Mid(pldat, 5, 2) & "-" & Mid(pldat, 7, 2) & " " & mid(pldat, 9, 2) & ":" & mid(pldat, 11, 2) & ":" & right(pldat, 2)
         				playdate = FormatDateTime(propdat)
                 if DateValue(itm.LastPlayed) < DateValue(playdate) then
                    itm.LastPlayed = playdate
                 end if
          end if
         itm.UpdateDB
         End If
      Loop
      Set sit = Nothing
      SDB.Database.Commit
   else
    exit sub
   end if
   txt.close
   Call fso.deletefile(path, false)
End sub

Re: Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

by Volition » Sat Aug 08, 2009 12:58 am

Hi Guys i've been away for a while.

But good to see some people getting some use out of this stuff.

When i originally got this stuff together i did get in touch with erland. and he mentioned to me if i can get some plugin stuff working he'd help with getting stuiff together.

I'm probably a bit above my head here though, as i jsut grabbed some other peoples code spent a week or two working it out and got something together. that works.

But now i'm back i'll look into it. Last thing i was doing was trying to work out a way of running the mm script from Squeezecenter. i think it can be done. Does anyone have any inf on say running the script from being called in a perl script.

Anyways i've got some other stuff first and then i'd like to get onto this. So give me a couple of weeks before i can get my teeth into this. I'll have to refresh my mind. Let me know if you have any ideas.

Firstly need to get a script that does the Update of mm3 from SC from within SC
2. Make an initial first time import/export
3. Way of syncing MM3 and trackstat. both ways

Let me know of what else.

Re: Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

by Guest » Sun Jan 18, 2009 7:26 am

For those interested in exporting mthere playlists to Squeezebox: I've just posted a MediaMonkey script that exports all playlist to your squeezebox folder (after cleaning up old playlists).

You can find it @ http://forums.slimdevices.com/showthread.php?t=58432

I've created and posted this script as I've had some troubles with the scripts posted in this thread. Next step in MediaMonkey would be to have the script run OnClose or scheduled. Any other suggestions for improvement?

Better would be however be an MediaMonkey plugin for Squeezecenter :-)

Re: Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

by heidtheba » Mon Dec 15, 2008 3:42 pm

I have rather confused myself with the field format of the "Hist" and "Complete" Custom Scan iTunes output files. From Erland's description on the SC forums, its a bit clearer to me now- I hadn't noticed that there was a still a rating contained in:

Ragged Wood|||C:\Documents and Settings\Steven\My Documents\My Music\E to L\Fleet Foxes - Fleet Foxes\03 ragged wood.mp3|played|20081214202306|100

...even though the 5th field says 'played'.

The reason for me asking is that I am trying to import my entire library's ratings by importing the "Complete" Custom Scan output file which you get my manually clicking 'export' in that SC plugin. However it is apparent that the script is designed to work with the continuous update "Hist" files rather than the all-in-one-go "Complete" files.

I am now trying to work out (I'm not so good at coding) whether I can adapt the script to import ratings properly from a "Complete" Custom Scan output file.

Re: Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

by heidtheba » Sun Dec 14, 2008 5:41 pm

Thanks Volition,
I wasn't aware of the differences between "Complete" and "Hist" versions of the Custom Scan Export. Anyway, I've now tried again, and found that your MM3 last played/rating import script actually works fine. The reason I was seeing no changes was because the Custom Scan Export "Complete" file is actually large parts of ratings data, which IS present on the SC web interface!
I have started a thread on this here to ask for some help.

Re: Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

by BuckNaked » Sun Dec 14, 2008 1:26 pm

I've tried adding the delete functions to the script, but they both yield an "Permission denied" error. Where do I allow VB-scripts to delete stuff? :)

Thanks
AV

Re: Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

by BuckNaked » Sun Dec 14, 2008 9:35 am

EDIT: I found the answer myself after a bit of searching. The export function is in the CustomScan plugin. :)
I'll leave this post as is for anyone else running into the same question as me.


This surely sounds awesome, however I'm running into trouble with point 2a. I have TrackStat enabled, and the iTunes plugin as well (just to be sure, not certain it is necessary?), but cannot find where to export for iTunes? I take it it is somewhere in the TrackStat configuration? Perhaps you could help me by pointing out under which settings submenu and also the name of the actual setting?

Thanks in advance and for your hard work.

Cheers,
-AV

Re: Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

by Volition » Thu Dec 11, 2008 8:00 pm

heidtheba;

You are using a different file to what i'm using from SC(Squeezecenter), I don;t remeber what actual setting i have i'll have a look later at home, but it said something like live data update or update history as going along or played.

I think the file your using is generated manually. The other option just makes the file happen.

Anyway if you can post some of the txt file you've got i believe it should be the same. However, i'd be careful, because if that is all your ratings you may do a major owverwrite in MM. Personally i'd look for the option which creates the Hist file as they are played. That way you only make changes on what has changed in SC.

In regards, to running the script there is no progressbar, so it looks like it is doing nothing. What you can do is, get the options right in trackstat for the hist file. then Change the script file name part from ending in complete to hist. Then Play a couple of songs or your Squeezebox, rate them or not. Do them from the Same Album perhaps.

Then Open Up MediaMonkey view that album, so you can see the playcounts, ratings, last played. Run the script and Voila!

Kind regards,

Vol

Re: Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

by Bex » Thu Dec 11, 2008 7:56 pm

Volition wrote:thanks Bex, will try that when i get home. I thought i'd tried the "call" part but i could be wrong.

Can you also advise if adding the sub name as onstartup this will just kick this off when starting MM3
Yes, if you place the script in the Auto-Folder.

Re: Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

by Volition » Thu Dec 11, 2008 7:47 pm

thanks Bex, will try that when i get home. I thought i'd tried the "call" part but i could be wrong.

Can you also advise if adding the sub name as onstartup this will just kick this off when starting MM3

Re: Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

by Bex » Thu Dec 11, 2008 7:37 pm

Volition wrote:I Just cant delete the file at the end of the syncing script, which is the second one.

I've tried using the fso thing with
fso.deletefile(path)

I keep getting can't call sub with paretheses error. Please someone advise!

If i call the sub at the top to OnStartup will that start it up everytime i start mediamonkey?
1) Try this:
Call fso.deletefile(path)
-or
fso.deletefile path

2) Yes, if you place the script in the Auto-Folder.

Re: Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

by heidtheba » Thu Dec 11, 2008 7:24 pm

Hi Volition,
I am having some trouble running the SqueezeSync.vbs script you posted. Everything is as you posted, other than the path line where I put my own path in. However when I run 'SqueezeSync' from the tools/scripts menu im MM, nothing happens at all.

Code: Select all

Option Explicit
    '1. Save this text as 'SqueezeSync.vbs' in the Scripts-folder of MediaMonkey
    '2. Add this Section to Scripts.ini

    '[SqueezeSync]
    'FileName=SqueezeSync.vbs
    'ProcName=SqueezeSync
    'DisplayName=SqueezeSync
    'Language=VBScript
    'ScriptType=0

    '3. Edit the path to your playcounter-file in the code below.
    '4. Restart MediaMonkey
    '5. You'll find "PlayCountImport" under Tools/Scripts

    Public Const path = "C:\Documents and Settings\Steven\My Documents\TrackStatBackup\TrackStat_iTunes_Complete.txt" 'PUT THE PATH TO YOUR FILE HERE

    Sub SqueezeSync
       Dim str, arr, songpath, sit, itm, playdate, newrate, pldat, propdat
       Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
       if fso.FileExists(path) then
          Dim txt : Set txt = fso.OpenTextFile(path,1,False)
          SDB.Database.BeginTransaction
          Do While Not txt.AtEndOfStream
             SDB.ProcessMessages
             str = Trim(txt.ReadLine)
             arr = Split(str,"|")

    'arr(0) is Title
    'arr(1)
    'arr(2)
    'arr(3) is SongPath
    'arr(4) is Played or Rated
    'arr(5) is Date in this format 20081209074549 yyyymmddhhmmss

    'arr(6) is Rating

             songpath = Mid(arr(3),2)
             newrate = arr(6)
             Set sit = SDB.Database.QuerySongs("AND (Songs.SongPath = '"&Replace(songpath,"'","''")&"')")
             If Not (sit.EOF) Then
                Set itm = sit.Item
                if arr(4) = "rated" then
                   itm.rating = newrate
                else
                      itm.Playcounter = itm.Playcounter + 1
                      pldat = arr(5)
                         propdat = Left(pldat, 4) & "-" & Mid(pldat, 5, 2) & "-" & Mid(pldat, 7, 2) & " " & mid(pldat, 9, 2) & ":" & mid(pldat, 11, 2) & ":" & right(pldat, 2)
                         playdate = FormatDateTime(propdat)
                     if DateValue(itm.LastPlayed) < DateValue(playdate) then
                        itm.LastPlayed = playdate
                     end if
              end if
             itm.UpdateDB
             End If
          Loop
          Set sit = Nothing
          SDB.Database.Commit
       else
        exit sub
       end if
    End sub
I am pretty new to this, but would appreciate any pointers.

Re: Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

by Volition » Thu Dec 11, 2008 2:37 am

I Just cant delete the file at the end of the syncing script, which is the second one.

I've tried using the fso thing with
fso.deletefile(path)

I keep getting can't call sub with paretheses error. Please someone advise!

If i call the sub at the top to OnStartup will that start it up everytime i start mediamonkey?

Re: Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

by guest » Wed Dec 10, 2008 6:56 pm

Great work. Though I am not up on the coding, I eagerly await any further work/description on this. For me it is reaching the holy grail- syncing my Zen, iphone (in future) and squeezecenter.

Woohoo, it's working!!!

by Volition » Wed Dec 10, 2008 6:21 pm

I've Managed to Get the Sync Working from Squeezecenter to MM3 for the last played time, playcounters and ratings.
My Zen Vision M;, Ipod Classic, Squeezeboxes & MediaMonkey all sync together, yes!

Thanks to a playcount script i found big Big Berny, thanks.

Here is the Code.

Code: Select all

Use the script at the further down
 
Ok, Now this all works, though it's all manual at the moment and can be cleaned up.

I'd really like some guidance on setting these scripts up to run automatically, I'd like to add a progress bar for them and an options sheet. so I'll look at doing that as well. For you scripters out there if you could lend a hand that would be appreciated.

1. I'll Join up the Import of details from Squeezecenter, with the exporting of playlists. and leave the ability to run them separately as well.
2. Add Progress Bars, to scripts & Options sheets for locations.
3. Workout how to schedule the scripts by time.
4. Put it all into an installer.
5. Write out a detailed post on how to get it to come together.


Kind regards,

Vol

Top