iPod, the Unix way

Heck, yes: I have an iPod, a 3G one, and it served me very well those last four years. But I always wanted to store the music where I think it is better to, not where Apple thought the music should be. Recently I discovered that libgpod can directly set the path to the file in the database used by the iPod, so I wanted to code a small hack to create a database with my directory structure being honored. Although I was quite busy, I finally did an initial implementation which works pretty well, but with some issues:

  • Playlists will be totally erased. Consider yourself warned. Maybe someday I decide to add support for smart playlists, but I am not sure about regular ones (I do not use them).
  • Only MP3 and AAC (untested) music content will be in the database after running the script.
  • Database will not be created if it does not exist, use gtkpod or your preferred iPod management utility to initialize the database. Remember: the script will refuse to initialize your iPod.
  • Do never use funky file names with non-ASCII encodings. Althought at least ISO-8859-1 should work with FAT (Windows) formatted iPods, and HFS ones should cope with UTF-8, I did not spend time guessing how to properly encode file names in the database.
  • The WFM syndrome applies to this hacky piece of software.

You will need the following in or order to use my iPod database updater (available in Gentoo, of course):

  • Python 2.4 (version 2.3 should works as well, but I only tested 2.4)
  • libgpod 0.4.x, built with USE=python
  • mutagen 1.8 or better
  • An iPod 😉

Usage is pretty straightforward:

  1. Download the script, name it ipod-update and mark it as executable with chmod +x ipod-update.
  2. Copy music to your iPod, you decide the layout. For example, I have a Music directory at the root of my iPod, and the structure follows the Artist/Album/Title structure. You can copy files with regular Unix tools like cp, rsync, mv or a file manager.
  3. Run the update script, passing the mountpoint option:
    $ ./ipod-update -m /media/ipod-mountpoint
  4. Wait for your music to be scanned and the database written.
  5. Unplug your iPod and enjoy!

Do you want to add, remove or move files around? No problem: just change the contents of the volume until you are satisfied with the results and re-run ipod-update.

Warning note: I am not responsible for any damage this program could make to your music and/or iPod. Even so, it is working like a charm for me and I took care to make the code only read files and never write to them; only the database is written after all your music was scanned. You can use the --backup flag the first time the updater is ran to save a copy of the database to iPod_Control/iTunes/iTunesDB.old, which you can use to restore the database.

Advertisements

One thought on “iPod, the Unix way

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s