now | writings | rss | github | twitter | contact

syncing itunes music with the android g1

posted to writings on jan 26th, 2009 with tags android, g1, mac, nerd, and ruby and commented on once

i finally got around to putting music on my g1 and wanted a simple way of synchronizing an itunes playlist with a directory on the g1's sd card while it was connected over usb, just like my iphone used to once it was docked.

i found synctunes which is free (though not available on the author's site anymore for some reason) but it didn't preserve any directory structure on the destination and just lumped all of the files into one big directory.

i then found salling media sync which did just what i wanted, but in its unregistered mode it doesn't really sync intelligently and just deletes all the files and copies them every time. it looked nice and did what i wanted so i was going to register it, until i found out they wanted twenty two fucking dollars for this little utility. ridiculous.

i saved my $22 and wrote itunes-rsync. it's a command-line ruby script that pulls all of the filenames out of an itunes playlist (using the nifty rubyosa module), creates a scratch directory and builds symlinks to each of the real files, then just calls rsync and lets it do all the magic of figuring out what needs to be copied and deleted.

$> ruby itunes-rsync.rb ipod /Volumes/ANDROIDMMC/Music/
querying itunes for playlist "ipod"... found 794 tracks.
linking files under /tmp/itunes-rsync.QnLco/... done.
rsyncing to /Volumes/ANDROIDMMC/Music/... 
building file list ... done

sent 32611 bytes  received 20 bytes  65262.00 bytes/sec
total size is 7355076387  speedup is 225401.50
cleaning up... done.

normally it would list all the files it's copying or deleting but i already ran it so it just did a quick comparison and exited without having to transfer anything.

i suppose it could use some bells and whistles to do things like check that the playlist size won't overflow the card and handle podcasts, but it works for me.

note: the script uses rsync's --delete option, so make sure the destination directory is only used for music. anything else that's in it will get deleted, so don't yell at me if it wipes out everything on your sd card.

Comments? Contact me via Twitter or e-mail.

1 Comment

Pierre (not authenticated) on june 24th, 2009 at 20:59:51:

Works very well!! awesome and simple!!