# Copyright for this work is to expire January 1, 2010, after which it
# shall be public domain.
-VERSION="2.3.99-$Id $"
+VERSION="2.3.99"
usage ()
{
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 "-f Force operations that otherwise are considered harmful. Read \"man abcde\""
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 "-m Modify playlist to include CRLF endings, to comply with some players"
echo "-M Create a CUE file"
echo "-o <type1[,type2]...>"
-echo " Output file type(s) (vorbis,mp3,flac,spx,mpc). Defaults to vorbis"
+echo " Output file type(s) (vorbis,mp3,flac,spx,mpc,wav). Defaults to vorbis"
echo "-p Pad track numbers with 0's (if less than 10 tracks)"
echo "-P Use UNIX pipes to read+encode without wav files"
echo "-r <host1[,host2]...>"
echo "-w <comment>"
echo " Add a comment to the CD tracks"
echo "-W <#> Contatenate 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."
echo "Ranges specified with hyphens are allowed (i.e., 1-5)."
fi
}
+# chechwarnings [blurb]
+# Returns "0" if the blurb was found (meaning there was an warning),
+# returns 1 if it wasn't (yes this is a little backwards).
+# Does not print the blurb on stdout.
+# Otherwise, returns "".
+checkwarnings ()
+{
+ if [ -e "$ABCDETEMPDIR/warnings" ]; then :; else
+ return 1
+ fi
+ # Take the last line in the status file if there's multiple matches
+ PATTERN="^$1(:.*)?$"
+ BLURB="$(egrep $PATTERN "$ABCDETEMPDIR/warnings" | tail -n 1)"
+
+ if [ -z "$BLURB" ]; then
+ # negative, we did not have a negative...
+ return 1
+ else
+ # affirmative, we had a negative...
+ return 0
+ fi
+}
+
# checkerrors [blurb]
# Returns "0" if the blurb was found (meaning there was an error),
# returns 1 if it wasn't (yes this is a little backwards).
do_tag ()
{
COMMENTOUTPUT="$(eval echo ${COMMENT})"
+ CDDBDISCID=$(echo $TRACKINFO | cut -d' ' -f1)
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 ))
-# fi
if [ -n "$STARTTRACKNUMBERTAG" ] ; then
do_gettracknum
fi
mpc)
run_command tagtrack-$OUTPUT-$1 true
;;
+ wav)
+ run_command tagtrack-$OUTPUT-$1 true
+ ;;
esac
done
if checkerrors "tagtrack-(.{3,6})-$1"; then :; else
mp3)
case "$MP3ENCODERSYNTAX" in
# FIXME # check if mp3enc needs -if for pipes
+ # FIXME # I have not been able to find a working mp3enc binary
mp3enc)
FILEARG="-if $IN"
;;
## FIXME ## to the encoder ends up empty.
$RUN_COMMAND nice $ENCNICE $MPPENCODER $MPPENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" "$IN" "$OUT"
;;
+ wav)
+ # In case of wav output we need nothing. Just keep the wavs.
+ run_command encodetrack-$OUTPUT-$1 true
+ ;;
esac
done
# Only remove .wav if the encoding succeeded
if checkerrors "encodetrack-(.{3,6})-$1"; then :; else
run_command encodetrack-$1 true
if [ ! "$KEEPWAVS" = "y" ] ; then
- rm -f "$IN"
+ if [ ! "$KEEPWAVS" = "move" ] ; then
+ rm -f "$IN"
+ fi
fi
fi
else
do
MP3FILES="$TRACKFILES track$UTRACKNUM.mp3"
done
- # XXX: Hard-coded batch option!
+ # FIXME # Hard-coded batch option!
$NORMALIZER -b $NORMALIZEROPTS $TRACKFILES
RETURN=$?
if [ "$RETURN" != "0" ]; then
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
do_gettracknum
# Supported variables for OUTPUTFORMAT are GENRE, ALBUMFILE, ARTISTFILE,
# TRACKFILE, and TRACKNUM.
esac
# Check that the directory for OUTPUTFILE exists, if it doesn't, create it
OUTPUTFILEDIR="$(dirname "$OUTPUTDIR/$OUTPUTFILE")"
- # mkdir -p shouldn't return an error if the directory already exists
- mkdir -p "$OUTPUTFILEDIR"
- run_command movetrack-$1 mv "$ABCDETEMPDIR/track$1.$OUTPUT" "$OUTPUTDIR/$OUTPUTFILE.$OUTPUT"
+ case $OUTPUT in
+ wav)
+ if [ "$DOCLEAN" != "y" ] && [ "$FORCE" != "y" ]; then
+ # FIXME # introduce warnings?
+ :
+ else
+ # mkdir -p shouldn't return an error if the directory already exists
+ mkdir -p "$OUTPUTFILEDIR"
+ run_command movetrack-$1 mv "$ABCDETEMPDIR/track$1.$OUTPUT" "$OUTPUTDIR/$OUTPUTFILE.$OUTPUT"
+ if checkstatus movetrack-output-$OUTPUT; then :; else
+ run_command movetrack-output-$OUTPUT true
+ fi
+ fi
+ ;;
+ *)
+ # mkdir -p shouldn't return an error if the directory already exists
+ mkdir -p "$OUTPUTFILEDIR"
+ run_command movetrack-$1 mv "$ABCDETEMPDIR/track$1.$OUTPUT" "$OUTPUTDIR/$OUTPUTFILE.$OUTPUT"
+ if checkstatus movetrack-output-$OUTPUT; then :; else
+ run_command movetrack-output-$OUTPUT true
+ fi
+ ;;
+ esac
# Lets move the cue file
if CUEFILE=$(checkstatus cuefile) >/dev/null ; then
if [ -r "$ABCDETEMPDIR/$CUEFILE" ]; then
#run_command '' vecho "Copying cue file to its destination directory..."
if checkstatus onetrack >/dev/null ; then
case $OUTPUT in
+ wav)
+ if [ "$DOCLEAN" != "y" ] && [ "$FORCE" != "y" ]; then
+ # We dont have the dir, since it was not created before.
+ :
+ else
+ run_command movecue-$OUTPUT cp "$ABCDETEMPDIR/$CUEFILE" "$OUTPUTDIR/$OUTPUTFILE.cue"
+ fi
+ ;;
# NOTE: Creating a cue file with the 3-char-extension files is to comply with
# http://brianvictor.tripod.com/mp3cue.htm#details
[a-z0-9][a-z0-9][a-z0-9])
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
do_gettracknum
if [ "$VARIOUSARTISTS" = "y" ]; then
OUTPUTFILE=$(eval echo $VAOUTPUTFORMAT)
# Create a proper CUE file based on the CUE file we created before.
do_cleancue()
{
- # FIXME # we can get the name of the cuefile from the status file
if CUEFILE_IN="$ABCDETEMPDIR"/$(checkstatus cuefile); then
CUEFILE_OUT=$CUEFILE_IN.out
### FIXME ### checkstatus cddb
# Parse command line options
#while getopts 1a:A:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do
-while getopts 1a:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W:z opt ; do
+while getopts 1a:bc:C:d:Defhj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W:z opt ; do
case "$opt" in
1) ONETRACK=y ;;
a) ACTIONS="$OPTARG" ;;
h) usage; exit ;;
e) ERASEENCODEDSTATUS=y ;;
E) ENCODING="$OPTARG" ;;
-# f) FORCECDDBUSELOCAL=y ;;
+ f) FORCE=y ;;
i) INLINETAG=y ;;
j) MAXPROCS="$OPTARG" ;;
k) KEEPWAVS=y ;;
exit 1
fi
;;
- z) echo "Placeholder for a future autodebug option" ;;
+ z) CDROMREADERSYNTAX=debug ; EJECTCD="n" ;;
?) usage; exit ;;
esac
done
mpc)
[ "$MPPENCODERSYNTAX" = "default" ] && MPPENCODERSYNTAX=mppenc
;;
+ wav)
+ if [ "$KEEPWAVS" = "y" ]; then
+ vecho "Unsetting the KEEPWAVS option, since the resulting wav files were requested..."
+ fi
+ KEEPWAVS=move
+ ;;
*) echo "abcde error: Invalid OUTPUTTYPE defined" >&2
exit 1
;;
# Don't clean up
DOCLEAN=n
fi
+# Check if we have moved all the formats we had previously encoded, if we are not using the FORCE.
+if [ "$DOCLEAN" = "y" ] && [ ! "$FORCE" = "y" ]; then
+ ENCODED_FORMATS=$(egrep "^encodetrack-(.{3,6})-(.{1,2})$" "$ABCDETEMPDIR/status" | cut -d"-" -f2 | sort -u | tr '\n' '|')
+ MOVED_FORMATS=$(egrep "^movetrack-output-(.{3,6})$" "$ABCDETEMPDIR/status" | cut -d"-" -f3 | sort -u | tr '\n' '|')
+ if [ "$ENCODED_FORMATS" != "$MOVED_FORMATS" ]; then
+ echo "Not all encoded formats have been requested to be moved."
+ echo "Use \"-a clean -f -C $DISCID\" to force the removal of the remaining data."
+ DOCLEAN=n
+ fi
+fi
if [ "$DOCLEAN" = "y" ]; then
# Wipe all the evidence
# Gimme gimme gimme some more time!