Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Volition
Posts: 92
Joined: Sat Jul 08, 2006 4:03 am
Location: Deep South, Mainland Australia.
Contact:

Squeezebox, MM3, Squeezecenter & ipod / Zen Integration

Post by Volition »

Hi Everyone,

We'll i'm trying to get my MM3 and Squeezebox integrating with ratings playcounts and playtimes etc. The reason i use both are;
1. MM3 - Has great tagging Facilities (which is important for Squeececenter)
2. MM3 - Has Brilliant Autoiplylists (Which i use with ratings, genres, etc)
3. MM3 - Syncs all the above with my Portable players. (Zen vision:m & Ipod Classic, which both in turn allow me to rate tracks)
4. Squeezbox - Allows me to play my Music anywhere in my house. I have 2 one in my lunge and one in my bedroom.

Now the task ahead is to sync all autoplaylists, ratings, playcounts and playtimes. I suppose i'll break it up step by step. I've accomplished quite a bit of these steps, i would like some help trying to finish of my outstsanding issues. I see this as a bit of a project and any assistance that can be provided would be great. As i've only messed around with the most basic of scripts and only then i've used others scripts and manipulated them.

Like i said earlier any assistance would be of great help, Specifically Scheduling the script, and creating the script from the psuedo-code below. I'd say it would take me a while.
In regards to assistance, Ideally if someone who has the knowledge could knock up the code that would be awesome. Else if people can point to scripts that do similar things and resources which will help me.

Firstly, Syncing Playlists and Autoplaylists
1. MM3 & Portable players use sync on MM3
2. I've created a playlist node called "A - Squeeze" - This has playlists in it that i want to use with the Squeezecenter.
3. In Squeezecenter i've set my destination for playlists as "F:\Playlists\A - Squeeze"
4. Using the Modified Export all m3u's script below i run that to export the playlists within folders in "F:\Playlists\A - Squeeze", you can see i've hard coded the destinations and playlist node.

Code: Select all

See Last Post for latest script
5. Ok, So that's the playlists from MM3 into A directory, I've set up squeezecenter to rescan changes at 5am every day. So it' Picks these Up.

Outstanding issues for syncing Playlists
I'd Like to run the script above automated using the windows scheduler, i've had a look around. i just can't find any solid information, Pekes windows scheduler is geared up for playlists not scripts. How can i achieve this.

Syncing Ratings, Playcounts and Playtimes
1. Setup Squeezecenter to handle ratings. (This Syncs MM3's rating to Squeezecenter)
1a- Add plugin "Trackstat" by Erland
1b- Add plugin "Custom Scan" by Erland (Setup Ratings scan option to be automatic, this will add the ratings into squeezecenter)
2. Sync the ratings and Playtimes and counts from squeezecenter.
2a- Using the Trackstat plugin setup the itunes integration to update as edited. this creates a txt file with the necessary details to parse into MM3. I've set mine up to wirite to "f:\Playlists\Trackstat\TrackStat_iTunes_Hist.txt" the output in this file is as such;

Code: Select all

Pictures of You [Extended Dub Mix]|||O:\Music\The Cure\Mixed Up\[Mixed Up]7-The Cure_Pictures of You [Extended Dub Mix].mp3|played|20081208190833|100
Sun Is Shining|||O:\Music\Various Artists\History of Trojan Records 1968-1971\[History of Trojan Records 1968-1971]19-Bob Marley & the Wailers_Sun Is Shining.mp3|played|20081208191753|100
Angie|||O:\Music\The Rolling Stones\Forty Licks\[Forty Licks]27-The Rolling 
The Jungle|||O:\Music\Faith No More\We Care a Lot\[We Care a Lot]2-Faith No More_The Jungle.mp3|rated||60
The Jungle|||O:\Music\Faith No More\We Care a Lot\[We Care a Lot]2-Faith No More_The Jungle.mp3|played|20081209074549|60
Outstanding issues for syncing Ratings, Played time and Playcounts
This is the important bit, i need to create a script which parses the above txt file contents into MM3. And I was thinking to add this to the start of the exporting playlists script at the top. and when all finished create options to set destinations. However i need to get this script worked out.

So in getting this script done here is the following Psuedo Code.

Code: Select all

If "f:\Playlists\Trackstat\TrackStat_iTunes_Hist.txt" does not exist
     then end
else
For every line up till end of txt repeat the following.
Is this Song a rating change or played change(Parse txt to check wether song is played or rated)
    Case is [i]rating change[/i]
         if song(use parse to find path) does not exist
           than go to next song
         else
            Change rating (use parse to find)
            go to next song
    Case is [i]Played change[/i]
         if song(use parse to find path) does not exist
           than go to next song
         else
            Change Played Time (use parse to find)
            Increase Playcount
            go to next song
End of txt file
then delete "f:\Playlists\Trackstat\TrackStat_iTunes_Hist.txt" file
Run ExportM3USpecific
We'll that's it, that would sync MM3 with Squeezebox/Squeezecenter and your Portable Mp3 players. Anyways, i'll keep this thread updated to my progress, and all you Squeezebox MM3 users, let me know if you already have something similar, or jump on board and give me a hand.

Kind regards,

Vol.
Last edited by Volition on Sat Aug 08, 2009 1:05 am, edited 1 time in total.
Volition
Posts: 92
Joined: Sat Jul 08, 2006 4:03 am
Location: Deep South, Mainland Australia.
Contact:

Woohoo, it's working!!!

Post by Volition »

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
Last edited by Volition on Sat Aug 08, 2009 1:06 am, edited 1 time in total.
guest

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

Post by guest »

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.
Volition
Posts: 92
Joined: Sat Jul 08, 2006 4:03 am
Location: Deep South, Mainland Australia.
Contact:

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

Post by Volition »

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?
heidtheba

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

Post by heidtheba »

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.
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

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

Post by Bex »

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.
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
Volition
Posts: 92
Joined: Sat Jul 08, 2006 4:03 am
Location: Deep South, Mainland Australia.
Contact:

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

Post by Volition »

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
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

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

Post by Bex »

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.
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
Volition
Posts: 92
Joined: Sat Jul 08, 2006 4:03 am
Location: Deep South, Mainland Australia.
Contact:

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

Post by Volition »

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
BuckNaked
Posts: 23
Joined: Fri Aug 11, 2006 4:13 pm

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

Post by BuckNaked »

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
BuckNaked
Posts: 23
Joined: Fri Aug 11, 2006 4:13 pm

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

Post by BuckNaked »

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
heidtheba

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

Post by heidtheba »

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.
heidtheba

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

Post by heidtheba »

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.
Guest

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

Post by Guest »

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 :-)
Volition
Posts: 92
Joined: Sat Jul 08, 2006 4:03 am
Location: Deep South, Mainland Australia.
Contact:

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

Post by Volition »

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.
Post Reply