autorip
Modified on $Date: 2006/01/21 20:20:43 $
My autorip script is a modification
of Jonathan Mayer's Sourceforge
project.
autorip is a Perl script for automating the process
of ripping MP3 files from music CDs.
autorip queries CDDB/Freedb servers to locate information about
each CD (title, artist, song names, year, genre, etc.) and uses
this information to create file and directory names, and to set
the value of ID3 tags in the MP3 files.
I have used this script to
rip dozens of CDs for my SlimServer music server, with good
results.
Hint: use "screen" I have found the
"screen" utility
very handy for running autorip. "screen" allows autorip to continue
running after you log out, and captures any output from the script.
So if something seems amiss (maybe the script double-ejected a disc?),
you can re-attach to the screen process and see the last screenful
of script output.
how this differs from Jonathan's script
The biggest reason I modified this script is to deal with
different TTITLE offsets in CDDB entries. When Jonathan wrote
autorip, I guess CDDB/Freedb must have had CD entries with the
first song recorded as number "1". Now most CD entries I've come
across have the first track recorded as number "0". Jonathan's
script trips up on this badly, in my opinion -- on a 10 song CD
with CDDB data in TTITLE0 through TTITLE9, Jonathan's script will
only rip the first 9 tracks, and each will be named and tagged
with information from the next song.
Yes, I have submitted changes to Jonathan, but have not heard from him yet.
Changes from autorip 1.3:
- Many (most?) CDs are listed in the CDDB servers with track information
starting with TTITLE0 instead of TTITLE1. autorip both fails to rip the
final (Nth) track from these CDs and mis-names and mis-tags the first
(N-1) tracks from the CD. I call this an "off-by-one" mistake. My
modified autorip knows how to use CDDB info with TTITLE0 as well as info
that starts with TTITLE1. If the CDDB TTITLEn count does not match the
track count on the CD, the disc is ejected and an error displayed.
- My modified script has a "-c" option for correcting the filename and
MP3 tags of any previously ripped CD with that off-by-one problem.
[Note:due to my modified escape() routine, this probably would not work
on MP3 collections made with the old script. Adding code to make it fix
collections with old-style name escaping should not be too difficult,
though.]
- My modified script uses a different escape() routine. This is
primarily because I wanted file and directory names without spaces for
easier use in some shell scripts, but also to use a "positive filter"
(only allow known-good characters) to better protect against weird or
illegal characters from the CDDB information.
- With my DVD drive, autorip would complain about an error accessing the
CD drive and exit the "waiting for next disk" while loop. My modified
script stays in the while loop forever -- the user pretty much needs
something like Control-C to abort the script.
- My modified script adds the "$tracknum: $discid" comment tag.
- My modified script tries to "double eject" the CD (open drawer, close
drawer, then eject again) when there's a problem with the CD that it
can't handle (can't find information, track miscount, etc.). When using
the script on a headless system (say, a media server), this double-eject
helps inform the user that something was wrong. My script also tries to
use the system bell to indicate and differentiate errors (different
numbers of bell tones for different errors).
- My modified script stores the CDDB information it retrieved about a
disk (*all* lines, including song offset comments, etc.) in a dot file
(.cddb-data) inside the album directory it makes -- to facilitate any
future processing.
- My modified script tries to pull the year and genre information from
the CDDB listing.
- My modified script has a "-r" option to indicate that even if it seems
that a CD has been ripped correctly (has the right number of tracks),
autorip should retag the MP3 files (to add year, genre, and track:discid
comment, for instance).
- My modified script has a "-f" option to indicate that all CDs should
be re-ripped (and their old directories, if any, replaced).
- My modified script tries to be more safe with system() type calls,
e.g. using system() with more than one argument to prevent
metacharacter expansion (http://perldoc.perl.org/functions/system.html).
- My modified script makes an working directory inside $tmpdir for its
use -- so the script is safe to use with $tmpdir set to '/tmp' on
multi-user systems (race conditions, etc.). It will remove this
directory, but no longer uses rmdir's "-P" option to attempt removal of
parent directories.
- My modified script (as of version 1.4, 2006/01/21) knows how to
reassemble CDDB data that spans two lines (song titles,
long album titles, etc.).
Return to peterw's main page