This was taken from the litux.org archives. It was hard to find, and seemed to be transitory so I copied it to my own web space. As of October 14, 2005 I have not used it, but it looks interesting and I hope to try it soon. The package may be available at cvs.litux.org, but the link is flakey and I am not hosting the package myself.
Tuesday, 31 May 2005, at 21:36:11 WEST, by Bruno Rodrigues.
Under Apple, Computers, Projects, Music and Mobile Devices.
On June, 23 2004, I’ve started a Python application to synchronise the iTunes library with our Archos Jukebox (as a side note, it was also my first Python application with more than 10 lines). Since that day, this application has been enhanced to provide several similar, but unrelated, tasks. It’s still called Archos-iTunes, but its name should have been changed to something more generic.
This project started after having lots of problems with rsync in Mac OS X, specially when used against an Archos device over USB. I never understood if it was an Apple USB bug or an Archos bug. Copying a file with cp or with Finder worked perfectly, but with rsync it was typical to get corrupted files.
This application can be used to do backups of your library, either to another hard disk or to burn DVD’s, can synchronise with Archos devices - including .m3u play-lists and folder-name voice files, and more recently, to fill up other kind of devices with random music, in a similar way to the iPod Shuffle concept. It syncs the files in iTunes with another device (or folder) in an incremental way, like rsync. It is aware of iTunes play-lists, meaning that it can synchronise the music available in one play-list (or a set of play-lists).
As I don’t have any real documentation for it, due to lack of time, I’ll write here some notes on how I use the application. iTunes Library Disk Backup and DVD Burning
I’m using the Grouping field to tag my music and split it into DVD’s play-lists. When an album is fully sorted, with covers et all, it’s tagged as MP3-XXX and appears automatically in specific Smart play-lists filtered by that field. Any music without this tag is available in the Chaos Smart play-list, ready to be sorted out. Every time a MP3-XXX play-list hits around 4.4GB, I burn them, and start deleting music that I don’t usually listen (or don’t want to listen) to release disk space.
To backup a play-list, I use my application like this:
$ ./ArchosiTunes.py -j “/Volumes/External HardDisk/Files/MP3-XXX” -p MP3-XXX -d 4 –delete
This will create an archive with the music present in the MP3-XXX Smart play-list. It creates an iTunes/iTunes Library folder, with “Artist Name” sub-folders, and then “Album Name” sub-sub-folders, which is the same structure as the one used locally in iTunes. It also creates a Playlists folder, with “By Artist”, “By Album” and “By Genre” sub-folders, each with .m3u play-lists.
When it hits the right size to fit a DVD, I run an additional step with the –paranoic parameter:
$ ./ArchosiTunes.py -j “/Volumes/External HardDisk/Files/MP3-XXX” -p MP3-XXX -d 4 –delete
This will make sure that every file is not corrupted, by comparing them with the original files in iTunes.
Then I just need to burn the tree with a regular burning application. The DVD won’t play automatically in iTunes, but at least I don’t loose any music file. Archos Synchronisation
$ ./ArchosiTunes.py -j /Volumes/JUKEBOX -p JUKEBOX -d 4 –delete –voice
The -p argument defines the play-list prefix name, which means that this -p JUKEBOX request will use any iTunes playlist that starts with “JUKEBOX”. This allows me to create play-lists like JUKEBOX-Rock and JUKEBOX-German Music, and the application will copy the music present in either playlist, and create the iTunes/Playlists/Rock.m3u and iTunes/Playlists/German Music.m3u playlist files. If a song disappears from these playlists, the –delete argument will make sure that the music gets deleted and releases space from the device. The –voice parameter will enable the creation of several _dirname.talk files, one per directory, with the folder name spoken. I’m using the Mac OS X’s system voice generator, and it requires the “lame” binary to translate the .aiff file generated by /usr/bin/say into a MP3 file. Shuffling
$ ./ArchosiTunes.py -j /Volumes/SonyEricsson -p SonyEricsson -d 4 –delete –flat –size=900
Enabling the –size parameter will also enable the random music selection. From all music present in the specified iTunes playlist, the application selects random music files until it fills the specified size (in MB). In this case, it would be probable to have only one or two music files per album. Also taking in consideration that a 1GB memory card will host two or three hundred songs, having folders with sub-folders and a single file doesn’t make sense. The –flat argument disables the folder structure and playlist generation, copying all files to the directory specified in the -j argument.