Thursday, December 16, 2010

Preparing an audiobook for listening on an mp3 player

I recently ripped a 7-CD audiobook to listen to on my Sansa Clip+ MP3 player. After a bit of fiddling around with bash I was able to end up with a collection of 183 chapters named 1_01.mp3 through to 7_26.mp3 (the first bit was the disc number, then the track number.)

Simply copying these onto my player didn't work as the tracks were all out of sequence. In the past, with smaller books, I've simply skipped around between the sections to listen in order, but that wasn't going to be an option here.

After some experimenting I discovered the Sansa orders the tracks by the Track Number in the ID3 tag, so I fired off the following bash command to set up the ID3 details appropriately:

n=0 ;
for f in *.mp3 ;
do n=$((n+1)) ;
id3tag --artist="author name" --album="book name" --song="${f/.mp3/}" --track=$n $f ;
done

This numbers all the tracks from 1 to 183 in order and also sets the artist and album so I can find it easily in the Audiobook list. The .mp3 is stripped from the displayed filename too.

The id3tag program came from the libid3-3.8.3-dev package, not sure why/when I installed that one...

Saturday, December 04, 2010

Python+Emacs made easy with emacs-for-python

I don't know where this has been all my life but Gabriele Lanaro has put together a really easy to use package for adding lots of Python goodies to Emacs.

Just unzip the archive into ~/.emacs.d/ and add one line to your .emacs and your done (well, also remove all the now unnecessary random cargo-cult prior additions to your .emacs):

(load-file "~/.emacs.d/emacs-for-python/epy-init.el")

I had also previously installed a handful of Python/Emacs packages via Synaptic that may or may not be required to make it all work: python-rope, python-ropemacs, pyflakes.