r168@frost: data | 2005-09-19 10:27:33 +0300
[clinton/abcde.git] / abcde
diff --git a/abcde b/abcde
index de8dff3..d03e009 100755 (executable)
--- 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-$Id $"
 
 usage ()
 {
@@ -325,6 +325,14 @@ do_replaygain()
                for OUTPUT in $( echo $OUTPUTTYPE | tr , \ )
                # THE OUTPUT NEEDS TO BE CORRECTED WITH THE CONTAINER?
                do
+                       case $OUTPUT in
+                               vorbis|ogg)
+                                       OUTPUT=$OGGOUTPUTCONTAINER
+                                       ;;
+                               flac)
+                                       OUTPUT=$FLACOUTPUTCONTAINER
+                                       ;;
+                       esac
                        OUTPUTFILES=""
                        for UTRACKNUM in $TRACKQUEUE
                        do
@@ -343,19 +351,16 @@ do_replaygain()
                                OUTPUTFILES="$OUTPUTDIR/$OUTPUTFILE.$OUTPUT $OUTPUTFILES"
                        done
                        case "$OUTPUT" in
-                               flac);;
-                               ogg);;
+                               flac)
+                                       run_command replaygain-flac $METAFLAC --add-replay-gain $OUTPUTFILES
+                                       ;;
+                               vorbis|ogg)
+                                       run_command replaygain-vorbis $VORBISGAIN --album $OUTPUTFILES
+                                       ;;
                                *);;
                        esac
-                       if [ "$RETURN" = "0" ]; then
-                               run_command replaygain-$OUTPUT true
-                       else
-                               runcommand replaygain-$OUTPUT false
-                       fi
                done
-               if checkerrors replaygain-.{3,4}; then
-                       run_command replaygain false
-               else
+               if checkerrors replaygain-.{3,6}; then :; else
                        run_command replaygain true
                fi
        fi
@@ -685,9 +690,7 @@ do_tag ()
                        ;;
                esac
        done
-       if checkerrors "tagtrack-(.{3,4})-$1"; then
-               run_command tagtrack-$1 false
-       else
+       if checkerrors "tagtrack-(.{3,6})-$1"; then :; else
                run_command tagtrack-$1 true
        fi
 
@@ -719,7 +722,7 @@ do_batch_encode ()
                        else
                                for UTRACKNUM in $TRACKQUEUE
                                do
-                                       echo encodetrack-$UTRACKNUM >> status
+                                       run_command encodetrack-$UTRACKNUM true
                                done
                        fi
                        )
@@ -868,9 +871,7 @@ do_encode ()
                        esac
                done
                # Only remove .wav if the encoding succeeded
-               if checkerrors "encodetrack-(.{3,4})-$1"; then 
-                       run_command encodetrack-$1 false
-               else
+               if checkerrors "encodetrack-(.{3,6})-$1"; then :; else
                        run_command encodetrack-$1 true
                        if [ ! "$KEEPWAVS" = "y" ] ; then
                                rm -f "$IN"
@@ -1137,6 +1138,14 @@ do_playlist ()
 {
        for OUTPUT in $(echo $OUTPUTTYPE | tr , \ )
        do
+               case $OUTPUT in
+                       vorbis|ogg)
+                               OUTPUT=$OGGOUTPUTCONTAINER
+                               ;;
+                       flac)
+                               OUTPUT=$FLACOUTPUTCONTAINER
+                               ;;
+               esac
                # Create a playlist file for the playlist data to go into.
                # We used to wipe it out if it existed. Now we request permision if interactive.
                for LASTTRACK in $TRACKQUEUE; do :; done
@@ -1278,12 +1287,10 @@ do_discid ()
                                                if [ ! "$RET" = "0" ];then
                                                        echo "Warning: Something went wrong while querying the CD... Maybe a DATA CD?"
                                                fi
-                                               TRACKS="$( echo "$CDPARANOIAOUTPUT" | egrep '^[[:space:]]+[[:digit:]]' | tail -n 1 | get_first | tr -d "." | tr '\n' ' ' )"
+                                               TRACKS="$(echo "$CDPARANOIAOUTPUT" | egrep '^[[:space:]]+[[:digit:]]' | tail -n 1 | get_first | tr -d "." | tr '\n' ' ')"
                                                CDPARANOIAAUDIOTRACKS="$TRACKS"
                                        else
-                                               if [ -f "$ABCDETEMPDIR/status" ] && checkstatus cdparanoia-audio-tracks ; then
-                                                       TRACKS=$( cat "$ABCDETEMPDIR/cdparanoia-audio-tracks" )
-                                               else
+                                               if [ -f "$ABCDETEMPDIR/status" ] && TRACKS=$(checkstatus cdparanoia-audio-tracks); then :; else
                                                        TRACKS=$(echo $TRACKINFO | cut -f2 -d' ')
                                                fi
                                        fi
@@ -1414,10 +1421,8 @@ do_discid ()
        fi
        # If we got the CDPARANOIA status and it is not recorded, save it now
        if [ -n "$CDPARANOIAAUDIOTRACKS" ]; then
-               if checkstatus cdparanoia-audio-tracks; then :; else
-                       if echo "$CDPARANOIAAUDIOTRACKS" >> "$ABCDETEMPDIR/cdparanoia-audio-tracks"; then
-                               echo "cdparanoia-audio-tracks" >> "$ABCDETEMPDIR/status"
-                       fi
+               if checkstatus cdparanoia-audio-tracks > /dev/null 2>&1; then :; else
+                       echo cdparanoia-audio-tracks=$CDPARANOIAAUDIOTRACKS >> "$ABCDETEMPDIR/status"
                fi
        fi
        
@@ -2849,8 +2854,8 @@ if [ "$USEPIPES" = "y" ]; then
        esac
        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
+               echo "read the USEPIPES file from the source tarball to get help." >&2
+               echo "On a Debian system, it is under /usr/share/doc/abcde/USEPIPES.gz" >&2
                exit 1;
        fi
        if [ ! -n "$( eval echo "\$$PIPEENCODERSVARCHECK" )" ] ; then