Some improvments

This commit is contained in:
Grégory Soutadé 2010-12-18 21:37:21 +01:00
parent 673853e531
commit 34a6444a75

View File

@ -18,6 +18,11 @@
set -e set -e
CDDA2WAV=icedax
LAME=lame
OGGENC=oggenc
EDITORS="emacs vim gedit kate"
tmp= tmp=
function _exit() function _exit()
@ -156,17 +161,15 @@ while getopts ":ab:d:D:ef:hkop:r:-:" arg ; do
;; ;;
mp3) mp3)
encode_mp3=1 encode_mp3=1
which lame > /dev/null if [ "`which $LAME`" == "" ] ; then
if [ ! $? ] ; then echo "$LAME not found, cannot continue"
echo "lame not found, cannot continue"
exit 1 exit 1
fi fi
;; ;;
ogg) ogg)
encode_ogg=1 encode_ogg=1
which oggenc > /dev/null if [ "`which $OGGENC`" == "" ] ; then
if [ ! $? ] ; then echo "$OGGENC not found, cannot continue"
echo "oggenc not found, cannot continue"
exit 1 exit 1
fi fi
;; ;;
@ -187,9 +190,8 @@ if [ $keep_wav = 0 -a $encode_mp3 = 0 -a $encode_ogg = 0 ] ; then
fi fi
if [ $resume = 0 ] ; then if [ $resume = 0 ] ; then
which cdda2wav > /dev/null if [ "`which $CDDA2WAV`" == "" ] ; then
if [ ! $? ] ; then echo "$CDDA2WAV not found, cannot continue"
echo "cdda2wav not found, cannot continue"
exit 1 exit 1
fi fi
@ -211,28 +213,40 @@ if [ $retrieve_infos = 0 ] ; then
read response read response
if [ "$response" = "c" -o "$response" = "copy" ] ; then if [ "$response" = "c" -o "$response" = "copy" ] ; then
echo /bin/cp audio.cddb /tmp echo /bin/cp audio.cddb /tmp
/bin/cp audio.cddb /tmp /bin/cp "$audio_cddb" /tmp
exit exit
fi fi
[ ! -z "$response" -a $response != "y" -a $response = "yes" ] && exit [ ! -z "$response" -a $response != "y" -a $response = "yes" ] && exit
else else
if [ $auto = 1 ] ; then if [ $auto = 1 ] ; then
cdda2wav -D "$dev" -L 1 -J -v title $CDDA2WAV -D "$dev" -L 1 -J -v title
else else
# Info query # Info query
while [ 1 ] ; do 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
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 "> " echo -n "> "
read response read response
if [ "$response" = "c" -o "$response" = "copy" ] ; then if [ "$response" = "c" -o "$response" = "copy" ] ; then
echo /bin/cp audio.cddb /tmp echo /bin/cp audio.cddb /tmp
/bin/cp audio.cddb /tmp /bin/cp "$audio_cddb" /tmp
exit exit
fi 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 [ -z "$response" -o "$response" = "y" -o "$response" = "yes" ] && break
[ "$response" = "e" -o "$response" = "exit" ] && exit [ "$response" = "q" -o "$response" = "quit" ] && exit
done done
fi fi
fi fi
@ -257,10 +271,10 @@ else
fi fi
# Suppress spaces # Suppress spaces
band=$(echo $band) band=$(echo $band | sed "s;/;-;g")
album=$(echo $album) album=$(echo $album | sed "s;/;-;g")
genre=$(echo $genre) genre=$(echo $genre | sed "s;/;-;g")
year=$(echo $year) year=$(echo $year | sed "s;/;-;g")
if [ $resume = 0 ] ; then if [ $resume = 0 ] ; then
# Extract wav # Extract wav
@ -279,7 +293,7 @@ if [ $resume = 0 ] ; then
tracknum=$((tracknum + 1)) tracknum=$((tracknum + 1))
done; done;
cdda2wav -B -D $dev $tracks $CDDA2WAV -B -D $dev $tracks
fi fi
# Convert into mp3 # Convert into mp3
@ -310,6 +324,8 @@ for track_wav in *.wav ; do
[ -z "$title" ] && title="Audio Track $prefix" [ -z "$title" ] && title="Audio Track $prefix"
title=$(echo $title | sed "s;/;-;g")
filename=$pattern filename=$pattern
filename=$(echo $filename | sed "s/%g/$genre/g") filename=$(echo $filename | sed "s/%g/$genre/g")
@ -323,7 +339,7 @@ for track_wav in *.wav ; do
if [ $encode_mp3 = 1 ] ; then if [ $encode_mp3 = 1 ] ; then
if [ ! -f "$new_file.mp3" -o $overwrite = 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 else
echo "$new_file.mp3 already exists, skipping" echo "$new_file.mp3 already exists, skipping"
fi fi
@ -331,7 +347,7 @@ for track_wav in *.wav ; do
if [ $encode_ogg = 1 ] ; then if [ $encode_ogg = 1 ] ; then
if [ ! -f "$new_file.ogg" -o $overwrite = 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 else
echo "$new_file.ogg already exists, skipping" echo "$new_file.ogg already exists, skipping"
fi fi
@ -349,5 +365,5 @@ for track_wav in *.wav ; do
fi fi
done done
echo "CD extracted into $dest" echo "CD extracted into $dest/$dir"
exit exit