␊ |
set -e␊ |
␊ |
CDDA2WAV=icedax␊ |
LAME=lame␊ |
OGGENC=oggenc␊ |
EDITORS="emacs vim gedit kate"␊ |
␊ |
tmp=␊ |
␊ |
function _exit()␊ |
|
␉ ;;␊ |
␉mp3)␊ |
␉ encode_mp3=1␊ |
␉ which lame > /dev/null␊ |
␉ if [ ! $? ] ; then␊ |
␉␉echo "lame not found, cannot continue"␊ |
␉ if [ "`which $LAME`" == "" ] ; then␊ |
␉␉echo "$LAME not found, cannot continue"␊ |
␉␉exit 1␊ |
␉ fi␊ |
␉ ;;␊ |
␉ogg)␊ |
␉ encode_ogg=1␊ |
␉ which oggenc > /dev/null␊ |
␉ if [ ! $? ] ; then␊ |
␉␉echo "oggenc not found, cannot continue"␊ |
␉ if [ "`which $OGGENC`" == "" ] ; then␊ |
␉␉echo "$OGGENC not found, cannot continue"␊ |
␉␉exit 1␊ |
␉ fi␊ |
␉ ;;␊ |
|
fi␊ |
␊ |
if [ $resume = 0 ] ; then␊ |
which cdda2wav > /dev/null␊ |
if [ ! $? ] ; then␊ |
␉echo "cdda2wav not found, cannot continue"␊ |
if [ "`which $CDDA2WAV`" == "" ] ; then␊ |
␉echo "$CDDA2WAV not found, cannot continue"␊ |
␉exit 1␊ |
fi␊ |
␊ |
|
␊ |
if [ $retrieve_infos = 0 ] ; then␊ |
if [ ! -f "$audio_cddb" ] ; then␊ |
␉echo "$audio_cddb not found"␊ |
␉exit␊ |
␉echo "$audio_cddb not found"␊ |
␉exit␊ |
fi␊ |
cat "$audio_cddb"␊ |
echo ␊ |
|
echo -n "> "␊ |
read response␊ |
if [ "$response" = "c" -o "$response" = "copy" ] ; then␊ |
␉echo /bin/cp audio.cddb /tmp␊ |
␉/bin/cp audio.cddb /tmp␊ |
␉exit␊ |
␉echo /bin/cp audio.cddb /tmp␊ |
␉/bin/cp "$audio_cddb" /tmp␊ |
␉exit␊ |
fi␊ |
[ ! -z "$response" -a $response != "y" -a $response = "yes" ] && exit␊ |
else␊ |
if [ $auto = 1 ] ; then␊ |
␉ cdda2wav -D "$dev" -L 1 -J -v title␉␊ |
␉ $CDDA2WAV -D "$dev" -L 1 -J -v title␉␊ |
else␉␊ |
# Info query␊ |
␉while [ 1 ] ; do␊ |
␉ cdda2wav -D "$dev" -L 0 -J -v title␊ |
␉ if [ "$response" = "e" -o "$response" = "edit" ] ; then␊ |
␉ ␉cat "$audio_cddb"␊ |
␉ else␊ |
␉ ␉$CDDA2WAV -D "$dev" -L 0 -J -v title␊ |
␉ fi␊ |
␉ echo ␊ |
␉ echo "Is this correct ? (y[es], n[o], e[xit], c[opy])"␊ |
␉ echo "Is this correct ? (y[es], n[o], q[uit], c[opy], e[dit])"␊ |
␉ echo -n "> "␊ |
␉ read response␊ |
␉ if [ "$response" = "c" -o "$response" = "copy" ] ; then␊ |
␉␉echo /bin/cp audio.cddb /tmp␊ |
␉␉/bin/cp audio.cddb /tmp␊ |
␉␉exit␊ |
␉ ␉echo /bin/cp audio.cddb /tmp␊ |
␉ ␉/bin/cp "$audio_cddb" /tmp␊ |
␉ ␉exit␊ |
␉ fi␊ |
␉ if [ "$response" = "e" -o "$response" = "edit" ] ; then␊ |
␉ ␉for editor in $EDITORS ; do␊ |
␉ ␉ if [ "`which $editor`" != "" ] ; then␊ |
␉ ␉␉$editor "$audio_cddb"␊ |
␉ ␉␉break␊ |
␉ ␉ fi␊ |
␉ ␉done␊ |
␉ fi␊ |
␉ [ -z "$response" -o "$response" = "y" -o "$response" = "yes" ] && break␊ |
␉ [ "$response" = "e" -o "$response" = "exit" ] && exit␊ |
␉ [ "$response" = "q" -o "$response" = "quit" ] && exit␊ |
␉done␊ |
fi␊ |
fi␊ |
|
fi␊ |
␊ |
# Suppress spaces␊ |
band=$(echo $band)␊ |
album=$(echo $album)␊ |
genre=$(echo $genre)␊ |
year=$(echo $year)␊ |
band=$(echo $band | sed "s;/;-;g")␊ |
album=$(echo $album | sed "s;/;-;g")␊ |
genre=$(echo $genre | sed "s;/;-;g")␊ |
year=$(echo $year | sed "s;/;-;g")␊ |
␊ |
if [ $resume = 0 ] ; then␊ |
# Extract wav␊ |
|
␉tracknum=$((tracknum + 1))␊ |
done;␊ |
␊ |
cdda2wav -B -D $dev $tracks␊ |
$CDDA2WAV -B -D $dev $tracks␊ |
fi␊ |
␊ |
# Convert into mp3␊ |
|
␊ |
[ -z "$title" ] && title="Audio Track $prefix"␊ |
␊ |
title=$(echo $title | sed "s;/;-;g")␊ |
␊ |
filename=$pattern␊ |
␊ |
filename=$(echo $filename | sed "s/%g/$genre/g")␊ |
|
␊ |
if [ $encode_mp3 = 1 ] ; then␊ |
␉if [ ! -f "$new_file.mp3" -o $overwrite = 1 ] ; then␊ |
␉ lame -b $bitrate -h --tt "$title" --ta "$band" --tl "$album" --ty "$year" --tn $i --tg "$genre" --add-id3v2 $track_wav "$new_file.mp3"␊ |
␉ $LAME -b $bitrate -h --tt "$title" --ta "$band" --tl "$album" --ty "$year" --tn $i --tg "$genre" --add-id3v2 $track_wav "$new_file.mp3"␊ |
␉else␊ |
␉ echo "$new_file.mp3 already exists, skipping"␊ |
␉fi␊ |
|
␊ |
if [ $encode_ogg = 1 ] ; then␊ |
␉if [ ! -f "$new_file.ogg" -o $overwrite = 1 ] ; then␊ |
␉ oggenc -b $bitrate -q 10 -t "$title" -a "$band" --album "$album" -d "$year" -N $i -G "$genre" $track_wav -o "$new_file.mp3"␊ |
␉ $OGGENC -b $bitrate -q 10 -t "$title" -a "$band" --album "$album" -d "$year" -N $i -G "$genre" $track_wav -o "$new_file.mp3"␊ |
␉else␊ |
␉ echo "$new_file.ogg already exists, skipping"␊ |
␉fi␊ |
|
fi␊ |
done␊ |
␊ |
echo "CD extracted into $dest"␊ |
echo "CD extracted into $dest/$dir"␊ |
exit␊ |