Export to iTunes

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Export to iTunes

Post by nynaevelan »

Thanks that's where I was missing it, I was using the right click send to options. :wink: I'll go try that now.

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Export to iTunes

Post by nynaevelan »

Ok:

I am making some progress with the playcounts from itunes but I am running into the following problem:

1. It is not updating the playcount in MM for all the tracks but it is removing them all from itunes.
2. It is not updating the playcount to itunes, should it be doing this when adding the tracks to itunes.
3. Forgot to mention - the tracks do not appear within the playlist(s) in itunes.

Ratings are syncing correctly to itunes, however when running the Sync and Recover option it gives you a dialog box for syncing the ratings back to MM. There is a Yes and Yes for All but no options for No or No to All. This would be nice if you do not want the ratings to change in MM. And although I told it yes for one of the tracks it did not make any changes in the db, I have the option selected for MM to be the master of ratings.

In a future version would it be possible to add an option for the user to select the playlist to get the playcounts from when using the Sync and Recover feature rather than having the tracks sent to a set playlist?
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

Re: Export to iTunes

Post by markstuartwalker »

nynaevelan wrote:I have the option selected for MM to be the master of ratings.
The term 'master' means that this is the source of the ratings.

When MM is the master chnages in MM are written to iTunes and chnages in iTunes are overwritten.
When MM is not the master changes in iTunes are written to MM and changes in MM are overwritten.
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

Re: Export to iTunes

Post by markstuartwalker »

In a future version would it be possible to add an option for the user to select the playlist to get the playcounts from when using the Sync and Recover feature rather than having the tracks sent to a set playlist?
In the next version an empty playlist name in the options causes it to prompt for a playlist name.
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Export to iTunes

Post by nynaevelan »

markstuartwalker wrote:
nynaevelan wrote:I have the option selected for MM to be the master of ratings.
The term 'master' means that this is the source of the ratings.

When MM is the master chnages in MM are written to iTunes and chnages in iTunes are overwritten.
When MM is not the master changes in iTunes are written to MM and changes in MM are overwritten.
That's what I thought, is it possible to separate the option for playcounts and ratings so that the user has the option whether or not to sync ratings back and forth??

BTW, in case I have not said it lately, thank you for such a great script. I know I do not use it as you intended, but it is great nonetheless. :D :D

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

Re: Export to iTunes

Post by markstuartwalker »

Try out version 12

* separate playcount and rating switches
* utilised the MM .custom1 field to store vales for the synchronisation thus ratings are bidirectional
* omit the sync playlist to cause it to prompt

Mark
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Export to iTunes

Post by nynaevelan »

markstuartwalker wrote:Try out version 12

* separate playcount and rating switches
* utilised the MM .custom1 field to store vales for the synchronisation thus ratings are bidirectional
* omit the sync playlist to cause it to prompt

Mark
A question before I install, the custom 1 field, is this optional because I have custom 1 already being used?
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

Re: Export to iTunes

Post by markstuartwalker »

A question before I install, the custom 1 field, is this optional because I have custom 1 already being used?
Damn!!! I wondered about that being a problem. It is compulsary. Have you got all the custom fields being used?
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Export to iTunes

Post by nynaevelan »

Yup but I could get rid of #4 if absolutely necessary, but the ISRC is a good one to use, at least for me. :wink:

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

Re: Export to iTunes

Post by markstuartwalker »

Try #13. It uses ISRC.
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Export to iTunes

Post by nynaevelan »

One thing I noticed, if you are syncing playlists that have tracks that are on more than 1 playlist, they do not get updated correctly in itunes. It's not a major deal but I thought I'd mention it. Now off to test the new features...

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Export to iTunes

Post by nynaevelan »

One other thing what is all the other info after the date and before the ratings?

ExportToItunes|0|10/15/2009 2:24:48 PM|155584055,1226135401|100
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

Re: Export to iTunes

Post by markstuartwalker »

ExportToItunes|0|10/15/2009 2:24:48 PM|155584055,1226135401|100
This is some additional 'join' information that I now store in MM which allows quicker and more consistent indexing into the iTunes DB. It contains several fields all crunched into a single string type DB column

ExportToItunes is there as an identifier so that I can sidestep existing information
0 is the format version - I am future proofing here in case I choose to store even more information in the future.
10/15/2009 2:24:48 PM is the time at which the last sync occurred
155584055,1226135401 are the low,high index into the iTunes DB which is comparable to the ID column in the MM database
100 is the ratinging that was written into iTunes

The advantage of capturing this information is to improve indexing speed (indexing by track name was not 100% accurate)
The timestamp allows some more intelligent last played decisions
The rating allows bidirectional rating detection.

