* Detection of the audio CD and kicking stuff off is done by ivman.
* Ripping and tagging is done by abcde.
* Transcoding is done by flac2mp3.
* Refreshing the library is done using the Squeezecenter CLI.
It took me "a while" to get it working end to end. The tough part was getting ivman configured. But that's the essential part for automation.
$ sudo apt-get install ivmanwhich installs a bunch of dependencies (but no X). Then I enabled an action to start a script when ivman detects an audio CD. This is what I added to /etc/ivman/IvmConfigActions.xml:
<ivm:Match name="hal.volume.disc.type" value="cd_rom">The rip_cd script just invokes abcde and directs its output to a log file.
<ivm:Match name="hal.volume.disc.has_audio" value="true">
<ivm:Match name="hal.volume.disc.has_data" value="false">
<ivm:Option name="exec" value="/home/user_x/bin/rip_cd '$hal.block.device$'"/>
The problem that broke my heart for ages was that ivman didn't have permission to use the cdrom drive. I got this error in the log file from abcde:
cd-discid: /dev/cdrom: open: Permission deniedNo such problem running abcde directly from the command line as the same user ivman ran as, since that user is a member of the group "cdrom".
[ERROR] abcde: CD could not be read. Perhaps there's no CD in the drive?
How I eventually got it working consistently was to configure ivman to run explicitly as the group "cdrom".
Ivman requires you to specify both a user and a group for the daemon to run as - in /etc/ivman/IvmConfigBase.xml). Just because the user you specify is a member of a group, e.g. cdrom, doesn't mean that ivman will run as a member of that group.
In my setup, ivman is now solely configured from /etc/ivman and runs as "user_x" and group "cdrom". And abcde is solely configured from /etc/abcde.conf.
It can help to run ivman in debug mode:
$ sudo /etc/init.d/ivman stop
$ sudo ivman -d --nofork
$ sudo apt-get install abcdeThis also installs cd-discid and probably cdparanoia (which I had installed already). Getting abcde configured is easy, especially thanks to a great guide on Andrew's Corner.
I included a post-read hook in /etc/abcde.conf to enqueue a transcoding script when the CD is ripped.
post_read ()It would probably be better just to run the transcoding script as a cron job rather than "on demand". But this way works too.
atq -q x | while read line; do job=`echo $line | sed -e 's/\(*\).*/\1/'`; atrm $job; done
at -q x 01:00AM -f /home/user_x/bin/flac2mp3
The flac2mp3 script invokes Robin Bowes' flac2mp3, directing its output to a log file, and then invokes the Squeezecenter CLI to rescan the music library.
Of course, abcde would happily take care of ripping to FLAC and mp3 at the same time. But I prefer to rip to FLAC and transcode from there. That way, if I need to change tags, I just update the FLACs and run flac2mp3 to update the tags in my mp3s.
Squeezecenter has a telnet-based command line interface. One of the things it supports is executing a rescan of the library. So I included the scriptlet below in my transcoding script, after transcoding completes:
echo `date` "requesting squeezecenter rescan..." >> $logDirecting the output to a file was useful here (again). It helped me diagnose a problem when the "wrong" version of echo got used when the script was run from the at task, causing the telnet to fail. The fix was to use /bin/echo explicitly.
/bin/echo -e "rescan\r";
/bin/echo -e "exit\r";
) | telnet localhost 9090 >> $log 2>&1
echo `date` "telnet exit status: " $? >> $log
Of course, I could just let Squeezecenter schedule a regular rescan of the music library instead of doing it on demand. But I wanted to give the CLI a try.
Anyway, that's about it.
Just a note on hardware. I'm still using the fit-PC slim as my server. It doesn't have a CD drive. I connect the internal DVD burner from my old PC through a cheapo IDE-USB adapter cable from ebay.