IPod Shuffle 4g under Linux

Project Link: shuffle.py

Couple of months ago, I got an Apple Ipod Shuffle 4g. Despite the presence of IPod syncing apps under Linux, my experience was annoying. Shuffle 4g changed compared to its predecessors regarding the database format and new features, so a lot of plugins and apps don’t work as expected. In this post, I will write about different ways to tackle this annoyance.

Basic Things to Know

Bah! why can’t Apple make straightforward stuffs! Anyway, here are things you should know in a nutshell. IPod’s internal software works on a defined structure in the mass storage of the IPod. The process of creating this structure may be referred to as initializing your device. For adding any content to your device, a simple copy is not enough, changes need to be made in the database (The iTunesSD file) as well.

If you want to know more about the database format, I highly encourage you to read it at http://web.archive.org/web/20131016014401/http://shuffle3db.wikispaces.com/iTunesSD3gen

Some other ways to use Shuffle 4g under Linux (which I didn’t prefer)

  • gtkPod: The most popular iPod syncing app under Linux. Seemed too complex initially. Random crashes made it more annoying. Although it works, lacks the feature for voiceover.
  • Floola: Didn’t work at all with my IPod + Crashes!
  • Rhythmbox with IPod Plugin: Rhythmbox wasn’t able to initialize my IPod and I had to do it using gnupod. Other than this, it works fine. It took me a bit of initial effort to get my IPod recognized by Rhythmbox. I had somehow screwed up the partition structure of my IPod. Anyway, if you face the same problem, delete the whole IPod partition and repair it with iTunes. The plugin however lacks the voiceover feature.

My preferred way, using shuffle-db-ng

I stumbled across this modest looking project at https://code.google.com/p/shuffle-db-ng/ and took a liking to it immediately. It is a command line tool written in python and is simple and straightforward. And yes, it supports voiceover too!

  • Put your music files in the IPod
  • Run the Script, Done!

I studied the whole script after reading about the database format and learned few cool things. I wonder why the voiceover support is still absent from other popular IPod apps.

As a prerequisite, you need the following

  • python2.7
  • mutagen python library (Required for accessing audio tags)
  • pico2wav for voiceover audio (can be found in svox pico package. For Arch Linux users)

You may use the original shuffle-db-ng, or use my modified version which has following additions

  • Automatic initialization of the directory tree
  • Option to disable voiceover to save space
  • Renames file which crash the program raising Unicode Error (using the –rename-unicode flag)
  • A usage message on flags ‘-h’, ‘–help’

I will use here my version (obviously ;))

~ $ git clone https://github.com/nims11/IPod-Shuffle-4g.git
~ $ cd IPod-Shuffle-4g/
~/IPod-Shuffle-4g $ python shuffle.py -h
usage: shuffle.py [-h] [--disable-voiceover] [--rename-unicode] path

positional arguments:
path

optional arguments:
-h, --help           show this help message and exit
--disable-voiceover  Disable Voiceover Feature
--rename-unicode     Rename Files Causing Unicode Errors, will do minimal
required renaming

# Lets copy few music files to my ipod mounted at /path/to/ipod
~/IPod-Shuffle-4g $ cp ~/Music/*.mp3 /path/to/ipod
~/IPod-Shuffle-4g $ python shuffle.py /path/to/ipod
[*] Adding track /path/to/ipod/01 - Bitter Sweet Symphony.mp3
[*] Adding track /path/to/ipod/01 Ace Of Spades.mp3
[*] Adding track /path/to/ipod/02 - Black Sabbath - Iron Man.mp3
[*] Adding track /path/to/ipod/11 - Angel of Death.mp3
[*] Adding track /path/to/ipod/Center Of The Universe.mp3
[*] Adding track /path/to/ipod/Vodka.mp3
[+] Adding master playlist

# Unmount and Unplug your IPod and test it out!

But with the limited capacity of this little device, adding music this way will be tiring. Thanks to the python script, you can treat your IPod as a normal mass storage MP3 device, sync into it using rhythmbox or any other player, and run the shuffle.py to build the database.

To recognize IPod as an media device, add a file named .is_audio_player to the root of your IPod with the following content

name="VV's IPOD"
audio_folders=Music/

Open Rhythmbox or any other player, disable the IPod plugin and make sure the MTP plugin is enabled. Search for new devices and your IPod storage will show up. Add whatever you want to and before ejecting your IPod, run python shuffle.py /path/to/ipod as mentioned in the example.

shuffle.py also supports playlists (m3u and pls), but they are a bit of a hassle. The files pointed by the playlist should be inside the ipod storage. If this is true, shuffle.py will automatically scan the playlist file and build the database. Rhythmbox saves the day again! Open the MTP device in Rhythmbox. Select the playlists to sync through Your Device -> properties -> sync, select your playlists, then press the sync button. The .pls files will be created on your IPod and next time you run shuffle.py, Viola! you have your playlists on your IPod!

a

NOTE: In Rhythmbox, the playlist syncing can sometimes produce incorrect .pls files. I observed that this happens when there is some difference in the ID3 tags like artist and album artist in which case the path specified in the .pls file by the MTP plugin sometimes goes wrong, causing the shuffle.py to crash! In such cases, close Rhythmbox, delete the .pls files (not audio files) created on your IPod, start Rhythmbox, sync your device again, the hopefully the new playlists should be right.

If some other player works fine or better, please do comment 🙂

Further Development

I wish to do the following in my free time

  • Inbuilt support for adding playlists from hard drives.
  • A last.fm scrobbler using the info here
  • A Qt frontend (maybe)

Any suggestions, doubts, feedback on this post? Please do comment!

Advertisements

27 thoughts on “IPod Shuffle 4g under Linux

  1. Cliff Stockton

    Thanks for the script. My shuffle’s name had a space in it and I had to change it for the script to work. No spaces.

    When trying to get voiceover I get the following:

    “Warning: RHVoice not found, Russian voicever won’t be generated.”

    I install Pico from Synaptic package manager. Using Xubuntu.

    Any Ideas?

    Reply

How did you feel about this post? Push in your 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