If you are feeling geeky have a look at the routine which does the synchronising ....

Code: Select all

    ' synchronise the playlist that contains the superset of all files 
    Public Sub syncPlaylist( playlistName , progress ) ' as String , as cProgress

        dim sdbplaylist : set sdbplaylist = SDB.PlaylistByTitle( playlistName )
        dim tracks : set tracks = sdbplaylist.tracks
        
        Progress.init "Sync playlist " & playlistName , tracks.count
        
        ' cache these 
        dim recoverPlaycounts : recoverPlaycounts = g.ini.recoverPlaycounts
        dim masterRatingsInMM : masterRatingsInMM = g.ini.masterRatingsInMM
        dim recoverRatings : recoverRatings = g.ini.recoverRatings
        
        dim r 
        
        if recoverPlaycounts then 
            if g.ini.recoverPlaycountsWarning = false then 
                r =SDB.Messagebox( "This will recover playcounts from the iTunes database (and any connected iPod/iPhone) and add them to the Media Monkey database. Is this what you want to do? Select 'No' to abort this action." , mtWarning , array(mbYes,mbNo) )
                if r <> mrYes then exit sub
                g.ini.recoverPlaycountsWarning = true
            end if 
                
        end if


        
        ' list of playcounts 
        Dim playcountList : set playcountList = new cPlaycountItem ' as cPlayCountItem

        ' join helper 
        dim c : set c = new cJoin

        r = mrNo
        Dim j : For j = 0 to tracks.count - 1 

            ' which item in MM
            dim item : set item = tracks.item(j) 

            ' have we got a valid reference in MM        
            c.splitCustom1 c.getCustom( item ) 
            if not c.valid then 
            
                ' add the file to iTunes
                addFile item 
                
            else
            
                ' have we got the track already in the itunes library?    
                dim t : set t = app.LibraryPlaylist.tracks.ItemByPersistentID(c.itIDhigh , c.itIDlow) 
                
                ' no we haven't
                if t is nothing then 

                    ' add the file to iTunes
                    addFile item 
                                
        		else
        		    ' yes, we have it already (which is quicker, but we need to check if things have changed)

                    if recoverPlaycounts then 
                        ' has it been played?                
                        If t.playedcount > 0 Then
                            ' accumulate the counts 
                            playcountList.add t, item 
                        End If
                    end if
                    
                    if recoverRatings then 
                        ' are the ratings different to what was synchronised?
                        if (t.rating <> c.itRating ) or (toItRating(item.rating) <> c.itRating )then
                        
                            if r <> mrYesToAll and r <> mrNoToAll then
                                r = SDB.Messagebox( "Rating changed for " & item.title &  " " & cstr(t.rating) & "," & cstr(item.rating) & ". Update the database?", mtWarning , array(mbNoToAll,mbNo,mbYes,mbYesToAll) )
                            end if 
                                  
                            if r = mrYes or r = mrYesToAll then                      
                                ' has mm changed ratings
                                if (toItRating(item.rating) <> c.itRating ) then
                                    ' update iTunes
                                    t.rating = toItRating(item.rating)
                                    c.itRating = t.rating 
                                else
                                    ' has itunes changed ratings 
                                    if (t.rating <> c.itRating ) then
                                        ' update MM
                                        item.rating = toMmRating(t.rating)
                                        c.itRating = t.rating 
                                    end if 
                                end if 
                                
                                c.updateCustom item , c.combineCustom1( c.itIDLow, c.itIDHigh , c.itRating)
                            end if 
                        end if 
                    end if 
                                    
                    ' has it changed after it has been sent to iTunes
                    if item.FileModified > c.syncDate then
                        addFile item
                    end if 
        		end if 

            end if 
            
            if Progress.count() then exit For 
        Next

        if recoverPlaycounts and Not progress.terminated() then
            ' did we recover any?
            progress.Init "Recover playcounts from iTunes to MM" , playcountlist.count()
            playcountlist.addToMM progress
        end if 
        
        ' and flush to the DB
        SDB.database.commit
    
    End sub
Mark
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

Re: Export to iTunes

Post by markstuartwalker »

Number 14 just released fixing a bug in the Last Played dates.

This also does the bidirectional playcounts like you alway wanted ;-)
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Export to iTunes

Post by nynaevelan »

markstuartwalker wrote:
ExportToItunes|0|10/15/2009 2:24:48 PM|155584055,1226135401|100
This is some additional 'join' information that I now store in MM which allows quicker and more consistent indexing into the iTunes DB. It contains several fields all crunched into a single string type DB column

