X-Git-Url: https://git.hcoop.net/clinton/abcde.git/blobdiff_plain/b69a8bb49108e275091c7115444f6ad4fc1db2c5..81d2dc2054747b9bc4581fd05d8b0ebee3cbd6af:/abcde diff --git a/abcde b/abcde index bd230a5..42f44db 100755 --- a/abcde +++ b/abcde @@ -11,7 +11,7 @@ # 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 () { @@ -32,6 +32,7 @@ echo " Specify CDROM device to grab (flac uses a single-track flac file)" 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)" @@ -62,6 +63,7 @@ echo "-x Eject CD after all tracks are read" echo "-w " 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)." @@ -144,6 +146,29 @@ checkstatus () 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). @@ -587,6 +612,7 @@ return 0 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 @@ -763,6 +789,7 @@ do_encode () 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" ;; @@ -991,7 +1018,7 @@ do_batch_gain () 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 @@ -1095,9 +1122,29 @@ do_move () 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 @@ -1106,6 +1153,14 @@ do_move () #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]) @@ -1434,7 +1489,6 @@ do_discid () # 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 @@ -2425,7 +2479,7 @@ fi # 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" ;; @@ -2439,7 +2493,7 @@ while getopts 1a:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W:z opt ; do h) usage; exit ;; e) ERASEENCODEDSTATUS=y ;; E) ENCODING="$OPTARG" ;; -# f) FORCECDDBUSELOCAL=y ;; + f) FORCE=y ;; i) INLINETAG=y ;; j) MAXPROCS="$OPTARG" ;; k) KEEPWAVS=y ;; @@ -2477,7 +2531,7 @@ while getopts 1a:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W:z opt ; do exit 1 fi ;; - z) echo "Placeholder for a future autodebug option" ;; + z) CDROMREADERSYNTAX=debug ; EJECTCD="n" ;; ?) usage; exit ;; esac done @@ -2719,7 +2773,9 @@ do [ "$MPPENCODERSYNTAX" = "default" ] && MPPENCODERSYNTAX=mppenc ;; wav) - vecho "Unsetting the KEEPWAVS option, since the resulting wav files were requested..." + 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 @@ -3289,6 +3345,16 @@ if [ "$KEEPWAVS" = "y" ];then # 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!