echo " Specify CDROM device to grab"
echo "-D Debugging mode (equivalent to sh -x abcde)"
echo "-e Erase encoded track information from status file"
+#echo "-E Set the encoding information for the tags"
echo "-h This help information"
#echo "-i Tag files while encoding, when possible (local only) -NWY-"
echo "-j <#> Number of encoder processes to run at once (localhost)"
echo $TO
}
+# do_getcddbinfo
+# Finds an specific field from cddbinfo
+#
+# TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2 -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')
+# TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2 -d= | tr -d \[:cntrl:\])
+# TRACKNAME="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
+
+do_getcddbinfo ()
+{
+ case $1 in
+ TRACKNAME1)
+ TRACKNAME="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
+ ;;
+ TRACKNAME)
+ TRACKNAME="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
+ ;;
+ esac
+}
+
+# do_gettracknum
+# Get the track number we are going to use for different actions
+do_gettracknum
+{
+ if [ -n "$STARTTRACKNUMBER" ] ; then
+ # Get the trackpadding from the current track
+ CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c)
+ TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
+ else
+ TRACKNUM=${UTRACKNUM}
+ fi
+}
+
+do_replaygain
+{
+ run-command "" echo "Adding reply-gain information..."
+ for OUTPUT in $( echo $OUTPUTTYPE | tr , \ )
+ do
+ OUTPUTFILES=""
+ for UTRACKNUM in $TRACKQUEUE
+ do
+ CDDBTRACKNUM=$(expr $UTRACKNUM - 1)
+ do_getcddbinfo TRACKNAME
+ splitvarious
+ TRACKFILE=$(mungefilename "$TRACKNAME")
+ ARTISTFILE=$(mungefilename "$TRACKARTIST")
+ ALBUMFILE=$(mungefilename "$DALBUM")
+ do_gettrucknum
+ if [ "$VARIOUSARTISTS" = "y" ]; then
+ OUTPUTFILE=$(eval echo $VAOUTPUTFORMAT)
+ else
+ OUTPUTFILE=$(eval echo $OUTPUTFORMAT)
+ fi
+ OUTPUTFILES="$OUTPUTDIR/$OUTPUTFILE.$OUTPUT $OUTPUTFILES"
+ done
+ case "$OUTPUT" in
+ flac);;
+ ogg);;
+ *);;
+ esac
+ echo vorbisgain-$OUTPUT >> "$ABCDETEMPDIR/status"
+ done
+ echo vorbisgain >> "$ABCDETEMPDIR/status"
+}
+
# This code splits the a Various Artist track name from one of the following
# forms:
#
TRACKNAME=$(echo "$DTITLEARTIST" | cut -f1 -d~)
;;
esac
- elif [ "$ONETRACK" = "y" ]; then
+ elif [ "$VARIOUSARTISTS" = "y" ] && [ "$ONETRACK" = "y" ]; then
TRACKARTIST="Various"
else
TRACKARTIST="$DARTIST"
"gangsta") id=59 ;;
"top 40") id=60 ;;
"christian rap") id=61 ;;
- "pop/funk") id=62 ;;
+ "pop/funk"|"pop / funk") id=62 ;;
"jungle") id=63 ;;
"native american") id=64 ;;
"cabaret") id=65 ;;
"anime") id=145 ;;
"jpop") id=146 ;;
"synthpop") id=147 ;;
+ "rock/pop"|"rock / pop") id=148 ;;
*) return 1 ;;
esac
echo ${id}
run_command '' echo "Tagging track $1 of $TRACKS: $TRACKNAME..."
# If we want to start the tracks with a given number, we need to modify the
# TRACKNUM value before evaluation
- if [ -n "$STARTTRACKNUMBER" -a -n "$STARTTRACKNUMBERTAG" ] ; then
- # Get the trackpadding from the current track
- CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c)
- TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
+# if [ -n "$STARTTRACKNUMBER" -a -n "$STARTTRACKNUMBERTAG" ] ; then
+# # Get the trackpadding from the current track
+# CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c)
+# TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
+# fi
+ if [ -n "$STARTTRACKNUMBERTAG" ] ; then
+ do_gettracknum
fi
for OUTPUT in $(echo $OUTPUTTYPE | tr , \ )
do
# id3v2 v0.1.9 claims to have solved the -c bug, so we merge both id3 and id3v2
GENREID=$(do_getgenreid "${CDGENRE}")
- # FIXME # track numbers in mp3 come with 1/10, so we cannot happily substitute them with $TRACKNUM
- run_command tagtrack-$1 $TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \
- -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" -y "$CDYEAR" \
- -g "$GENREID" -T "${TRACKNUM:-$1/$TRACKS}" \
- "$ABCDETEMPDIR/track$1.$OUTPUT"
+ case "$ID3SYNTAX" in
+ id3);;
+ eyed3)
+ # FIXME # track numbers in mp3 come with 1/10, so we cannot happily substitute them with $TRACKNUM
+ run_command tagtrack-$1 $TAGGER $TAGGEROPTS --commen=::"$COMMENTOUTPUT" \
+ -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" -Y "$CDYEAR" \
+ -G "$GENREID" -n "${TRACKNUM:-$1}" "${TRACKNUM:+-N $TRACKS}" \
+ "${ENCODING:+--set-encoding=$ENCODING}"
+ "$ABCDETEMPDIR/track$1.$OUTPUT"
+ ;;
+ *)
+ # FIXME # track numbers in mp3 come with 1/10, so we cannot happily substitute them with $TRACKNUM
+ run_command tagtrack-$1 $TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \
+ -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" -y "$CDYEAR" \
+ -g "$GENREID" -T "${TRACKNUM:-$1/$TRACKS}" \
+ "$ABCDETEMPDIR/track$1.$OUTPUT"
+ ;;
+ esac
;;
vorbis|ogg)
case "$OGGENCODERSYNTAX" in
do
TRACKFILES="$TRACKFILES track$UTRACKNUM.wav"
done
- nice $ENCNICE $MP3ENCODER $MP3ENCODEROPTS --nogap $TRACKFILES
+ nice $ENCNICE $MP3ENCODER $MP3ENCODEROPTS `[ "$MP3ENCODER" = "lame" ] && echo "--nogap"` $TRACKFILES
RETURN=$?
if [ "$RETURN" != "0" ]; then
echo "batch-encode: $ENCODER returned code $RETURN" >> errors
TEMPARG="PIPE_$MPPENCODER"
;;
esac
- IN=${!TEMPARG}
+ IN="$( eval echo "\$$TEMPARG" )"
else
IN="$ABCDETEMPDIR/track$1.wav"
case "$OUTPUT" in
YEAR=$(echo $CDYEAR)
# If we want to start the tracks with a given number, we need to modify the
# TRACKNUM value before evaluation
- if [ -n "$STARTTRACKNUMBER" ] ; then
- # Get the trackpadding from the current track
- CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c)
- TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
- else
- TRACKNUM=${UTRACKNUM}
- fi
+ # if [ -n "$STARTTRACKNUMBER" ] ; then
+ # # Get the trackpadding from the current track
+ # CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c)
+ # TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
+ # else
+ # TRACKNUM=${UTRACKNUM}
+ # fi
+ do_gettracknum
# Supported variables for OUTPUTFORMAT are GENRE, ALBUMFILE, ARTISTFILE,
# TRACKFILE, and TRACKNUM.
if [ "$VARIOUSARTISTS" = "y" ]; then
do
# Shares some code with do_move since the filenames have to match
CDDBTRACKNUM=$(expr $UTRACKNUM - 1)
- TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2 -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')
+ #TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2 -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')
+ do_getcddbinfo TRACKNAME
splitvarious
TRACKFILE=$(mungefilename "$TRACKNAME")
ARTISTFILE=$(mungefilename "$TRACKARTIST")
+ ALBUMFILE=$(mungefilename "$DALBUM")
# If we want to start the tracks with a given number, we need to modify the
# TRACKNUM value before evaluation
- if [ -n "$STARTTRACKNUMBER" ] ; then
- # Get the trackpadding from the current track
- CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c)
- TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
- else
- TRACKNUM=${UTRACKNUM}
- fi
+ # if [ -n "$STARTTRACKNUMBER" ] ; then
+ # # Get the trackpadding from the current track
+ # CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c)
+ # TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
+ # else
+ # TRACKNUM=${UTRACKNUM}
+ # fi
+ do_gettrucknum
if [ "$VARIOUSARTISTS" = "y" ]; then
OUTPUTFILE=$(eval echo $VAOUTPUTFORMAT)
else
echo "variousartiststyle=$VARIOUSARTISTSTYLE" >> "$ABCDETEMPDIR/status"
if [ "$EDITCDDB" = "y" ] && [ "$UNINTENTIONALLY_ANGER_THE_FREEDB_PEOPLE" = "y" ]; then
- if [ $CDDBDATAMD5SUM != "" ] && [ $CDDBDATAMD5SUM != $($MD5SUM "$CDDBDATA" | cut -d " " -f 1) ]; then
+ 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)
CDDBTRACKNUM=$(expr $UTRACKNUM - 1)
if [ "$USEPIPES" = "y" ]; then
TEMPARG="PIPE_$CDROMREADERSYNTAX"
- FILEARG="${!TEMPARG}"
+ FILEARG="$( eval echo "\$$TEMPARG" )"
REDIR=""
PIPE_MESSAGE="and encoding "
else
echo "Grabbing ${PIPE_MESSAGE}tracks $UTRACKNUM - $LASTTRACK as one track ..." >&2
else
if [ -r "$CDDBDATA" ]; then
- TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2 -d= | tr -d \[:cntrl:\])
+ #TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2 -d= | tr -d \[:cntrl:\])
+ do_getcddbinfo TRACKNAME
echo "Grabbing ${PIPE_MESSAGE}track $UTRACKNUM: $TRACKNAME..." >&2
else
echo "Grabbing ${PIPE_MESSAGE}track $UTRACKNUM..." >&2
ID3=id3
ID3V2=id3v2
+EYED3=eyeD3
CDPARANOIA=cdparanoia
CDDA2WAV=cdda2wav
DAGRAB=dagrab
# Let's use these checkings to determine the OS flavour, which will be used later
if [ X$(uname) = "XFreeBSD" ] ; then
HTTPGET=fetch
+ MD5SUM=md5
NEEDCDROMID=y
OSFLAVOUR=FBSD
elif [ X$(uname) = "XDarwin" ] ; then
elif [ X$(uname) = "XOpenBSD" ] ; then
HTTPGET=wget
MD5SUM=md5
+elif [ X$(uname) = "XNetBSD" ] ; then
+ HTTPGET=ftp
+ MD5SUM=md5
else
HTTPGET=wget
fi
wget) HTTPGETOPTS="-q -O -";;
curl) HTTPGETOPTS="-f -s";;
fetch)HTTPGETOPTS="-q -o -";;
+ ftp) HTTPGETOPTS="-q -o -";;
*) echo "abcde warning: HTTPGET in non-standard and HTTPGETOPTS are not defined." >&2 ;;
esac
fi
case "$opt" in
1) ONETRACK=y ;;
a) ACTIONS="$OPTARG" ;;
- A) EXPACTIONS="$OPTARG";;
+ A) EXPACTIONS="$OPTARG" ;;
b) BATCH=y ;;
c) if [ -e "$OPTARG" ] ; then . "$OPTARG" ; else echo "abcde error: config file \"$OPTARG\" cannot be found." >&2 ; exit 1 ; fi ;;
C) DISCID="${OPTARG#abcde.}" ;;
e) ERASEENCODEDSTATUS=y ;;
h) usage; exit ;;
e) ERASEENCODEDSTATUS=y ;;
+ E) ENCODING="$OPTARG" ;;
# f) FORCECDDBUSELOCAL=y ;;
i) INLINETAG=y ;;
j) MAXPROCS="$OPTARG" ;;
mpc)
PIPEENCODERSVARCHECK="PIPE_$MPPENCODER" ;;
esac
- if [ ! -n "${!PIPERIPPERSVARCHECK}" ] ; then
+ if [ ! -n "$( eval echo "\$$PIPERIPPERSVARCHECK" )" ] ; then
echo "abcde error: no support for pipes with given ripper" >&2
echo "read the USEPIPES file from the source tarball to help" >&2
echo "on a Debian system, read /usr/share/doc/abcde/USEPIPES.gz" >&2
exit 1;
fi
- if [ ! -n "${!PIPEENCODERSVARCHECK}" ] ; then
+ if [ ! -n "$( eval echo "\$$PIPEENCODERSVARCHECK" )" ] ; then
echo "abcde error: no support for pipes with given encoder" >&2
echo "read the USEPIPES file from the source tarball to help" >&2
echo "on a Debian system, read /usr/share/doc/abcde/USEPIPES.gz" >&2
# TRACKNUM=$(printf %0.${TRACKNUMPADDING}d $(expr ${UTRACKNUM} + 0))
TRACKNUM=$UTRACKNUM
CDDBTRACKNUM=$(expr $UTRACKNUM - 1)
- TRACKNAME="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
+ #TRACKNAME="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
+ do_getcddbinfo TRACKNAME
splitvarious
fi
fi
fi
# If the above didn't catch the stragglers, this will
wait
+if checkstatus replaygain; then :; else
+ do_replaygain
+fi
# Check to see if run_command logged any errors
if [ -f "$ABCDETEMPDIR/errors" ]; then
echo "The following commands failed to run:"