Badge the upcoming release as 2.7 rather than 2.6.1
[abcde.git] / abcde
diff --git a/abcde b/abcde
index 0546c14..5b36406 100755 (executable)
--- a/abcde
+++ b/abcde
@@ -13,7 +13,7 @@
 # Copyright for this work is to expire January 1, 2010, after which it
 # shall be public domain.
 
-VERSION='2.6.1-UNRELEASED'
+VERSION='2.7-UNRELEASED'
 
 usage ()
 {
@@ -23,7 +23,7 @@ echo "Options:"
 echo "-1     Encode the whole CD in a single file"
 echo "-a <action1[,action2]...>"
 echo "       Actions to perform:"
-echo "       cddb,read,normalize,encode,tag,move,replaygain,playlist,clean"
+echo "       cddb,read,getalbumart,normalize,encode,tag,move,replaygain,playlist,clean"
 #echo "-A     Experimental actions (retag, transcode)"
 echo "-b     Enable batch normalization"
 echo "-c <file>"
@@ -87,9 +87,9 @@ log ()
        BLURB="$1"
        shift
        case $BLURB in
-               error)   echo "[ERROR] abcde: $@" >&2 ;;
-               warning) echo "[WARNING] $@" >&2 ;;
-               info)    echo "[INFO] $@" ;;
+               error)   >&2 echo "[ERROR] abcde: $@" >&2 ;;
+               warning) >&2 echo "[WARNING] $@" >&2 ;;
+               info)    >&4 echo "[INFO] $@" ;;
        esac
 }
 
@@ -885,7 +885,7 @@ do_tag ()
                                        fi
                                        (
                                        # These are from
-                                       # http://www.xiph.org/ogg/vorbis/doc/v-comment.html
+                                       # http://www.xiph.org/vorbis/doc/v-comment.html
 
                                        echo ARTIST="$TRACKARTIST"
                                        echo ALBUM="$DALBUM"
@@ -897,6 +897,11 @@ do_tag ()
                                                echo GENRE="$CDGENRE"
                                        fi
                                        echo TRACKNUMBER=${TRACKNUM:-$1}
+                                       # TRACKTOTAL is not in the proposed, minimal list of standard field names from
+                                       # xiph.org: http://www.xiph.org/vorbis/doc/v-comment.html but is in common usage
+                                       # and read by mediainfo, ffprobe, vlc, Aqualung, ogg123, Foobar. And now abcde :)
+                                       # The tag is quietly ignored by  Audacious, MPlayer, mpv, XMMS....
+                                       echo TRACKTOTAL="${TRACKS}"
                                        if [ -n "$DISCNUMBER" ]; then
                                                echo DISCNUMBER="$DISCNUMBER"
                                        fi
@@ -935,6 +940,11 @@ do_tag ()
                                echo GENRE="$CDGENRE"
                        fi
                        echo TRACKNUMBER="${TRACKNUM:-$1}"
+                       # TRACKTOTAL is not in the proposed, minimal list of standard field names from
+                       # xiph.org: http://www.xiph.org/vorbis/doc/v-comment.html but is in common usage
+                       # and read by mediainfo, ffprobe, vlc, Aqualung, ogg123, Foobar. And now abcde :)
+                       # The tag is quietly ignored by  Audacious, MPlayer, mpv, XMMS....
+                       echo TRACKTOTAL="${TRACKS}"
                        if [ -n "$DISCNUMBER" ]; then
                                echo DISCNUMBER="$DISCNUMBER"
                        fi
@@ -3004,6 +3014,14 @@ do_getalbumart()
                                                $HTTPGET "$ALBUMARTURL" > "$ABCDETEMPDIR/$ALBUMARTFILE"
                                                if [ $? -ne 0 ]; then
                                                        vecho "could not download cover from amazon" >&2
+                                               else
+                                                       # Check that size is reasonable; sometimes when there is no cover image
+                                                       # on amazon.com a 1x1 pixel gif image will be downloaded instead:
+                                                       FILESIZE=$(wc -c < "$ABCDETEMPDIR/$ALBUMARTFILE")
+                                                       if [ "$FILESIZE" -lt 1024 ]; then
+                                                               rm "$ABCDETEMPDIR/$ALBUMARTFILE"
+                                                               vecho "could not download cover from amazon" >&2
+                                                       fi
                                                fi
                                        else
                                                vecho "no amazon ID found" >&2
@@ -3254,7 +3272,7 @@ vecho ()
 if [ x"$EXTRAVERBOSE" != "x" ] && [ $EXTRAVERBOSE -gt 0 ] ; then
        case $1 in
                warning) shift ; log warning "$@" ;;
