With Android devices - if you don't want to use "MediaMonkey for Android" - Auto-Sync is unable to sync back ratings (tags only, not the entire file!) and play count, neither in MTP (Media Player) nor in MSC (Mass Storage) mode. Basically the same problem exists for all portable devices in MSC mode.And here comes the solution: this script enables you to sync your rating tags from any portable USB device back to MediaMonkey and to sync play statistics from/to Android Music PlayerPro!

How does it work?

The script looks up all tracks from the last Auto-Sync of a device in MediaMonkey. Therefore the songs are matched precisely by their ID in MediaMonkey and the file name on the device. So it doesn't matter if you changed e.g. the artist name of a song after your last Auto-Sync anywhere, or even the file name on the PC. And it works for format converted songs as well, e.g. ape on PC and mp3 on portable device.

Ratings are synced back from the device node (be aware that in MM 4 only the Folder node shows current tags, the Music node is not refreshed).Unchanged or empty (no star) ratings are ignored.Play count, skip count (needs MM 4) and last played date are synced from an XML file on the device. If a value is higher than in MM it is copied to MM, otherwise it is copied from MM. At the moment, this feature is supported only for Android with PlayerPro as music player app. New files from the device are ignored (e.g. tracks downloaded to a phone).If you have several synced MSC devices, you can choose which one to sync. The device has to be attached of course...

If Windows Media Player or Winamp was selected as rating system before, you may see different ratings, because PlayerPro adds a new rating tag instead of moving the ratings from one system to another. Then in MM you may only see the old ratings. To clean up, check/set the ratings in MM manually first, delete all music from the device and do a complete Auto-Sync.

How to sync play statistics:

In MM, go to Tools, Options, Portable/Audio Devices, SyncBackRatings and enable "Sync back play count from PlayerPro on Android (Songbird format)"

Create the XML file from PlayerPro. To do this, start the app, go to Settings, Library, Settings, Music library, Export music stats, Songbird.

Attach the device (you may have to activate the USB drive and restart MM)

Start "Sync Back Ratings"

Detach the device (eject and deactivate)

In PlayerPro, Import music stats, External library. After an auto-sync do steps 2-6 before playing any music in order to import stats from MM first.

Updates or Uninstall

To update or uninstall, go to menu Tools->Extensions. Uninstall will remove any older manually installed version (before v0.7) as well. If you update from a version before v0.7, it is strongly recommended to uninstall the old version, either manually (delete from \scripts and scripts.ini) or by installing, then uninstalling and reinstalling the current version.

This has to be executed manually. Does anybody know how the script could execute an Auto-Sync afterwards? I guess it's not possible to let the script be started automatically with an Auto-Sync, but before MM syncs actually?

To get the ratings the script navigates to the node of the device and reads its song list, which can take some time.

'----------------------------------------------------------------------------------------------------------------' Sync back ratings and play count from device to MM according to last executed sync'' 12. Mar. 2013' First created 14. Aug. 2011' by Aff'' Some portions inspired from trixmoto and apoujade' Thanks abatistas1709 for contributing conversion from UTC/GMT to local time'' For details please visit the MediaMonkey forum:' http://www.mediamonkey.com/forum/viewtopic.php?f=2&t=59888'' This program is free software: you can redistribute it and/or modify' it under the terms of the GNU General Public License as published by' the Free Software Foundation, either version 3 of the License, or' (at your option) any later version.'' This program is distributed in the hope that it will be useful,' but WITHOUT ANY WARRANTY; without even the implied warranty of' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' GNU General Public License for more details.'' You should have received a copy of the GNU General Public License' along with this program. If not, see <http://www.gnu.org/licenses/>.'' If you plan to modify this script and publish it, please' - make a clear reference to the above-mentioned forum thread and authorship' - use the most recent source if possible' - inform me (PM) if there are any bugs in my code or if you have made any improvements to it.'----------------------------------------------------------------------------------------------------------------

'MM4: Navigate to Folders node (first Music node is not relevant as it reflects the PC or sync history rather than the actual track tags from the device) If SDB.VersionHi >= 4 Then Node.Expanded = True 'necessary before activating FirstChildNode if the node wasn't expanded once manually before! Otherwise children not available. MM bug IMHO. Set Node = SDB.MainTree.FirstChildNode(Node) Do While Not Node Is Nothing WriteLog Node.Caption & " _ " & SDB.localize("Folders") If Node.Caption = SDB.localize("Folders") Then Exit Do Set Node = SDB.MainTree.NextSiblingNode(Node) Loop If Node Is Nothing Then SDB.MessageBox AppTitle & ": " & SDB.localize("Folders") & " node '" & DevTg & "' not found", mtError, Array(mbabort) Exit Sub End If End If

'check if play count has to be synced to MM Dim iNewPlaycount iNewPlaycount = 0 Dim iNewSkipcount iNewSkipcount = 0 Dim dNewLastPlayed dNewLastPlayed = CDate(0) '...and if there are changes to be imported in Player Pro Dim bImpStatsTrack