ExportToItunes is there as an identifier so that I can sidestep existing information
0 is the format version - I am future proofing here in case I choose to store even more information in the future.
10/15/2009 2:24:48 PM is the time at which the last sync occurred
155584055,1226135401 are the low,high index into the iTunes DB which is comparable to the ID column in the MM database
100 is the ratinging that was written into iTunes

The advantage of capturing this information is to improve indexing speed (indexing by track name was not 100% accurate)
The timestamp allows some more intelligent last played decisions
The rating allows bidirectional rating detection.

If you are feeling geeky have a look at the routine which does the synchronising ....

Code: Select all

    ' synchronise the playlist that contains the superset of all files 
    Public Sub syncPlaylist( playlistName , progress ) ' as String , as cProgress

        dim sdbplaylist : set sdbplaylist = SDB.PlaylistByTitle( playlistName )
        dim tracks : set tracks = sdbplaylist.tracks
        
        Progress.init "Sync playlist " & playlistName , tracks.count
        
        ' cache these 
        dim recoverPlaycounts : recoverPlaycounts = g.ini.recoverPlaycounts
        dim masterRatingsInMM : masterRatingsInMM = g.ini.masterRatingsInMM
        dim recoverRatings : recoverRatings = g.ini.recoverRatings
        
        dim r 
        
        if recoverPlaycounts then 
            if g.ini.recoverPlaycountsWarning = false then 
                r =SDB.Messagebox( "This will recover playcounts from the iTunes database (and any connected iPod/iPhone) and add them to the Media Monkey database. Is this what you want to do? Select 'No' to abort this action." , mtWarning , array(mbYes,mbNo) )
                if r <> mrYes then exit sub
                g.ini.recoverPlaycountsWarning = true
            end if 
                
        end if


        
        ' list of playcounts 
        Dim playcountList : set playcountList = new cPlaycountItem ' as cPlayCountItem

        ' join helper 
        dim c : set c = new cJoin

        r = mrNo
        Dim j : For j = 0 to tracks.count - 1 

            ' which item in MM
            dim item : set item = tracks.item(j) 

            ' have we got a valid reference in MM        
            c.splitCustom1 c.getCustom( item ) 
            if not c.valid then 
            
                ' add the file to iTunes
                addFile item 
                
            else
            
                ' have we got the track already in the itunes library?    
                dim t : set t = app.LibraryPlaylist.tracks.ItemByPersistentID(c.itIDhigh , c.itIDlow) 
                
                ' no we haven't
                if t is nothing then 

                    ' add the file to iTunes
                    addFile item 
                                
        		else
        		    ' yes, we have it already (which is quicker, but we need to check if things have changed)

                    if recoverPlaycounts then 
                        ' has it been played?                
                        If t.playedcount > 0 Then
                            ' accumulate the counts 
                            playcountList.add t, item 
                        End If
                    end if
                    
                    if recoverRatings then 
                        ' are the ratings different to what was synchronised?
                        if (t.rating <> c.itRating ) or (toItRating(item.rating) <> c.itRating )then
                        
                            if r <> mrYesToAll and r <> mrNoToAll then
                                r = SDB.Messagebox( "Rating changed for " & item.title &  " " & cstr(t.rating) & "," & cstr(item.rating) & ". Update the database?", mtWarning , array(mbNoToAll,mbNo,mbYes,mbYesToAll) )
                            end if 
                                  
                            if r = mrYes or r = mrYesToAll then                      
                                ' has mm changed ratings
                                if (toItRating(item.rating) <> c.itRating ) then
                                    ' update iTunes
                                    t.rating = toItRating(item.rating)
                                    c.itRating = t.rating 
                                else
                                    ' has itunes changed ratings 
                                    if (t.rating <> c.itRating ) then
                                        ' update MM
                                        item.rating = toMmRating(t.rating)
                                        c.itRating = t.rating 
                                    end if 
                                end if 
                                
                                c.updateCustom item , c.combineCustom1( c.itIDLow, c.itIDHigh , c.itRating)
                            end if 
                        end if 
                    end if 
                                    
                    ' has it changed after it has been sent to iTunes
                    if item.FileModified > c.syncDate then
                        addFile item
                    end if 
        		end if 

            end if 
            
            if Progress.count() then exit For 
        Next

        if recoverPlaycounts and Not progress.terminated() then
            ' did we recover any?
            progress.Init "Recover playcounts from iTunes to MM" , playcountlist.count()
            playcountlist.addToMM progress
        end if 
        
        ' and flush to the DB
        SDB.database.commit
    
    End sub
Mark
Thanks for the explanation and :lol: :lol: I am not smart enough to know what I am looking at and just geeky enough to be dangerous.
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
Post Reply