#
# $Id$
-VERSION='2.3.99.8'
+VERSION='2.4.1'
usage ()
{
echo "-n No lookup. Don't query CDDB, just create and use template"
echo "-N Noninteractive. Never prompt for anything"
echo "-m Modify playlist to include CRLF endings, to comply with some players"
-echo " WARNING: Deprecated. Use \"cue\" action"
+#echo " WARNING: Deprecated. Use \"cue\" action"
#echo "-M Create a CUE file"
echo "-o <type1[,type2]...>"
echo " Output file type(s) (vorbis,mp3,flac,spx,mpc,wav,m4a). Defaults to vorbis"
echo "-x Eject CD after all tracks are read"
echo "-w <comment>"
echo " Add a comment to the CD tracks"
-echo "-W <#> Concatenate CDs: -T #01 -w \"CD #\""
+echo "-W <#> Concatenate CDs: -T #01 -w \"CD #\""
echo "-z Use debug CDROMREADERSYNTAX option (needs cdparanoia)"
echo ""
echo "Tracks is a space-delimited list of tracks to grab."
}
# log [level] [message]
-#
+#
# log outputs the right message in a common format
log ()
{
PARSECHOICE2=$(echo $CDDBDIFFCHOICE | cut -d"," -f2 | xargs printf %d 2>/dev/null)
if [ $PARSECHOICE1 -lt 1 ] || [ $PARSECHOICE1 -gt $CDDBDIFFCHOICES ] || \
[ $PARSECHOICE2 -lt 1 ] || [ $PARSECHOICE2 -gt $CDDBDIFFCHOICES ] || \
- [ $PARSECHOICE1 -eq $PARSECHOICE2 ]; then
+ [ $PARSECHOICE1 -eq $PARSECHOICE2 ]; then
echo "Invalid diff range. Please select two comma-separated numbers between 1 and $CDDBDIFFCHOICES" >&2
else
# We parse the 2 choices to diff, store them in temporary files and diff them.
TRACKNAME="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
;;
TRACK-INFO)
- grep ^EXTT$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | perl -p -e 's/\\n/\n/;'
+ grep ^EXTT$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\\n/\n/g'
;;
esac
}
do_replaygain()
{
if checkstatus replaygain; then :; else
- run_command "" echo "Adding replygain information..."
+ run_command "" echo "Adding replaygain information..."
for TMPOUTPUT in $( echo $OUTPUTTYPE | tr , \ )
do
case $TMPOUTPUT in
TRACKFILE="$(mungefilename "$TRACKNAME")"
ARTISTFILE="$(mungefilename "$TRACKARTIST")"
ALBUMFILE="$(mungefilename "$DALBUM")"
- GENRE="$(mungegenre "$GENRE")"
- YEAR=${CDYEAR:-$CDYEAR}
+ GENRE="$(mungegenre "$GENRE")"
+ YEAR=${CDYEAR:-$CDYEAR}
gettracknum
- if [ "$ONETRACK" = "y" ]; then
+ if [ "$ONETRACK" = "y" ]; then
if [ "$VARIOUSARTISTS" = "y" ]; then
OUTPUTFILE="$(eval echo \""$VAONETRACKOUTPUTFORMAT"\")"
else
done
case "$OUTPUT" in
flac)
- run_command replaygain-flac nice $ENCNICE $METAFLAC --add-replay-gain "${OUTPUTFILES[@]}"
+ run_command replaygain-flac nice $ENCNICE $METAFLAC $FLACGAINOPTS "${OUTPUTFILES[@]}"
#run_command replaygain-flac true
;;
vorbis|ogg)
- run_command replaygain-vorbis nice $ENCNICE $VORBISGAIN --album "${OUTPUTFILES[@]}"
+ run_command replaygain-vorbis nice $ENCNICE $VORBISGAIN $VORBISGAINOPTS "${OUTPUTFILES[@]}"
;;
mp3)
- run_command replaygain-mp3 nice $ENCNICE $MP3GAIN -a "${OUTPUTFILES[@]}"
+ run_command replaygain-mp3 nice $ENCNICE $MP3GAIN $MP3GAINOPTS "${OUTPUTFILES[@]}"
;;
mpc)
run_command replaygain-mpc nice $ENCNICE $MPPGAIN --auto "${OUTPUTFILES[@]}"
# do_tag [tracknumber]
# id3 tags a filename
# variables used:
-# TRACKS, TRACKNAME, TRACKARTIST, TAGGER, TAGGEROPTS, VORBISCOMMENT, METAFLAC, ATOMICPARSLEY
-# COMMENT, DALBUM, DARTIST, CDYEAR, CDGENRE (and temporarily) ID3TAGV
+# TRACKS, TRACKNAME, TRACKARTIST, TAGGER, TAGGEROPTS, VORBISCOMMENT, METAFLAC, ATOMICPARSLEY
+# COMMENT, DALBUM, DARTIST, CDYEAR, CDGENRE
do_tag ()
{
COMMENTOUTPUT="$(eval echo ${COMMENT})"
mp3)
# id3v2 v0.1.9 claims to have solved the -c bug, so we merge both id3 and id3v2
GENREID=$(do_getgenreid "${CDGENRE}")
+ # Set TPE2 in case we have a Various Artists rip.
+ TPE2=""
+ if [ "$VARIOUSARTISTS" = "y" ]; then
+ TPE2="Various"
+ fi
case "$ID3SYNTAX" in
id3);;
-G "$GENREID" -n "${TRACKNUM:-$1}" \
"${TRACKNUM:+-N $TRACKS}" \
"${ENCODING:+--set-encoding=$ENCODING}" \
+ "${TPE2:+--set-user-text-frame=TPE2:$TPE2}" \
"$ABCDETEMPDIR/track$1.$OUTPUT"
;;
# FIXME # Still not activated...
$TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \
-A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" \
-y "$CDYEAR" -g "$GENREID" \
- -T "${TRACKNUM:-$1/$TRACKS}" \
+ -T "${TRACKNUM:-$1}/$TRACKS" \
+ ${TPE2:+--TPE2 "$TPE2"} \
"$ABCDETEMPDIR/track$1.$OUTPUT"
;;
esac
;;
esac
OUT="$ABCDETEMPDIR/track$1.$OUTPUT"
- if [ "$NOGAP" = "y" ] && checkstatus encodetrack-$OUTPUT-$1 ; then
+ if [ "$NOGAP" = "y" ] && checkstatus encodetrack-$OUTPUT-$1 ; then
continue
fi
if [ X"$USEPIPES" = "Xy" ]; then
case "$2" in
%local*%)
case "$FLACENCODERSYNTAX" in
- flac) $RUN_COMMAND nice $EFFECTIVE_NICE $FLACENCODER -f $FLACENCODEROPTS -o "$OUT" "$IN" ;;
- esac
+ flac) $RUN_COMMAND nice $EFFECTIVE_NICE $FLACENCODER -f $FLACENCODEROPTS -o "$OUT" "$IN" ;;
+ esac
;;
*)
vecho -n "DISTMP3:"
fi
# Quick hack to avoid tagging Ogg/Speex, since there is no other way to tag than inline tagging
if [ ! "$DOTAG" = "y" ]; then
- $RUN_COMMAND nice $EFFECTIVE_NICE $SPEEXENCODER $SPEEXENCODEROPTS --author "$TRACKARTIST" --title "$TRACKNAME" "$COMMENT" "$IN" "$OUT"
+ $RUN_COMMAND nice $EFFECTIVE_NICE $SPEEXENCODER $SPEEXENCODEROPTS --author "$TRACKARTIST" --title "$TRACKNAME" --comment "$COMMENT" "$IN" "$OUT"
else
$RUN_COMMAND nice $EFFECTIVE_NICE $SPEEXENCODER $SPEEXENCODEROPTS "$IN" "$OUT"
fi
# esac
# done
# # Only remove .wav if the encoding succeeded
-# if checkerrors "preprocess-(.{3,4})-$1"; then
+# if checkerrors "preprocess-(.{3,4})-$1"; then
# run_command preprocess-$1 false
# else
# run_command preprocess-$1 true
# run_command postprocess-$OUTPUT-$1 nice $POSTNICE $SPX_POST $IF $OF ;;
# esac
# # Only remove .wav if the encoding succeeded
-# if checkerrors "postprocess-(.{3,4})-$1"; then
+# if checkerrors "postprocess-(.{3,4})-$1"; then
# run_command postprocess-$1 false
# else
# run_command postprocess-$1 true
gettracknum
# Supported variables for OUTPUTFORMAT are GENRE, YEAR, ALBUMFILE,
# ARTISTFILE, TRACKFILE, and TRACKNUM.
- if [ "$ONETRACK" = "y" ]; then
+ if [ "$ONETRACK" = "y" ]; then
if [ "$VARIOUSARTISTS" = "y" ]; then
OUTPUTFILE="$(eval echo \""$VAONETRACKOUTPUTFORMAT"\")"
else
OUTPUTFILE="$(eval echo \""$ONETRACKOUTPUTFORMAT"\")"
- fi
+ fi
else
if [ "$VARIOUSARTISTS" = "y" ]; then
OUTPUTFILE="$(eval echo \""$VAOUTPUTFORMAT"\")"
else
OUTPUTFILE="$(eval echo \""$OUTPUTFORMAT"\")"
fi
- fi
+ fi
if checkerrors "tagtrack-$OUTPUT-$1"; then :; else
# Once we know the specific output was successful, we can change
# the OUTPUT to the value containing the container
;;
esac
# Lets move the cue file
- if CUEFILE=$(checkstatus cuefile) >/dev/null ; then
+ if CUEFILE=$(checkstatus cuefile) >/dev/null ; then
if [ -r "$ABCDETEMPDIR/$CUEFILE" ]; then
if checkstatus movecue-$OUTPUT; then :; else
# Silence the Copying output since it overlaps with encoding processes...
;;
PREGAP) PREGAP=$(msf2lba $2)
;;
- REM) case "$2" in
+ REM) case "$2" in
FLAC__lead-out)
LEADOUT=$(( $4 / 588 ))
;;
echomsf () {
printf "$1%02i:%02i:%02i\n" $(($2/4500)) $((($2/75)%60)) $(($2%75))
- }
+ }
local MODE DISCID TRACKS
- local i OFFSET LBA
-
-
- if [ "$1" = --wholedisc ] ; then
- MODE=INDEX
- else
- MODE=PREGAP
- fi
-
- set -- $TRACKINFO
-
- DISCID=$1
- TRACKS=$2
- shift 2
-
- echo REM DISCID $DISCID
- echo FILE \"dummy.wav\" WAVE
-
- if [ $1 -ne 150 ] && [ $MODE = "PREGAP"] ; then
- OFFSET=$1
- else
- OFFSET=150
- fi
-
- i=1
- while [ $i -le "$TRACKS" ] ; do
- LBA=$(( $1 - $OFFSET ))
- printf " TRACK %02i AUDIO\n" $i
- if [ $i -eq 1 -a $1 -ne 150 ] ; then
- if [ $MODE = PREGAP ] ; then
- echomsf " PREGAP " $(($OFFSET-150))
- else
- echo " INDEX 00 00:00:00"
- fi
+ local i OFFSET LBA
+ local CUEWAVFILE
+
+ if [ "$1" = --wholedisc ] ; then
+ MODE=INDEX
+ else
+ MODE=PREGAP
+ fi
+
+ vecho "One track is $ONETRACK"
+ TRACKFILE="$(mungefilename "$TRACKNAME")"
+ ARTISTFILE="$(mungefilename "$TRACKARTIST")"
+ ALBUMFILE="$(mungefilename "$DALBUM")"
+ if [ "$ONETRACK" = "y" ]; then
+ if [ "$VARIOUSARTISTS" = "y" ]; then
+ CUEWAVFILE="$(eval echo \""$VAONETRACKOUTPUTFORMAT"\" | sed -e 's@^.*/@@').$OUTPUT"
+ else
+ CUEWAVFILE="$(eval echo \""$ONETRACKOUTPUTFORMAT"\" | sed -e 's@^.*/@@').$OUTPUT"
fi
- echomsf " INDEX 01 " $LBA
+ vecho "Cue wav file is $CUEWAVFILE"
+ else
+ CUEWAVFILE="dummy.wav"
+ fi
+
+ set -- $TRACKINFO
+
+ DISCID=$1
+ TRACKS=$2
+ shift 2
+
+ echo REM DISCID $DISCID
+ echo FILE \""$CUEWAVEFILE"\" WAVE
+
+ if [ $1 -ne 150 ] && [ $MODE = "PREGAP" ] ; then
+ OFFSET=$1
+ else
+ OFFSET=150
+ fi
+
+ i=1
+ while [ $i -le "$TRACKS" ] ; do
+ LBA=$(( $1 - $OFFSET ))
+ printf " TRACK %02i AUDIO\n" $i
+ if [ $i -eq 1 -a $1 -ne 150 ] ; then
+ if [ $MODE = PREGAP ] ; then
+ echomsf " PREGAP " $(($OFFSET-150))
+ else
+ echo " INDEX 00 00:00:00"
+ fi
+ fi
+ echomsf " INDEX 01 " $LBA
i=$(($i+1))
- shift
- done
+ shift
+ done
}
# do_discid
# CDPARANOIAAUDIOTRACKS="$TRACKS"
#
# LEADOUT="$(echo "$CDPARANOIAOUTPUT" | egrep -o '^TOTAL[[:space:]]+([[:digit:]]+)' | get_last)"
-# OFFSETS="$(echo "$CDPARANOIAOUTPUT" | sed -n -e's/^ .* \([0-9]\+\) \[.*/\1/p')"
+# OFFSETS="$(echo "$CDPARANOIAOUTPUT" | sed -n -e's/^ .* \([0-9]\+\) \[.*/\1/p')"
# makeids
# ;;
*)
vecho "Creating cue file..."
case $CDROMREADERSYNTAX in
flac)
- if $METAFLAC --export-cuesheet-to=- "$CDROM" > "$ABCDETEMPDIR/$CUEFILE"; then
+ if $METAFLAC --export-cuesheet-to=- "$CDROM" > "$ABCDETEMPDIR/$CUEFILE"; then
echo cuefile=$CUEFILE >> "$ABCDETEMPDIR/status"
else
log warning "the input flac file does not contain a cuesheet."
eval track="\$TRACK$n"
n=$(expr $n + 1)
echo " TITLE \"$track\"" >> "$CUEFILE_OUT"
+ # When making a single-track rip, put the
+ # actual file name into the file declaration
+ # in the cue file so that it is usable by
+ # music players and the like
+ elif [ "$ONETRACK" = "y" ] &&
+ echo "$line" | grep '^FILE "dummy.wav" WAVE' > /dev/null 2>&1 ; then
+
+ TRACKFILE="$(mungefilename "$TRACKNAME")"
+ ARTISTFILE="$(mungefilename "$TRACKARTIST")"
+ ALBUMFILE="$(mungefilename "$DALBUM")"
+
+ if [ "$VARIOUSARTISTS" = "y" ]; then
+ OUTPUTFILE="$(eval echo \""$VAONETRACKOUTPUTFORMAT"\" | sed -e 's@^.*/@@').$OUTPUT"
+ else
+ OUTPUTFILE="$(eval echo \""$ONETRACKOUTPUTFORMAT"\" | sed -e 's@^.*/@@').$OUTPUT"
+ fi
+
+ echo "FILE \"$OUTPUTFILE\" WAVE" >> "$CUEFILE_OUT"
+ continue
fi
# FIXME # If the lines above are uncommented, remove the line below.
echo "$line" >> "$CUEFILE_OUT"
cat "$RESULT" > "${CDDBLOCALREAD}"
{
echo -n "#$X: "
- do_cddbparse "${CDDBLOCALREAD}"
+ do_cddbparse "${CDDBLOCALREAD}"
echo ""
##FIXME## QUICK HACK !!!!
if [ ! "$INTERACTIVE" = "y" ]; then break ; fi
RESPONSECODE=$(head -n 1 "$ABCDETEMPDIR/cddbstat" | cut -f1 -d' ')
case "$RESPONSECODE" in
210) # 210 OK, status information follows (until terminating `.')
- rc=0;
+ rc=0
;;
- 501|*) # 501 Illegal CDDB protocol level: <n>.
+ 501) # 501 Illegal CDDB protocol level: <n>.
CDDBPROTO=`expr $CDDBPROTO - 1`
;;
- esac
+ *) # Try a cddb query, since freedb2.org doesn't support the stat or ver commands
+ # FreeDB TESTCD disc-id is used for query
+ $CDDBTOOL query $CDDBURL $CDDBPROTO $CDDBUSER $CDDBHOST 03015501 1 296 344 > "$ABCDETEMPDIR/cddbstat"
+ RESPONSECODE=$(head -n 1 "$ABCDETEMPDIR/cddbstat" | cut -f1 -d' ')
+ case "$RESPONSECODE" in
+ 2??) # Server responded, everything seems OK
+ rc=0
+ ;;
+ esac
+ ;;
+ esac
done
if test $rc -eq 1; then
- CDDBAVAIL="n"
+ CDDBAVAIL="n"
fi
fi
echo cddb-statcomplete >> "$ABCDETEMPDIR/status"
ERRORCODE=no_query
echo 503 > "$ABCDETEMPDIR/cddbquery"
# The default CDDBLOCALSTATUS is "notfound"
- # This part will be triggered if the user CDDB repo does not
+ # This part will be triggered if the user CDDB repo does not
# contain the entry, or if we are not trying to use the repo.
else
vecho "Querying the CDDB server..."
if [ "$(wc -l < "$ABCDETEMPDIR/cddbquery" | tr -d ' ')" -eq 3 ]; then
echo "One ${IN}exact match:" >> "$ABCDETEMPDIR/cddbchoices"
tail -n +2 "$ABCDETEMPDIR/cddbquery" | head -n 1 >> "$ABCDETEMPDIR/cddbchoices"
- echo cddb-choice=1 >> "$ABCDETEMPDIR/status"
+ echo cddb-choice=1 >> "$ABCDETEMPDIR/status"
else
echo "Multiple ${IN}exact matches:" >> "$ABCDETEMPDIR/cddbchoices"
fi
if [ -n "$CHOICE" ] ; then
case $CDDBCHOICES in
-1) if head -1 "$ABCDETEMPDIR/cddbquery" | grep "^$" > /dev/null 2>&1 ; then
- log error "CDDB query failed!"
+ log error "CDDB query failed!"
exit 1
else
cat "$ABCDETEMPDIR/cddbchoices"
PARSECHOICE2=$(echo $CDDBCHOICE | cut -d"," -f2 | xargs printf %d 2>/dev/null)
if [ $PARSECHOICE1 -lt 1 ] || [ $PARSECHOICE1 -gt $CDDBCHOICES ] || \
[ $PARSECHOICE2 -lt 1 ] || [ $PARSECHOICE2 -gt $CDDBCHOICES ] || \
- [ $PARSECHOICE1 -eq $PARSECHOICE2 ]; then
+ [ $PARSECHOICE1 -eq $PARSECHOICE2 ]; then
echo "Invalid diff range. Please select two comma-separated numbers between 1 and $CDDBCHOICES" >&2
else
# We parse the 2 choices to diff, store them in temporary files and diff them.
if [ "$USELOCALRESP" = "y" ]; then :; else
if [ -n "$CHOICE" ] ; then
case $CDDBCHOICES in
- 0)
+ 0)
UNKNOWNDISK=y
echo "Selected template."
;;
if [ "$CDDBDATAMD5SUM" != "" ] && [ "$CDDBDATAMD5SUM" != "$($MD5SUM "$CDDBDATA" | cut -d " " -f 1)" ]; then
# This works but does not have the necessary error checking
# yet. If you are familiar with the CDDB spec
- # (see http://www.freedb.org/src/latest/DBFORMAT)
+ # (see http://www.freedb.org/src/latest/DBFORMAT)
# and can create an error-free entry on your own, then put
# UNINTENTIONALLY_ANGER_THE_FREEDB_PEOPLE=y in your
# abcde.conf to enable it. Put CDDBSUBMIT=email@address in
# do_cdread [tracknumber]
# do_cdread onetrack [firsttrack] [lasttrack]
-#
+#
do_cdread ()
{
# The commands here don't go through run_command because they're never supposed to be silenced
# FIXME # Add the possibility of grabbing ranges of tracks in onetrack
# FIXME # Until then, we grab the whole CD in one track, no matter what
# the user said
- # We need the first and last track for cdda2wav
+ # We need the first and last track for cdda2wav/icedax
FIRSTTRACK=$2
LASTTRACK=$(expr $3 + 0)
UTRACKNUM=$FIRSTTRACK
case "$CDROMREADERSYNTAX" in
flac) READTRACKNUMS="$FIRSTTRACK.1-$(($LASTTRACK + 1)).0" ;;
- cdparanoia)
+ cdparanoia)
#XX FIXME XX
# Add a variable to check if tracks are provided in command line and if not, use "0-" to rip the tracks
READTRACKNUMS="$FIRSTTRACK-$LASTTRACK" ;;
- cdda2wav) READTRACKNUMS="$FIRSTTRACK+$LASTTRACK" ;;
+ cdda2wav | icedax) READTRACKNUMS="$FIRSTTRACK+$LASTTRACK" ;;
*) echo "abcde error: $CDROMREADERSYNTAX does not support ONETRACK mode"
exit 1 ;;
esac
if [ "$USEPIPES" = "y" ]; then
TEMPARG="PIPERIPPER_$CDROMREADERSYNTAX"
FILEARG="$( eval echo "\$$TEMPARG" )"
- REDIR=""
+ REDIR="y"
PIPE_MESSAGE="and encoding "
else
WAVDATA="$ABCDETEMPDIR/track$UTRACKNUM.wav"
FILEARG="$WAVDATA"
;;
esac
- REDIR=">&2"
+ REDIR="n"
fi
if [ "$1" = "onetrack" ]; then
echo "Grabbing ${PIPE_MESSAGE}tracks $UTRACKNUM - $LASTTRACK as one track ..." >&2
# Avoid problems wit math expressions by unpadding the given UTRACKNUM
STRIPTRACKNUM=$(expr $UTRACKNUM + 0)
nice $READNICE $FLAC -d -f --cue=${READTRACKNUMS:-$STRIPTRACKNUM.1-$(($STRIPTRACKNUM + 1)).0} "$FILEARG" "$CDROM" ;;
- cdparanoia)
- nice $READNICE $CDROMREADER -$CDPARANOIACDROMBUS "$CDROM" ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" $REDIR ;;
- cdda2wav)
+ cdparanoia)
+ if [ "$REDIR" = "y" ]; then
+ nice $READNICE $CDROMREADER -$CDPARANOIACDROMBUS "$CDROM" ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" >&2
+ else
+ nice $READNICE $CDROMREADER -$CDPARANOIACDROMBUS "$CDROM" ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG"
+ fi;;
+
+ cdda2wav | icedax)
if [ "$OSFLAVOUR" = "OSX" ] ; then
- # Hei, we have to unmount the device before running anything like cdda2wav in OSX
+ # Hei, we have to unmount the device before running anything like cdda2wav/icedax in OSX
disktool -u ${CDROM#/dev/} 0
- # Also, in OSX the cdrom device for cdda2wav changes...
+ # Also, in OSX the cdrom device for cdda2wav/icedax changes...
CDDA2WAVCDROM="IODVDServices"
elif [ "$OSFLAVOUR" = "FBSD" ] ; then
CDDA2WAVCDROM="$CDROMID"
CDDA2WAVCDROM="$CDROMID"
fi
fi
- nice $READNICE $CDROMREADER -D $CDDA2WAVCDROM -t ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" $REDIR
- ;;
+ if [ "$REDIR" = "y" ]; then
+ nice $READNICE $CDROMREADER -D $CDDA2WAVCDROM -t ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" >&2
+ else
+ nice $READNICE $CDROMREADER -D $CDDA2WAVCDROM -t ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG"
+ fi ;;
## FIXME ## We have an exception for dagrab, since it uses -f
## FIXME ## Shall we just use -f $FILEARG ??
- dagrab) nice $READNICE $CDROMREADER -d "$CDROM" -v $UTRACKNUM "$FILEARG" $REDIR
- ;;
+ dagrab)
+ if [ "$REDIR" = "y" ]; then
+ nice $READNICE $CDROMREADER -d "$CDROM" -v $UTRACKNUM "$FILEARG" >&2
+ else
+ nice $READNICE $CDROMREADER -d "$CDROM" -v $UTRACKNUM "$FILEARG"
+ fi ;;
cddafs)
# Find the track's mounted path
REALTRACKNUM=$(expr $UTRACKNUM + 0)
FILEPATH=$(find "$FILEPATH" | grep "/$REALTRACKNUM ");
# If the file exists, copy it
if [ -e "$FILEPATH" ] ; then
- nice $READNICE $CDROMREADER "$FILEPATH" "$FILEARG" $REDIR
+ if [ "$REDIR" = "y" ]; then
+ nice $READNICE $CDROMREADER "$FILEPATH" "$FILEARG" >&2
+ else
+ nice $READNICE $CDROMREADER "$FILEPATH" "$FILEARG"
+ fi
else
false
fi ;;
- debug) nice $READNICE $CDROMREADER -$CDPARANOIACDROMBUS "$CDROM" -w $UTRACKNUM-[:1] "$FILEARG" $REDIR
- ;;
+ debug)
+ if [ "$REDIR" = "y" ]; then
+ nice $READNICE $CDROMREADER -$CDPARANOIACDROMBUS "$CDROM" -w $UTRACKNUM-[:1] "$FILEARG" >&2
+ else
+ nice $READNICE $CDROMREADER -$CDPARANOIACDROMBUS "$CDROM" -w $UTRACKNUM-[:1] "$FILEARG"
+ fi ;;
esac
RETURN=$?
- # If we get some error or we get some missing wav
+ # If we get some error or we get some missing wav
# (as long as we dont use pipes)
if [ "$RETURN" != "0" -o \( ! -s "$WAVDATA" -a X"$USEPIPES" != "Xy" \) ]; then
# Thank goodness errors is only machine-parseable up to the
# do_cdspeed
# No values accepted, only uses env variables
-do_cdspeed ()
+do_cdspeed ()
{
if "$CDSPEED" "$CDSPEEDOPTS" "$CDSPEEDVALUE" >/dev/null ; then
vecho "Setting CD speed to ${CDSPEEDVALUE}x"
BATCHNORM=n
NOCDDBQUERY=n
-# If using scsi devices, cdda2wav needs a CDROMID, instead of a device node
+# If using scsi devices, cdda2wav/icedax needs a CDROMID, instead of a device node
# i.e. CDROMID="1,0,0"
CDROMID=""
# If we are using the IDE bus, we need CDPARANOIACDROMBUS defined as "d"
AACTAG=faac
CDPARANOIA=cdparanoia
-CDDA2WAV=cdda2wav
+CDDA2WAV=icedax
DAGRAB=dagrab
CDDAFS=cp
CDDISCID=cd-discid
L3ENCOPTS=
XINGMP3ENCOPTS=
MP3ENCOPTS=
+MP3GAINOPTS="-a -k"
# ogg
VORBIZEOPTS=
OGGENCOPTS=
+VORBISGAINOPTS="--album"
# flac
FLACOPTS=
+FLACGAINOPTS="--add-replay-gain"
# speex
SPEEXENCOPTS=
# mpc
# List of actions to perform - by default, run to completion
ACTIONS=cddb,read,encode,tag,move,clean
-# This option is basicaly for Debian package dependencies:
+# This option is basicaly for Debian package dependencies:
# List of prefered outputs - by default, run with whatever we have in the path
DEFAULT_OUTPUT_BINARIES=vorbis:oggenc,flac:flac,mp3:toolame,mp3:lame,mp3:bladeenc,spx:speex,m4a:faac
# List of prefered cdromreaders - by default, run whichever we have in the path
-DEFAULT_CDROMREADERS="cdparanoia cdda2wav"
+DEFAULT_CDROMREADERS="cdparanoia icedax cdda2wav"
# List of quality levels associated with the encoders:
DEFAULT_QUALITY_XLO="oggenc:-q -1,lame:-q 9,speex:--quality 1,m4a:"
t) STARTTRACKNUMBER="$OPTARG" ;;
T) STARTTRACKNUMBER="$OPTARG" ; STARTTRACKNUMBERTAG="y" ;;
U) CDDBPROTO=5 ;;
- v)
+ v)
echo "This is abcde v$VERSION."
echo "Usage: abcde [options] [tracks]"
echo "abcde -h for extra help"
x) EJECTCD="y" ;;
X) CUE2DISCID="$OPTARG" ;;
w) COMMENT="$OPTARG" ;;
- W) if echo $OPTARG | grep "[[:digit:]]" > /dev/null 2>&1 ; then
- STARTTRACKNUMBER="${OPTARG}01"
+ W) if echo $OPTARG | grep "[[:digit:]]" > /dev/null 2>&1 ; then
+ STARTTRACKNUMBER="${OPTARG}01"
STARTTRACKNUMBERTAG="y"
COMMENT="CD${OPTARG}"
DISCNUMBER="${OPTARG}"
else
- log error "argument of -W must be integer"
+ log error "argument of -W must be integer"
exit 1
fi
;;
fi
# Decide if we can continue.
-if [ "$ONETRACK" = "y" ]; then
+if [ "$ONETRACK" = "y" ]; then
# FIXME # remove check as soon as we find out about the other readers
case "$CDROMREADERSYNTAX" in
flac) ;;
cdparanoia) ;;
- cdda2wav) ;;
+ cdda2wav | icedax) ;;
*) log error "$CDROMREADERSYNTAX does not support ONETRACK mode"
- exit 1 ;;
+ exit 1 ;;
esac
if [ "$BATCHNORM" = "y" ]; then
log warning "BATCHNORM mode is not compatible with ONETRACK mode. Disabling..."
# Cleaned up to use shell built-ins by Charles Steinkuehler
if [ "${1#*[^0-9-]}" != "$1" ]; then
log error "syntax error while processing track numbers"
- else
+ else
RSTART=${1%%-*}
REND=${1##*-}
while [ ${RSTART:=1} -le ${REND:=0} ] ; do
TRACKQUEUE="$TRACKQUEUE $RSTART"
RSTART=$(( $RSTART + 1 ))
done
- fi
+ fi
shift
done
fi
done
# At this point a CDROM has to be defined, so we check it exists.
-if [ X"$CDROM" != "X" ] ; then
- if [ "$CDROMREADERSYNTAX" = "cdda2wav" ] && [ "$NEEDCDROMID" = "y" ] ; then
+if [ X"$CDROM" != "X" ] ; then
+ if ( [ "$CDROMREADERSYNTAX" = "cdda2wav" ] || [ "$CDROMREADERSYNTAX" = "icedax" ] ) && [ "$NEEDCDROMID" = "y" ] ; then
if [ "$OSFLAVOUR" = "FBSD" ]; then
if echo "$CDROMID" | grep "^[0-9],[0-9],[0-9]$" >/dev/null 2>&1 ; then :; else
log error "CDROMID not in the right format for $CDROMREADERSYNTAX"
fi
# BATCHNORM pre-tests, before we get into serious problems
-# Not compatible with
+# Not compatible with
if [ "$BATCHNORM" = "y" ] && [ "$DONORMALIZE" = "n" ]; then
vecho warning "Disabling BATCHNORM since we are not normalizing!"
BATCHNORM=n
CDROMREADER="$CDPARANOIA"
CDROMREADEROPTS="$CDPARANOIAOPTS"
;;
- cdda2wav)
+ cdda2wav | icedax)
CDROMREADER="$CDDA2WAV"
CDROMREADEROPTS="$CDDA2WAVOPTS"
;;
[ "$FLACENCODERSYNTAX" = "default" ] && FLACENCODERSYNTAX=flac
[ "$DOTAG" = "y" ] && NEEDMETAFLAC=y
[ "$DOREPLAYGAIN" = "y" ] && NEEDMETAFLAC=y
- [ "$ONETRACK" = "y" ] && [ "$DOCUE" = "y" ] && NEEDMETAFLAC=y
+ [ "$ONETRACK" = "y" ] && [ "$DOCUE" = "y" ] && NEEDMETAFLAC=y
;;
spx)
[ "$SPEEXENCODERSYNTAX" = "default" ] && SPEEXENCODERSYNTAX=speexenc
fi
# Don't check for stuff if it's not needed
-if [ "$REMOTEHOSTS" ]; then
+if [ "$REMOTEHOSTS" ]; then
NEEDDISTMP3=y
fi
if [ "$DONORMALIZE" = "y" ]; then
#case $CDROMREADERSYNTAX in
# flac)
# TRACKINFO=$($METAFLAC --show-tag=CDDB $CDROM | cut -d"=" -f2 | egrep "[a-f0-9]{8}")
-# if [ "$TRACKINFO" = "" ]; then
+# if [ "$TRACKINFO" = "" ]; then
# checkexec ${NEEDCUE2DISCID+$CUE2DISCID}
# fi
# ;;
fi
if checkstatus cddb-choice > /dev/null; then
:
- else
+ else
if [ "$CDDBLOCALSTATUS" = "notfound" ] ; then
case "$CDDBMETHOD" in
cddb)
if checkstatus onetrack ; then ONETRACK=y ; fi
-if [ "$ONETRACK" = "y" ]; then
+if [ "$ONETRACK" = "y" ]; then
# Reuse the CUEFILE in case we created it (now or in a previous run)
if CUEFILE=$(checkstatus cuefile); then
IMPORTCUESHEET=y
echo "encode-output=loud" >> "$ABCDETEMPDIR/status"
fi
-if [ "$ONETRACK" = "y" ]; then
+if [ "$ONETRACK" = "y" ]; then
TRACKS="$FIRSTTRACK"
if [ "$USEPIPES" = "y" ]; then
if checkstatus readencodetrack-$FIRSTTRACK; then :; else
fi
fi
if [ "$NOGAP" = "y" ] || [ "$BATCHNORM" = "y" ]; then
- :
+ :
else
# If we are not reading, set the encode output to loud already, so
# that we can see the output of the first track.
# We are now finished with the cdrom - it can be safely ejected. Note that
# abcde will not have completed yet.
if [ "$EJECTCD" = "y" ] && [ -x $(which $EJECT) ]; then
- # We check if the disk we are processing is actually the disk inside the
+ # We check if the disk we are processing is actually the disk inside the
# CD tray. If not, we do not eject the CD, since it might be so that the
# user ejected it manually.
#CURRENTTRACKINFO=$($CDDISCID $CDROM)
- #if if [ "$?" != "1" ] && [ "$CURRENTTRACKINFO" = "$TRACKINFO" ] ; then
+ #if if [ "$?" != "1" ] && [ "$CURRENTTRACKINFO" = "$TRACKINFO" ] ; then
# More FreeBSD bits.
if [ X"$(uname)" = X"FreeBSD" ] ; then
# FreeBSD eject uses the EJECT environment variable to name the CDROM
) | (
-## Do we need to pre-process
+## Do we need to pre-process
#if [ x"$PREPROCESS" = "x" ] ; then
# cat
#else
# # all locations are working, wait and try again later
# if [ ! $PREPROCEED ]; then sleep 3; fi
# done
-# ( do_preprocess $PRETRACKNUM
+# ( do_preprocess $PRETRACKNUM
# echo "NEXTTRACK"
# ) &
# done
fi
# Don't proceed with the rest of the loop if we can't encode
if [ "$ABORT" ]; then continue; fi
- ## FIXME ## Add here
+ ## FIXME ## Add here
## run_command tagtrack-$OUTPUT-$1 $METAFLAC $METAFLACOPTS ${IMPORTCUESHEET:+--import-cuesheet-from="$ABCDETEMPDIR/$CUEFILE"} --import-tags-from=- "$ABCDETEMPDIR/track$1.$FLACOUTPUTCONTAINER"
# Set TRACKNUM, TRACKNAME
if [ -e "$CDDBDATA" ]; then
- if [ "$ONETRACK" = "y" ]; then
+ if [ "$ONETRACK" = "y" ]; then
TRACKNAME="$DALBUM"
TRACKNUM="$FIRSTTRACK"
splitvarious
fi
# Lets tag the cue file
if checkstatus cleancuefile >/dev/null; then :; else
- if checkstatus cuefile >/dev/null ; then
+ if checkstatus cuefile >/dev/null ; then
do_cleancue
fi
fi