Set oCtrl = SDB.UI.NewCheckBox(oSheet) With oCtrl .Checked = SDB.IniFile.BoolValue(AppID, "NoSyncIfModifiedInMM") .Caption = "Don't sync back rating for tracks with file modification on PC newer than on device" .Common.SetRect 10, 10, 425, 20 'L, T, W, H .Common.ControlName = "cbNoSyncIfModifiedInMM" .Common.Hint = "If the modification date of a song on the PC is updated by any tag change, not only ratings, the rating won't be synced, " & _ "except if there is no rating on the PC, but on the device" End With

Set oCtrl = SDB.UI.NewLabel(oSheet) With oCtrl .Common.SetRect 10, 104, 65, 20 'L, T, W, H .Common.ControlName = "lbTimeOut" .Caption = "Time out when waiting for the device song list for more than:" End With

Function RatingMM2XML(iRating)'PlayerPro doesn't support bomb and half stars yet and interprets 0 the same as empty, i.e. we can simply round RatingMM2XML = Round(0.01 + iRating / 20) 'Trick to round 0.5 up to 1 because VB does Banker's rounding, see http://support.microsoft.com/kb/196652/EN-USEnd Function

0.3 - Last synced device is preselected- Checks for fully loaded song list (no more user interaction needed)- List of tracks with ratings to be updated, user can decide if update shall be executed- Sync only if there is a rating from the device (don't overwrite existing ratings with empty ones)- go back to last node- Some other minor improvements

0.4 (2011-08-15)- Only synced usb msc devices can be selected. No selection needed if there is only one.- Handling fixed if device is not attached (missing node)

0.4.1- Listbox description changed- Known issue (since 0.3): for format converted songs the sync is applied even if the user cancels from the list of tracks to be updated (MM bug?)

0.5 (2011-08-26)- (Resolved known issue:) really no change to tags at all until user presses OK from the list of tracks to be updated- Timeout for reading device song list increased to 90 sec

0.8 (2011-10-16)- Don't sync back if the rating on the device is unchanged since the last Auto-Sync- Option sheet (under Portable/Audio Devices)- Options: don't sync back if the file date on the PC is newer; set time-out limit for the track list from the device- Default timeout for reading device song list increased to 120 sec- Uninstall removes the menu items (no restart of MM needed anymore)

0.8.1 (2011-10-17)- If option "Don't sync back tracks having a file modification on the PC..." is set, sync back anyways if rating is empty on the PC

1.2 (2012-01-15)- Sync back skip count (MM4) and last played from PlayerPro- Check 'All' node setting

1.3 (2012-02-19)- Convert UTC/GMT to local time for last played date. Thanks a lot to abatistas1709 for contributing this!- Additional USBMass DLLs (e.g. USBMass1.dll for your phone and USBMass2.dll for your partner's phone) were ignored- Hints added to some error messages- GNU General Public License (GPL) added

1.4 (2012-09-02)- Sync stats from MM to Player Pro via import file (based on the last export)- Sync back from PlayerPro was indicated even if there was no change, because of a finer time resolution in the XML than in MM - Option for writing a debug log file

1.5 (2012-09-02)- Change items in import file for Player Pro only where needed- Inform user if import in Player Pro is recommended

1.6 (2012-10-06)- Added message text on how to ex-/import PlayerPro statistics and about deactivating WMDM- Buttons in report list keep the exact position to the bottom when window is resized- Log file shows statistics that are higher in MM than in PlayerPro (MM > XML)

1.7 (2012-10-08)- XML track matching improved where PlayerPro uses file or folder name (e.g. flac, unknown album and multiple artists)- Message and detailed log if tracks could not be found in the XML

1.8 (2012-10-15)- XML track matching improved for unknown song titles- Detailed reports- Log tracks that were not found on the device

1.8.1 (2012-10-16)- Report layout improved

1.9 (2013-02-23)- Match for USBMass*.dll instead of USBMass?.dll- Check and optionally show duplicate tracks in XML- Ignore case for XML look up

1.9.1 (2013-02-23)- More detailed log for duplicate tracks in XML

1.9.2 (2013-03-12)- Ignore case for Music node matching

1.9.3 (2013-12-03)- Message fixed when synced song is missing in MM

I'm looking forward to your feedback! Hope the script is useful for some of you!

Last edited by Aff on Tue Dec 03, 2013 5:37 pm, edited 50 times in total.

Awesome!! I've been having a hell of a time getting the same two way syncing functionality on my android that I was so used to with itunes--ipod.Fist time I tried syncing mm with my phone a bunch of artists came up as "unknown artist" in playerpro. After hours spent reading forums, I realized there was an issue with how android recognizes ID3 tags for .m4a files. Luckily I was able to get around this using the auto-conversion setting (removing m4a from the list of supported formats and setting it to auto-convert to mp3). I thought I was finally in the clear but as a test when I updated the rating of a song that exists as .m4a on my pc but as mp3 on my phone, I found that this workaround wouldn't allow for two-way syncing.

Alas I installed your script and BAM! The ratings I update on my phone sync back to the pc regardless of file extensions. Cheers, thanks for the HUGE help!! Now if only android fixes this issue with ID3 tags for m4a files.

Question---Any way to make it so that it only syncs the most recently updated ID3 tags to your pc? (ie: some ratings from your phone sync back, but some that have been updated more recently on your pc remain)

Thank you very much for your great feedback!! I was already beginning to think that nobody is interested in this script.

There is a commented out piece of code to check which one is newer - PC or phone. I haven't integrated it because I can only check the file date. There is no possibility (as far as I know) to check especially the date of a rating change, but every change to the file counts, e.g. new album art or lyrics in MM that are written to the tag in the file trigger a file date change (if configured to do so in MM).

Nevertheless I think this is a good request and I will incorporate it as an option. This will take some time as coding an option sheet is a bit of work.Do you agree that if the file on the PC is newer but has no rating yet, it should be updated from the portable anyway?

Hey, I just discovered this thread. Will test your script soon.As you mentioned PlayerPro, I headed to Android Market to see its specs. Looks like a very good player. AND besides Rating, it also supports embedded/online lyrics and album art (which is awesome).

But what really caught my attention was the ability to import/export play statistics (ratings, play/skip counts, last played dates) in an iTunes XML format. If you add support for this, then we could get a real sync between device and MM, like what MM already does with iPods and iPhones.As far as I can remember, there's a script around this forum which does the iTunes XML export thing. It could serve as inspiration!

Thanks for your suggestions. I was looking into syncing of play counts etc., it is planned for a future version.

At the moment, the export of play statistics from PlayerPro in iTunes format doesn't seem to work. I hope it will and that it will incorporate the file path on the mobile device. The Songbird format works, but it has no file path, only title, artist and album. If you change one of those tags in MM, the track can't be matched anymore. I had a short look at the script you linked to export play statistics from MM. It's interesting, but at this time I don't plan to integrate it, as it doesn't fit smoothly into my script. As long as Android doesn't support all tags with MTP, there is really some room of improvement for syncing with MM. Even with PlayerPro you have to im-/export the play count statistics manually at the moment, which I think isn't very practical.

This is an exciting project -- can't wait for the play count sync (my only current use case, although I'm sure I'll enjoy ratings sync once I get a device that actually allows me to set ratings). Your goal of handling this automatically on a sync is a worthy one. I do recall seeing a function to initiate a sync, but now I'm unable to find it -- unfortunately, the programmer documentation isn't very thorough. It would be even more useful to be able to catch an OnSyncBefore event (if such a thing existed, it's not in the documentation), of course.

I'm working on a project that has a bit of overlap; I've written a Python script that builds a playlist using podcasts and music. Naturally, it's very important to me whether a given episode has been listened to, since I don't want to include already-heard podcasts in my playlist. I also just got a feature request for being able to sync multiple devices from a single account, each with its own playlists and play information. I'm planning on using sync information to accomplish the last goal; I'm also going to have to disable mediamonkey's ability to delete a song as soon as it's played, of course (since just because it's been played on one device doesn't mean the library's done with it).

When I select Sync Back Ratings, I get the following error message: "SyncBackRatings: You have no synchronized devices". I have MediaMonkey 3 in Windows 7, with a Motorola XT720 in USB mode which shows up on the MediaMonkey list at the left of the screen. What am I doing wrong?

@Prooffreader: Have you done a MediaMonkey Auto-Sync first to copy the music to your Motorola? SyncBackRatings does no initial sync, but reads the list of previously auto-synced tracks and checks them for ratings. The advantage is that this way each track is reliably identified, even if you may have changed e.g. the album title on the PC after having copied the song to the device.

@DocMAX:There is a snag in your suggestions. Those tools copy the whole file from the phone back to the PC, not the tags! There are several problems with that:

No Auto-Conversion. MM can level the volume while synchronizing in order to have no loudness jumps when playing the music on the device. This is done by permanently changing the volume in the file on the phone. When you sync this file back to the PC, you loose your original! Thereby you may loose some sound quality and the replay gain tags would have to be updated.MM can convert the format of files that your device can't decode, e.g. from APE to MP3. Obviously it doesn't help to sync back the MP3 file (you would create a duplicate in MM).

No changes allowed on PC.Often I update tags on the PC for files after they were copied to my phone, e.g. to add lyrics or album art. So either the file simply wouldn't be synced back to the PC because it is older than on the PC, or if it was newer, all the changes made on the PC would be lost.

Furthermore MM can do this kind of simple file sync back by itself ("Auto-Sync tracks from the device to the PC"), except that it can't add completely new songs from the device to the PC.

These severe drawbacks are the reason that I've written SyncBackRatings

1. Auto-conversion is not needed for me. All files on PC are allready prepared for Android (volume levels, bitrates,...)2. If any changes are done on PC and you set MM to set new timestamp PC file is newer than on Android. Thus SyncBackPro will copy PC -> Android.

I'm also getting the sync back error mentioned previously "you have no syncronized devices". I have auto synced my list a few times, plugged and unplugged it, etc. Same setup as the other commenter but using a Galaxy II