iTunes playlist sync
note - apple mac only!
i'm a playlist fanatic - i love organizing my music with them, so i can easily put on the kind of thing i want right when i have a hankering for it. i'm very happy with iTunes playlists, and i urgently want to be able to easily synchronize my main ones - and the tunes that belong on them - to my android phone. i developed a Mac OS python script to scratch that itch, enabling me to replace my old iPod with my android phone. the script does incremental syncs, fairly efficiently ensuring accurate copies of a selected iTunes playlist and all its contained playlists and music files. it does so in a way that compensates for some very irritating logistical flaws in the standard android music players. see features, below, for details.
the script runs only on MacOS X with operational iTunes and requires python with appscript installed.
i developed and have been using the script since about October, 2009. i synchronize a collection of around 200 playlists (i did say fanatic, right?), which includes over 2600 MP3 tracks, quickly and cleanly. the script might be useful to you. it is free and open source (under a dual GPL and Apache license). if you're running Mac OS X and use iTunes, please give it a try and let me know what you think!
- incremental - only those playlists and music files necessary to rectify differences with the files already in the target hierarchy are copied.
- the target directory on the device is also purged of playlists, track files, and directories which do not correspond to any elements within the subject playlist's hierarchy. (other files and directories are left undisturbed.)
- the synchronization is done with respect to mounted filesystems, so simple USB storage mounting or smb/samba shares can be used (though the latter can be slow with lots of files
compensation for irritating android player flaws:
playlist folder nesting is reflected in the names of playlists on the device.
i organize my playlists in shallow iTunes playlist folder hierarchies, to distinguish playlists according to various kinds of categories. typical iTunes sync mechanisms discard the folder containment info, sacrificing what is, to me, crucial distinguishing features of the playlists. it really sucks - and with playlistsync i compensated for it. playlistsync encodes containment info in the target playlist names - eg "rock_newwave" for the "newwave" playlist contained in the "rock" playlist folder.
(it turns out that apple's old iPod - and maybe new iPod touch and iPhone? - synchronization discards the folder containment info, which i find supremely irritating. in that case i don't have as easy recourse, since they don't expose the sync via filesystem. fortunately, i prefer android phones... :-)
further, target playlists are created for the iTunes playlist folders, so that there is a "rock" playlist containing all the items in the "newwave", "classic", "sparse", "prog", and "casual" sublists, or whatever.
put a short, silent "stub" track at the top of each target playlist, for device shuffle-play that, pathetically, always launches playlists with the first track.
simplistic shuffle-play schemes, including those of Android's default music players, always launch with a playlist's first track, and shuffle from there. this script provides a workaround, optionally setting every target playlist's first track to a dummy "stub track". i use `a track that consists entirely of 1 second of silence`_.
provide a way to control ordering of playlists, using their names, that sorts the same in both iTunes and the android players.
among my very many playlists i have several favorites. i want those favorites to wind up before their less preferred siblings in the sorting, yet i still often want to use the lower priority playlists. likewise, i want to be able to put some categories ahead of others. unfortunately, the standard android players impose an alphabetic sort on the playlists, so i have to use literal playlist name prefixes to control ordering. to compound this complication, the sortings vary between the two standard "Music" players and that of iTunes - so playlist sync has configuration to systematically transform specified playlist name prefixes to preserve sort order across the players.
(this provision works with the composite folder + playlist nesting names, of course, to convey ordering within a category as well as among categories.)
failsafe - to avoid unintended deletion of music files in mistaken target directories, the target directory must contain a file with the name specified by TARGET_DIRECTORY_FAILSAFE_FILE. the user is prompted for creation of the failsafe file if absent, eg the first time the script is run.
Configuration and Operation
follow the python appscript instructions to install appscript in the python you'll be using to run the script.
configure the script by setting variable names in the script code and/or using command-line options, overriding the persistent configuration variables. see the script code, below the "Configuration Below" line, for the user-configurable variables, with explanations. invoke with '--help' to see the available options.
the synchronization target directory must exist and be writable.
to avoid unintended deletion of music files in mistaken target directories, the target directory must contain a file with the name specified by TARGET_DIRECTORY_FAILSAFE_FILE. you will be prompted for creation of the failsafe file if absent, eg the first time you the script targets that directory. you can tell the script to create the failsafe file when necessary, without prompting, by passing in "-c" / "--create-failsafe" that first time (or you can set ALWAYS_CREATE_FAILSAFE in the script to True, but it defeats the safeguard while set.)
invoke by applying the appscript-equipped python on playlistsync.py, specifying the target directory with the '-d' option if you haven't configured the TARGET_DIRECTORY_PATH script setting:
python playlistsync.py -d /Volumes/andUSD/Music/synchronized