Sunday, February 21, 2010

Sansa Clip+ with Rhythmbox

Some infos on how to use the Sansa Clip+ in combination with Rhythmbox for Podcasts:

1) Put the device via its Settings menu into MSC mode, so that you can access it as normal USB storage

2) Create a file .is_audio_player with the following content in the root directory of the device:


3) Next time you plug the device in it should show up in Rhythmbox and you can drag&drop music onto the device from within Rhythmbox.

Note: Sometimes Rhythmbox doesn't register the device for some unknown reason. Replugging it sometimes help. Sometimes when to many other USB storage devices are connected it doesn't seem to work at all.

4) apt-get install id3v2

So far everything works nice and easy, but it doesn't work quite perfectly, as Rhythmbox uses the RSS feeds for file information, while the Clip+ uses ID3 tags and those are often messed up or non-existing for many podcasts. To fix that up I currently use a few quick&dirty scripts.

The first script scans for filenames and directory names, which Rhythmbox creates with the RSS info, and then uses those to correctly set the MP3 tags. For this to work its important to have a high enough folder_depth option set, as Rhythmbox naming behavior changes depending on the value of the option. Lower values mean that Rhythmbox will put author, title and album into the filename, which will make it more more difficult to split them up. A high value means Rhythmbox will name things" ${author}/${album}/00 ${title}.mp3". The leading ${author} part is annoying, but there doesn't seem to be an easy way to get rid of it. To use this script you have to adjust the directory in the first line to match your setup:

for j in /media/mp3/PODCASTS/*/*/; do
pushd "$j"
for i in *.mp3; do
echo "$i"
id3v2 -a "$(basename "$(dirname "$(pwd)")")" -A "$(basename "$(pwd)")" -t "$(echo "$i" | sed "s/^00 - //;s/\.mp3$//")" "$i"

You can download the script with a few improvements here.

The second script is used to fix the sorting of the podcasts by setting a track number. The sed expression isn't generic and needs to be adopted from podcast to podcast, as Rhythmbox itself doesn't seem to supply a useful track number:

for i in *.mp3; do
id3v2 -T "$(echo "$i" | sed "s/.*\([0-9]*\).*/\1/")" "$i"

One could of course change that to use the order provided by "sort -n" instead of extracting a number from the podcast, but again that depends on the podcast, some podcasts don't work properly with "sort -n"

The Clip+ also provides "browse by folder", but when you do browse by folder it no longer tracks the current position in podcasts, so you really want to make sure that you use the normal PODCAST/ directory on the device and the related menu entry on the Clip+.

On some ID3 tags the clip seems to get confused, haven't really tracked down which those are, so one might want to play around with the --delete-all and --delete-v1 options of id3v2. V2 tags seem to work better then V1 ones.

One thing to keep in mind is that id3v2 will write a new file when you change the tags, so it will take extra storage on the Clip+ to get it works done. Once the tags are in place however the script can be called multiple files, id3v2 will not touch files where no change is required.

Some quick comments about the device itself:
  • its small
  • its cheap
  • it supports Ogg and Flac
  • has a microphone and recording
  • the OLED display is pretty good
  • menu structure is ok
  • it keeps track of position in podcasts and audiobooks, but not music
  • it features a microSDHC slot (which I taped, as I don't use it right now)
  • the color on the keys is no good, after two month it is already gone (see pic below)
  • overall I am pretty happy with the little thing
  • Update: after three month the clip hinge broke :(

PS: Rhythmbox is doing a lot of weird things, aside from the random crash every now and then, it has now multiple times mixed up the podcast database, causing one podcasts episode to point to another podcasts episode's mp3 instead of its own. It doesn't happy often and only with single mp3, still a little annoying. Rhythmbox also is bad at tracking which podcasts have already been listened to, podcasts already deleleted pop up every now again at random.

PS2: For Replay Gain you need mp3gain 1.5.1 and must use ID3v2 tags (mp3gain -s i ...) instead of the APE tags, this means you have to grab the source, as the mp3gain version in Ubuntu doesn't support ID3v2 tags. (untested)

PS3: In theory the Sansa should support Unicode, in practice that however doesn't work and the tags generated by id3v2 come out garbled, not sure who is at fault, might be id3v2 not setting the correct encoding, so as a workaround I added recode to the script to translate stuff to Latin-1.