-               *) echo "$@" ;;
+               *) >&4 echo "$@" ;;
        esac
 fi
 }
@@ -3267,7 +3285,7 @@ vvecho ()
 if [ x"$EXTRAVERBOSE" != "x" ] && [ $EXTRAVERBOSE -gt 1 ] ; then
        case $1 in
                warning) shift ; log warning "$@" ;;
-               *) echo "$@" ;;
+               *) >&4 echo "$@" ;;
        esac
 fi
 }
@@ -3280,9 +3298,9 @@ decho ()
 if [ x"$DEBUG" != "x" ]; then
        if echo $1 | grep "^\[" > /dev/null 2>&1 ; then
                DEBUGECHO=$(echo "$@" | tr -d '[]')
-               echo "[DEBUG] $DEBUGECHO: `eval echo \\$${DEBUGECHO}`"
+               echo >&4 "[DEBUG] $DEBUGECHO: `eval echo \\$${DEBUGECHO}`"
        else
-               echo "[DEBUG] $1"
+               echo >&4 "[DEBUG] $1"
        fi
 fi
 }
@@ -3498,7 +3516,7 @@ FAACENCOPTS=
 NEROACENCOPTS=
 # fdkaac chokes without either a bitrate or bitrate-mode specified so 
 # we set bitrate here.
-FDKAACENCOPTS='192k'
+FDKAACENCOPTS='--bitrate 192k'
 
 ID3OPTS=
 EYED3OPTS=""
@@ -3541,6 +3559,9 @@ DEFAULT_OUTPUT_BINARIES=vorbis:oggenc,flac:flac,mp3:toolame,mp3:lame,mp3:bladeen
 # List of preferred cdromreaders - by default, run whichever we have in the path
 DEFAULT_CDROMREADERS="cdparanoia icedax cdda2wav libcdio pird"
 
+# fd for when `vecho` and `log info` called with redirected stdout
+exec 4>&1
+
 # Assume fetch if under FreeBSD. curl is used for Mac OS X. wget is used for
 # Linux/OpenBSD. ftp is user for NetBSD.
 # Let's use these checkings to determine the OS flavour, which will be used
@@ -4171,7 +4192,7 @@ esac
 case "$AACENCODERSYNTAX" in
                # Some elaborate 'if' work to keep backward compatability for those
                # who don't realise that AACENCOPTS does not work with abcde from
-               # version 2.6.1 onwards.
+               # version 2.7 onwards.
        faac)
                if [ -z "$FAACENCOPTS" ] && [ -n "$AACENCOPTS" ]; then
                        AACENCODEROPTS="${AACENCODEROPTSCLI:-$AACENCOPTS}"
@@ -4373,16 +4394,14 @@ if [ "$USEPIPES" = "y" ]; then
        if [ "$( eval echo "\$$PIPERIPPERSVARCHECK" )" = "$" ] || \
           [ "$( eval echo "\$$PIPERIPPERSVARCHECK" )" = "" ] ; then
                log error "no support for pipes with given ripper"
-               log error "read the USEPIPES file from the source tarball to get help."
-               log error "On a Debian system, it is under /usr/share/doc/abcde/USEPIPES.gz"
+               log error "read the FAQ file from the source tarball to get help."
                exit 1;
        fi
        decho "PIPEENCODERSVARCHECK: $( eval echo "\$$PIPEENCODERSVARCHECK" )"
        if [ "$( eval echo "\$$PIPEENCODERSVARCHECK" )" = "$" ] || \
           [ "$( eval echo "\$$PIPEENCODERSVARCHECK" )" = "" ] ; then
                log error "no support for pipes with given encoder"
-               log error "read the USEPIPES file from the source tarball to help"
-               log error "on a Debian system, read /usr/share/doc/abcde/USEPIPES.gz"
+               log error "read the FAQ file from the source tarball to get help"
                exit 1;
        fi
 fi