TRACKTOTAL written to ogg files
[abcde.git] / abcde
diff --git a/abcde b/abcde
index edbc78c..370e327 100755 (executable)
--- a/abcde
+++ b/abcde
 #
 # Copyright for this work is to expire January 1, 2010, after which it
 # shall be public domain.
-#
-# $Id$
 
-VERSION='2.5.5-UNRELEASED'
+VERSION='2.6.1-UNRELEASED'
 
 usage ()
 {
@@ -25,10 +23,9 @@ 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 "-B     Disable batch replaygain (do file by file)"
 echo "-c <file>"
 echo "       Specify a configuration file (overrides system and user config files)"
 echo "-C <discid#>"
@@ -39,6 +36,7 @@ echo "-D     Debugging mode (equivalent to sh -x abcde)"
 echo "-e     Erase encoded track information from status file"
 echo "-f     Force operations that otherwise are considered harmful. Read \"man abcde\""
 echo "-g     Use \"lame --nogap\" for MP3 encoding. Disables low disk and pipes flags"
+echo "-G     Get album art by using the 'getalbumart' action"
 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)"
@@ -51,11 +49,9 @@ echo "-m     Modify playlist to include CRLF endings, to comply with some player
 echo "-n     No lookup. Don't query CDDB, just create and use template"
 echo "-N     Noninteractive. Never prompt for anything"
 echo "-o <type1[,type2]...>"
-echo "       Output file type(s) (vorbis,mp3,flac,spx,mpc,wav,m4a). Defaults to vorbis"
+echo "       Output file type(s) (vorbis,mp3,flac,spx,mpc,wav,m4a,opus,wv,ape). 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 "-q <level>"
-echo "       Set quality level (high,medium,low)"
 echo "-r <host1[,host2]...>"
 echo "       Also encode on these remote hosts"
 echo "-s <field>"
@@ -433,8 +429,8 @@ getcddbinfo()
 gettracknum()
 {
        if [ -n "$STARTTRACKNUMBER" ] ; then
-               # Get the trackpadding from the current track
-               CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c)
+               # Get the trackpadding from the current track, also trim whitespace for MacOSX
+               CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c | tr -d ' ')
                TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
        else
                TRACKNUM=${UTRACKNUM}
@@ -493,7 +489,7 @@ makeids ()
 
        case "$CDDBMETHOD" in
                cddb)
-                       printf -v DISCID "%08lx" $(( ($CDDBCKSUM % 0xff) << 24 | $TOTALTIME << 8 | $TRACKS))
+                       printf -v DISCID "%08lx" $(( ($CDDBCKSUM % 0xff) * 16777216 | $TOTALTIME * 256 | $TRACKS))
                        ;;
                musicbrainz)
                        # FIXME: don't assume the first track is 1
@@ -515,6 +511,9 @@ do_replaygain()
                                vorbis|ogg)
                                        OUTPUT=$OGGOUTPUTCONTAINER
                                        ;;
+                               opus)
+                                       OUTPUT=$OPUSOUTPUTCONTAINER
+                                       ;;
                                flac)
                                        OUTPUT=$FLACOUTPUTCONTAINER
                                        ;;
@@ -541,7 +540,7 @@ do_replaygain()
                                        else
                                                OUTPUTFILE="$(eval echo \""$ONETRACKOUTPUTFORMAT"\")"
                                        fi
-                               else    
+                               else
                                        if [ "$VARIOUSARTISTS" = "y" ]; then
                                                OUTPUTFILE="$(eval echo \""$VAOUTPUTFORMAT"\")"
                                        else
@@ -563,7 +562,10 @@ do_replaygain()
                                        run_command replaygain-mp3 nice $ENCNICE $MP3GAIN $MP3GAINOPTS "${OUTPUTFILES[@]}"
                                        ;;
                                mpc)
-                                       run_command replaygain-mpc nice $ENCNICE $MPPGAIN --auto "${OUTPUTFILES[@]}"
+                                       run_command replaygain-mpc nice $ENCNICE $MPCGAIN "${OUTPUTFILES[@]}"
+                                       ;;
+                               wv)
+                                       run_command replaygain-wv nice $ENCNICE $WVGAIN $WVGAINOPTS "${OUTPUTFILES[@]}"
                                        ;;
                                *);;
                        esac
@@ -790,7 +792,7 @@ return 0
 # do_tag [tracknumber]
 # id3 tags a filename
 # variables used:
-# TRACKS, TRACKNAME, TRACKARTIST, TAGGER, TAGGEROPTS, VORBISCOMMENT, METAFLAC, ATOMICPARSLEY
+# TRACKS, TRACKNAME, TRACKARTIST, TAGGER, TAGGEROPTS, VORBISCOMMENT, METAFLAC,
 # COMMENT, DALBUM, DARTIST, CDYEAR, CDGENRE
 do_tag ()
 {
@@ -818,30 +820,17 @@ do_tag ()
                        if [ "$VARIOUSARTISTS" = "y" ]; then
                                TPE2="Various"
                        fi
-       
+
                        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-$OUTPUT-$1 nice $ENCNICE $TAGGER $TAGGEROPTS \
-                                               --comment=::"$COMMENTOUTPUT" -A "$DALBUM" \
-                                               -a "$TRACKARTIST" -t "$TRACKNAME" -Y "$CDYEAR" \
-                                               -G "$GENREID" -n "${TRACKNUM:-$1}" \
-                                               ${TRACKNUM:+-N "$TRACKS"} \
-                                               ${ENCODING:+--set-encoding="$ENCODING"} \
-                                               ${TPE2:+--set-text-frame=TPE2:"$TPE2"} \
-                                               "$ABCDETEMPDIR/track$1.$OUTPUT"
-                                       ;;
-                               # FIXME # Still not activated...
-                               id3ed)
+                               id3)
                                        run_command tagtrack-$OUTPUT-$1 nice $ENCNICE \
                                                $TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \
-                                               -a "$DALBUM" -n "$TRACKARTIST" -s "$TRACKNAME" \
-                                               -y "$CDYEAR" -g "$GENREID" -k "${TRACKNUM:-$1}" \
+                                               -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" \
+                                               -y "$CDYEAR" -g "$GENREID" \
+                                               -T "${TRACKNUM:-$1}" \
                                                "$ABCDETEMPDIR/track$1.$OUTPUT"
                                        ;;
-                               *)
+                               id3v2)
                                        # FIXME # track numbers in mp3 come with 1/10, so we cannot
                                        # happily substitute them with $TRACKNUM
                                        run_command tagtrack-$OUTPUT-$1 nice $ENCNICE \
@@ -852,6 +841,39 @@ do_tag ()
                                                ${TPE2:+--TPE2 "$TPE2"} \
                                                "$ABCDETEMPDIR/track$1.$OUTPUT"
                                        ;;
+                               eyed3*)
+                                       # FIXME # track numbers in mp3 come with 1/10, so we cannot
+                                       # happily substitute them with $TRACKNUM
+                                       case "$ID3SYNTAX" in
+                                               eyed3_06) addopts=( \
+                                                       ${ENCODING:+--set-encoding="$ENCODING"} \
+                                                       ${TPE2:+--set-text-frame=TPE2:"$TPE2"} \
+                                       # We set 'recording-date' so the date tag will show 
+                                       # in Audacious, vlc and friends...          Andrew.
+                                                       ${CDYEAR:+--set-text-frame="TDRC:$CDYEAR"} \
+                                                       ${COMMENTOUTPUT:+--comment=::"$COMMENTOUTPUT"} \
+                                                       );;
+                                               *) addopts=( \
+                                                       ${ENCODING:+--encoding="$ENCODING"} \
+                                                       ${TPE2:+--text-frame=TPE2:"$TPE2"} \
+                                       # We set 'recording-date' so the date tag will show 
+                                       # in Audacious, vlc and friends...           Andrew.
+                                                       ${CDYEAR:+--text-frame="TDRC:$CDYEAR"} \
+                                                       ${COMMENTOUTPUT:+--comment "$COMMENTOUTPUT"} \
+                                                       );;
+                                       esac
+                                       run_command tagtrack-$OUTPUT-$1 nice $ENCNICE $TAGGER $TAGGEROPTS \
+                                               -A "$DALBUM" \
+                                               -a "$TRACKARTIST" -t "$TRACKNAME" \
+                                               -G "$GENREID" -n "${TRACKNUM:-$1}" \
+                                               ${TRACKNUM:+-N "$TRACKS"} \
+                                               "${addopts[@]}" \
+                                               "$ABCDETEMPDIR/track$1.$OUTPUT"
+                                       ;;
+                               *)
+                                       log error "Internal error: ID3SYNTAX has an illegal value"
+                                       exit 1
+                                       ;;
                        esac
                        ;;
                vorbis|ogg)
@@ -863,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"
@@ -873,8 +895,13 @@ do_tag ()
                                        fi
                                        if [ -n "$CDGENRE" ]; then
                                                echo GENRE="$CDGENRE"
-                                       fi      
+                                       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
@@ -883,7 +910,7 @@ do_tag ()
                                                case "$COMMENTOUTPUT" in
                                                        *=*) echo "$COMMENTOUTPUT";;
                                                        *)   echo COMMENT="$COMMENTOUTPUT";;
-                                               esac    
+                                               esac
                                        fi
                                        ) | run_command tagtrack-$OUTPUT-$1 nice $ENCNICE \
                                                $VORBISCOMMENT $VORBISCOMMENTOPTS -w \
@@ -898,6 +925,9 @@ do_tag ()
                                        ;;
                        esac
                        ;;
+               opus)
+                       run_command tagtrack-$OUTPUT-$1 true
+                       ;;
                flac)
                        (
                        echo ARTIST="$TRACKARTIST"
@@ -908,8 +938,13 @@ do_tag ()
                        fi
                        if [ -n "$CDGENRE" ]; then
                                echo GENRE="$CDGENRE"
-                       fi      
+                       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
@@ -918,9 +953,10 @@ do_tag ()
                                case "$COMMENTOUTPUT" in
                                        *=*) echo "$COMMENTOUTPUT";;
                                        *)   echo COMMENT="$COMMENTOUTPUT";;
-                               esac    
+                               esac
                        fi
-                       ) | run_command tagtrack-$OUTPUT-$1 nice $ENCNICE $METAFLAC $METAFLACOPTS ${IMPORTCUESHEET:+--import-cuesheet-from="$ABCDETEMPDIR/$CUEFILE"} --import-tags-from=- "$ABCDETEMPDIR/track$1.$FLACOUTPUTCONTAINER"
+                       ) | run_command tagtrack-$OUTPUT-$1 nice $ENCNICE $METAFLAC $METAFLACOPTS ${IMPORTCUESHEET:+--import-cuesheet-from="$ABCDETEMPDIR/$CUEFILE"} \
+                       --import-tags-from=- "$ABCDETEMPDIR/track$1.$FLACOUTPUTCONTAINER"
                        ;;
                spx)
                        run_command tagtrack-$OUTPUT-$1 true
@@ -928,21 +964,35 @@ do_tag ()
                mpc)
                        run_command tagtrack-$OUTPUT-$1 true
                        ;;
+               wv)
+                       run_command tagtrack-$OUTPUT-$1 true
+                       ;;
+               ape)
+                       # This tagging syntax is suitable for Robert Muth's application 'apetag', the Monkey's Audio 
+                       # Console port (mac) used for encoding does not have the ability to tag.
+                       run_command tagtrack-$OUTPUT-$1 nice $ENCNICE "$APETAG" -i "$ABCDETEMPDIR/track$1.ape" -m overwrite \
+                       -p artist="$TRACKARTIST" -p album="$DALBUM" -p title="$TRACKNAME" -p track=${TRACKNUM:-$1} \
+                       -p year="$CDYEAR" -p genre="$CDGENRE" ${COMMENTOUTPUT:+-p comment="$COMMENTOUTPUT"} 
+                       ;;
+               aac)
+                       run_command tagtrack-$OUTPUT-$1 true
+                       ;;
                m4a)
-                       #  Use a temp-file of our choice. --overWrite seems to
-                       #  case core dumps with AtomicParsley 0.9.0
-                       ATOMICTEMPFILE="$ABCDETEMPDIR/track$1.m4a-atomic"
-
-                       VARIOUSBOOL="false"
-                       if [ "$VARIOUSARTISTS" = "y" ]; then
-                               VARIOUSBOOL="true"
-                       fi
-
-                       #It has to be command file opts for AtomicParsley
-                       run_command tagtrack-$OUTPUT-$1 nice $ENCNICE $ATOMICPARSLEY "$ABCDETEMPDIR/track$1.m4a" --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --tracknum ${TRACKNUM:-$1} --year "$CDYEAR" --genre "$CDGENRE" --compilation $VARIOUSBOOL --comment "$COMMENTOUTPUT" --output $ATOMICTEMPFILE
-                       if [ -f $ATOMICTEMPFILE ]; then
-                               mv "$ATOMICTEMPFILE" "$ABCDETEMPDIR/track$1.m4a"
-                       fi
+                       case "$AACENCODERSYNTAX" in
+                               fdkaac)
+                                       # We will use inline tagging...
+                                       run_command tagtrack-$OUTPUT-$1 true
+                                       ;;
+                               neroAacEnc)
+                                       # Tag post encode with neroAacTag...
+                                       run_command tagtrack-$OUTPUT-$1 nice $ENCNICE "$NEROAACTAG" "$ABCDETEMPDIR/track$1.m4a" \
+                                       -meta:artist="$TRACKARTIST" -meta:album="$DALBUM" -meta:title="$TRACKNAME" -meta:track=${TRACKNUM:-$1} \
+                                       -meta:year="$CDYEAR" -meta:genre="$CDGENRE" -meta:comment="$COMMENT"
+                                       ;;
+                               faac)
+                                       run_command tagtrack-$OUTPUT-$1 true   
+                                       ;;
+                       esac
                        ;;
                wav)
                        run_command tagtrack-$OUTPUT-$1 true
@@ -952,7 +1002,6 @@ do_tag ()
        if checkerrors "tagtrack-(.{3,6})-$1"; then :; else
                run_command tagtrack-$1 true
        fi
-
 }
 
 # do_nogap_encode
@@ -992,7 +1041,7 @@ do_nogap_encode ()
                        esac
                        ;;
                esac
-       done            
+       done
        if checkerrors "nogap-encode"; then :; else
                if [ ! "$KEEPWAVS" = "y" ] ; then
                        if [ ! "$KEEPWAVS" = "move" ] ; then
@@ -1007,7 +1056,8 @@ do_nogap_encode ()
 # do_encode [tracknumber] [hostname]
 # If no hostname is specified, encode locally
 # variables used:
-# TRACKS, TRACKNAME, TRACKARTIST, DISTMP3, DISTMP3OPTS, {FOO}ENCODERSYNTAX, OUTPUTTYPE, ENCODEROPTS, DALBUM, DARTIST, ENCNICE, CDYEAR, CDGENRE, COMMENT
+# TRACKS, TRACKNAME, TRACKARTIST, DISTMP3, DISTMP3OPTS, {FOO}ENCODERSYNTAX, OUTPUTTYPE, ENCODEROPTS, 
+# DALBUM, DARTIST, ENCNICE, CDYEAR, CDGENRE, COMMENT
 do_encode ()
 {
        if [ "$USEPIPES" = "y" ]; then
@@ -1018,6 +1068,9 @@ do_encode ()
                        vorbis|ogg)
                                TEMPARG="PIPE_$OGGENCODERSYNTAX"
                                ;;
+                       opus)
+                               TEMPARG="PIPE_$OPUSENCODERSYNTAX"
+                               ;;
                        flac)
                                TEMPARG="PIPE_$FLACENCODERSYNTAX"
                                ;;
@@ -1025,7 +1078,13 @@ do_encode ()
                                TEMPARG="PIPE_$SPEEXENCODER"
                                ;;
                        mpc)
-                               TEMPARG="PIPE_$MPPENCODER"
+                               TEMPARG="PIPE_$MPCENCODER"
+                               ;;
+                       wv)
+                               TEMPARG="PIPE_$WVENCODERSYNTAX"
+                               ;;
+                       aac)
+                               TEMPARG="PIPE_$AACENCODERSYNTAX"
                                ;;
                        m4a)
                                TEMPARG="PIPE_$AACENCODERSYNTAX"
@@ -1034,23 +1093,6 @@ do_encode ()
                IN="$( eval echo "\$$TEMPARG" )"
        else
                IN="$ABCDETEMPDIR/track$1.wav"
-               case "$OUTPUT" in
-                       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"
-                                               ;;
-                                       *)
-                                               FILEARG="$IN"
-                                               ;;
-                               esac
-                               ;;
-                       *)
-                               FILEARG="$IN"
-                               ;;
-               esac
        fi
        # We need IN to proceed, if we are not using pipes.
        if [ -s "$IN" -o X"$USEPIPES" = "Xy" ] ; then
@@ -1060,6 +1102,9 @@ do_encode ()
                                vorbis|ogg)
                                        OUTPUT=$OGGOUTPUTCONTAINER
                                        ;;
+                               opus)
+                                       OUTPUT=$OPUSOUTPUTCONTAINER
+                                       ;;
                                flac)
                                        OUTPUT=$FLACOUTPUTCONTAINER
                                        ;;
@@ -1075,7 +1120,7 @@ do_encode ()
                                RUN_COMMAND=""
                                # We need a way to store the creation of the files when using PIPES
                                RUN_COMMAND_PIPES="run_command encodetrack-$OUTPUT-$1 true"
-                               # When pipping it does not make sense to have a higher nice for
+                               # When piping it does not make sense to have a higher nice for
                                # reading than for encoding, since it will be hold by the
                                # encoding process. Setting an effective nice, to calm down a
                                # bit the reading process.
@@ -1091,9 +1136,8 @@ do_encode ()
                                %local*%)
                                        case "$MP3ENCODERSYNTAX" in
                                        lame|toolame|gogo) $RUN_COMMAND nice $EFFECTIVE_NICE $MP3ENCODER $MP3ENCODEROPTS "$IN" "$OUT" ;;
-                                       bladeenc) $RUN_COMMAND nice $EFFECTIVE_NICE $MP3ENCODER $MP3ENCODEROPTS -quit "$IN" ;;
+                                       bladeenc) $RUN_COMMAND nice $EFFECTIVE_NICE $MP3ENCODER $MP3ENCODEROPTS -quit "$IN" "$OUT" ;;
                                        l3enc|xingmp3enc) $RUN_COMMAND nice $EFFECTIVE_NICE $MP3ENCODER "$IN" "$OUT" $MP3ENCODEROPTS ;;
-                                       # FIXME # Relates to the previous FIXME since it might need the "-if" removed.
                                        mp3enc) $RUN_COMMAND nice $EFFECTIVE_NICE $MP3ENCODER -if "$IN" -of "$OUT" $MP3ENCODEROPTS ;;
                                        esac
                                        ;;
@@ -1115,6 +1159,27 @@ do_encode ()
                                        ;;
                                esac
                                ;;
+                       opus)
+                               case "$2" in
+                               %local*%)
+                                       case "$OPUSENCODERSYNTAX" in
+                                       opusenc)
+                                       # Tag the file at encode time, as it can't be done after encoding.
+                                               if [ "$DOTAG" = "y" ]; then
+                                                       $RUN_COMMAND nice $EFFECTIVE_NICE $OPUSENCODER $OPUSENCODEROPTS --artist "$TRACKARTIST" \
+                                                       --album "$DALBUM" --title "$TRACKNAME" --genre "$CDGENRE" --date "$CDYEAR" --comment TRACKNUMBER="$1" \
+                                                       ${COMMENT:+--comment COMMENT="$COMMENT"} "$IN" "$OUT"
+                                               else
+                                                       $RUN_COMMAND nice $EFFECTIVE_NICE $OPUSENCODER $OPUSENCODEROPTS "$IN" "$OUT"
+                                               fi
+                                       ;;
+                                       esac
+                                       ;;
+                               *)
+                                       $RUN_COMMAND nice $DISTMP3NICE $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" >/dev/null 2>&1
+                                       ;;
+                               esac
+                               ;;
                        flac)
                                case "$2" in
                                %local*%)
@@ -1134,35 +1199,69 @@ do_encode ()
                                        case "$COMMENT" in
                                                *=*) ;;
                                                *)   COMMENT="COMMENT=$COMMENT" ;;
-                                       esac    
+                                       esac
                                fi
                                # Tag the file at encode time, as it can't be done after encoding.
                                if [ "$DOTAG" = "y" ]; then
-                                       $RUN_COMMAND nice $EFFECTIVE_NICE $SPEEXENCODER $SPEEXENCODEROPTS --author "$TRACKARTIST" --title "$TRACKNAME" ${COMMENT:+--comment "$COMMENT"} "$IN" "$OUT"
+                                       $RUN_COMMAND nice $EFFECTIVE_NICE $SPEEXENCODER $SPEEXENCODEROPTS --author "$TRACKARTIST" --title "$TRACKNAME" \
+                                       ${COMMENT:+--comment "$COMMENT"} "$IN" "$OUT"
                                else
                                        $RUN_COMMAND nice $EFFECTIVE_NICE $SPEEXENCODER $SPEEXENCODEROPTS "$IN" "$OUT"
                                fi
                                ;;
-                       mpc)    
-                               # MPP/MP+(Musepack) format (.mpc) is done locally, with inline
-                               # tagging.
-                               # I tried compiling the mppenc from corecodecs.org and got some
-                               # errors, so I have not tried it myself.
-                               ## FIXME ## Needs some cleanup to determine if an empty tag sent
-                               ## FIXME ## to the encoder ends up empty.
-                               $RUN_COMMAND nice $EFFECTIVE_NICE $MPPENCODER $MPPENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" "$IN" "$OUT"
+                       mpc)
+                               # Tag the file inline at encode time.
+                               if [ "$DOTAG" = "y" ]; then
+                                       $RUN_COMMAND nice $EFFECTIVE_NICE $MPCENCODER $MPCENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" \
+                                       --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" ${COMMENT:+--comment "$COMMENT"} "$IN" "$OUT"
+                               else
+                                       $RUN_COMMAND nice $EFFECTIVE_NICE $MPCENCODER $MPCENCODEROPTS "$IN" "$OUT"
+                               fi
                                ;;
-                       m4a)
-                               # Tag the file at encode time, as it can't be done after encoding.
+                       wv)
                                if [ "$DOTAG" = "y" ]; then
-                                       $RUN_COMMAND nice $EFFECTIVE_NICE $AACENCODER $AACENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" -o "$OUT" "$IN"
-                                       
+                                       $RUN_COMMAND nice $EFFECTIVE_NICE $WVENCODER $WVENCODEROPTS -w Artist="$TRACKARTIST" -w Album="$DALBUM" \
+                                       -w Title="$TRACKNAME" -w Track="$1" -w Genre="$CDGENRE" -w Year="$CDYEAR" ${COMMENT:+-w Comment="$COMMENT"} "$IN" -o "$OUT"
                                else
-                                       $RUN_COMMAND nice $ENCNICE $AACENCODER $AACENCODEROPTS -o "$OUT" "$IN"
+                                       $RUN_COMMAND nice $EFFECTIVE_NICE $WVENCODER $WVENCODEROPTS "$IN" -o "$OUT"
                                fi
                                ;;
+                       ape)
+                               $RUN_COMMAND nice $EFFECTIVE_NICE $APENCODER "$IN" "$OUT" $APENCODEROPTS
+                               ;;
+                       aac)
+                               # aac container is only used to catch faac encoded files where faac 
+                               # is compiled without mp4 support (with libmp4v2).
+                               $RUN_COMMAND nice $EFFECTIVE_NICE $AACENCODER $AACENCODEROPTS -o "$OUT" "$IN"
+                               ;;
+                       m4a)
+                               case "$AACENCODERSYNTAX" in
+                                       faac)
+                                               if [ "$DOTAG" = "y" ]; then
+                                                       $RUN_COMMAND nice $EFFECTIVE_NICE $AACENCODER $AACENCODEROPTS  --artist "$TRACKARTIST" --album "$DALBUM" \
+                                                       --title "$TRACKNAME" --track ${TRACKNUM:-$1} --year "$CDYEAR" --genre "$CDGENRE" --comment "$COMMENT" -o "$OUT" "$IN"
+                                               else 
+                                                       $RUN_COMMAND nice $EFFECTIVE_NICE $AACENCODER $AACENCODEROPTS -o "$OUT" "$IN"   
+                                               fi
+                                               ;;
+                                       neroAacEnc)
+                                               $RUN_COMMAND nice $EFFECTIVE_NICE $AACENCODER $AACENCODEROPTS -if "$IN" -of "$OUT"
+                                               ;;
+                                       fdkaac)      
+                                               if [ "$DOTAG" = "y" ]; then
+                                                       $RUN_COMMAND nice $EFFECTIVE_NICE $AACENCODER $AACENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" \
+                                                       --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --date "$CDYEAR" --comment "$COMMENT" "$IN" -o "$OUT"
+                                               else
+                                                       $RUN_COMMAND nice $EFFECTIVE_NICE $AACENCODER $AACENCODEROPTS "$IN" -o "$OUT"
+                                               fi
+                                               ;;
+                                       esac
+                               ;;
                        wav)
                                # In case of wav output we need nothing. Just keep the wavs.
+                               # But we need the following to allow full logging and subsequent 
+                               # successful cleaning of $ABCDETEMPDIR.
+                               echo "encodetrack-$OUTPUT-$UTRACKNUM" >> "$ABCDETEMPDIR/status"
                                ;;
                        esac
                        $RUN_COMMAND_PIPES
@@ -1272,7 +1371,7 @@ do_single_gain ()
 
 # do_batch_gain
 # variables used:
-# MP3GAIN, MP3GAINOPTS, VORBISGAIN, VORBISGAINOPTS, MPPGAIN, MPPGAINOPTS
+# MP3GAIN, MP3GAINOPTS, VORBISGAIN, VORBISGAINOPTS, MPCGAIN
 # FIXME #
 do_batch_gain ()
 {
@@ -1383,7 +1482,7 @@ do_move ()
                        else
                                OUTPUTFILE="$(eval echo \""$ONETRACKOUTPUTFORMAT"\")"
                        fi
-               else    
+               else
                        if [ "$VARIOUSARTISTS" = "y" ]; then
                                OUTPUTFILE="$(eval echo \""$VAOUTPUTFORMAT"\")"
                        else
@@ -1397,6 +1496,9 @@ do_move ()
                                vorbis|ogg)
                                        OUTPUT=$OGGOUTPUTCONTAINER
                                        ;;
+                               opus)
+                                       OUTPUT=$OPUSOUTPUTCONTAINER
+                                       ;;
                                flac)
                                        OUTPUT=$FLACOUTPUTCONTAINER
                                        ;;
@@ -1478,6 +1580,9 @@ do_playlist ()
                        vorbis|ogg)
                                OUTPUT=$OGGOUTPUTCONTAINER
                                ;;
+                       opus)
+                               OUTPUT=$OPUSOUTPUTCONTAINER
+                               ;;
                        flac)
                                OUTPUT=$FLACOUTPUTCONTAINER
                                ;;
@@ -1486,7 +1591,7 @@ do_playlist ()
                                ;;
                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.
+               # We used to wipe it out if it existed. Now we request permission if interactive.
                for LASTTRACK in $TRACKQUEUE; do :; done
                ALBUMFILE="$(mungefilename "$DALBUM")"
                ARTISTFILE="$(mungefilename "$DARTIST")"
@@ -1601,7 +1706,7 @@ abcde.cue2discid () {
        LEADIN=88200
        i=0
        N=0
-       
+
        while read line ; do
                set -- $line
                case "$1" in
@@ -1627,16 +1732,16 @@ abcde.cue2discid () {
                        esac
                        ;;
                esac
-               
+
        done
-       
+
        TRACKS=$i
        LEADOUT=$(( $LEADOUT + $LEADIN ))
 
        LENGTH=$(( $LEADOUT/75 - $TRACK1/75 ))
        DISCID=$(( ( $N % 255 ) * 2**24 | $LENGTH * 2**8 | $TRACKS ))
        printf "%08x %i" $DISCID $TRACKS
-       
+
        j=1
        while [ $j -le $TRACKS ] ; do
                eval echo -n "\" \$TRACK$j\""
@@ -1705,7 +1810,7 @@ abcde.mkcue () {
        shift 2
 
        echo REM DISCID $DISCID
-       echo FILE \""$CUEWAVEFILE"\" WAVE
+       echo FILE \""$CUEWAVFILE"\" WAVE
 
        if [ $1 -ne 150 ] && [ $MODE = "PREGAP" ] ; then
                OFFSET=$1
@@ -1839,7 +1944,7 @@ do_discid ()
        if [ -z "$TRACKQUEUE" ]; then
                if [ ! "$STRIPDATATRACKS" = "n" ]; then
                        case "$CDROMREADERSYNTAX" in
-                               cdparanoia|debug)
+                               cdparanoia|libcdio|debug)
                                        if [ "$WEHAVEACD" = "y" ]; then
                                                vecho "Querying the CD for audio tracks..."
                                                CDPARANOIAOUTPUT="$( $CDROMREADER -$CDPARANOIACDROMBUS "$CDROM" -Q --verbose 2>&1 )"
@@ -2003,7 +2108,7 @@ do_discid ()
                        echo cdparanoia-audio-tracks=$CDPARANOIAAUDIOTRACKS >> "$ABCDETEMPDIR/status"
                fi
        fi
-       
+
        # Create the discid file
        echo "$TRACKINFO" > "$ABCDETEMPDIR/discid"
        if checkstatus cddbmethod > /dev/null 2>&1 ; then :; else
@@ -2104,7 +2209,7 @@ do_cddbparse ()
 do_localcddb ()
 {
        if checkstatus cddb-readcomplete && checkstatus cddb-choice >/dev/null; then :; else
-       
+
                CDDBLOCALSTATUS="notfound"
                CDDBDISCID=$(echo $TRACKINFO | cut -d' ' -f1)
                USELOCALRESP="y"
@@ -2127,7 +2232,7 @@ do_localcddb ()
                else
                        CDDBLOCALMATCH=none
                fi
-               
+
                # If the user has selected to check a local CDDB repo, we proceed with it
                case $CDDBLOCALMATCH in
                        multiple)
@@ -2138,7 +2243,7 @@ do_localcddb ()
                                        # List out disc title/author and contents
                                        CDDBLOCALREAD="$ABCDETEMPDIR/cddblocalread.$X"
                                        cat "$RESULT" > "${CDDBLOCALREAD}"
-                                       {       
+                                       {
                                                echo -n "#$X: "
                                                do_cddbparse "${CDDBLOCALREAD}"
                                                echo ""
@@ -2400,6 +2505,9 @@ do_cddbstat ()
                                                2??)    # Server responded, everything seems OK
                                                        rc=0
                                                        ;;
+                                               *)      # unknown error
+                                                       break
+                                                       ;;
                                        esac
                                        ;;
                                esac
@@ -2418,7 +2526,7 @@ do_cddbquery ()
 {
        CDDBDISCID=$(echo $TRACKINFO | cut -d' ' -f1)
        CDDBLOCALFILE="${CDDBLOCALDIR}/${CDDBDISCID}"
-       
+
        # Perform CDDB query if it hasn't already been done
        if checkstatus cddb-querycomplete; then :; else
                if [ "$CDDBAVAIL" = "n" ]; then
@@ -2546,7 +2654,7 @@ do_cddbread ()
                        echo cddb-read-1-complete >> "$ABCDETEMPDIR/status"
                        echo cddb-choice=1 >> "$ABCDETEMPDIR/status"
                        ;;
-               esac    
+               esac
                echo "cddb-readcomplete" >> "$ABCDETEMPDIR/status"
        fi
 }
@@ -2592,7 +2700,7 @@ do_cddbedit ()
                                                # It's all going to fit in one page, cat it
                                                cat "$ABCDETEMPDIR/cddbchoices" >&2
                                        fi
-                                       
+
                                        CDDBCHOICENUM=""
                                        # Setting the choice to an impossible integer to avoid errors in the numeric comparisons
                                        CDCHOICENUM=-1
@@ -2697,23 +2805,23 @@ do_cddbedit ()
                exit 1
        fi
        CDDBDATA="$ABCDETEMPDIR/cddbread.$(checkstatus cddb-choice)"
-       echo -n "Edit selected CDDB data? [y/n] (" >&2
+       echo -n "Edit selected CDDB data " >&2
        if [ "$INTERACTIVE" = "y" ]; then
                if [ "$UNKNOWNDISK" = "y" ]; then
-                       echo -n "y): " >&2
+                       echo -n "[Y/n]? " >&2
                        read EDITCDDB
                        [ "$EDITCDDB" != "n" ] && EDITCDDB=y
                else
-                       echo -n "n): " >&2
+                       echo -n "[y/N]? " >&2
                        read EDITCDDB
                fi
        else
-               echo "n): n" >&2
+               echo "[y/N]? " >&2
                EDITCDDB=n
        fi
        if [ "$EDITCDDB" = "y" ]; then
                CDDBDATAMD5SUM=$($MD5SUM "$CDDBDATA" | cut -d " " -f 1);
-               
+
                # Use the debian sensible-editor wrapper to pick the editor that the
                # user has requested via their $EDITOR environment variable
                if [ -x "/usr/bin/sensible-editor" ]; then
@@ -2878,6 +2986,132 @@ do_cddbedit ()
        echo "cddb-edit" >> "$ABCDETEMPDIR/status"
 }
 
+# do_getalbumart
+# try to download CD cover
+do_getalbumart()
+{
+       # set variables
+       ALBUMFILE="$(mungefilename "$DALBUM")"
+       ARTISTFILE="$(mungefilename "$DARTIST")"
+       # have we got a musicbrainz mbid or amazon asin?
+       case "$CDDBMETHOD" in
+               musicbrainz)
+                       # try musicbrainz mbid
+                       if [ -s "$ABCDETEMPDIR/mbid.$(checkstatus cddb-choice)" ]; then
+                               MBID=$(cat "$ABCDETEMPDIR/mbid.$(checkstatus cddb-choice)")
+                               vecho "trying to get cover from coverartarchive.orq with musicbrainz mbid $MBID" >&2
+                               ALBUMARTURL="http://coverartarchive.org/release/$MBID/front"
+                               vecho "cover URL: $ALBUMARTURL" >&2
+                               $HTTPGET "$ALBUMARTURL" > "$ABCDETEMPDIR/$ALBUMARTFILE"
+                               if [ $? -ne 0 ]; then
+                                       vecho "could not download cover from musicbrainz" >&2
+                                       # try amazon asin
+                                       if [ -s "$ABCDETEMPDIR/asin.$(checkstatus cddb-choice)" ]; then
+                                               ASIN=$(cat "$ABCDETEMPDIR/asin.$(checkstatus cddb-choice)")
+                                               vecho "trying to get cover from amazon.com with asin $ASIN" >&2
+                                               ALBUMARTURL="http://ec1.images-amazon.com/images/P/$ASIN.01.LZZZZZZZZ.jpg"
+                                               vecho "cover URL: $ALBUMARTURL" >&2
+                                               $HTTPGET "$ALBUMARTURL" > "$ABCDETEMPDIR/$ALBUMARTFILE"
+                                               if [ $? -ne 0 ]; then
+                                                       vecho "could not download cover from amazon" >&2
+                                               fi
+                                       else
+                                               vecho "no amazon ID found" >&2
+                                       fi
+                               fi
+                       else
+                               vecho "no musicbrainz ID found" >&2
+                       fi
+                       ;;
+       esac
+       # use glyrc
+       if [ ! -s "$ABCDETEMPDIR/$ALBUMARTFILE" ]; then
+               vecho "trying to get cover with glyrc for $ARTISTFILE / $ALBUMFILE" >&2
+               $GLYRC cover --artist "$ARTISTFILE" --album "$ALBUMFILE" --write "$ABCDETEMPDIR/$ALBUMARTFILE" $GLYRCOPTS
+               if [ $? -ne 0 ]; then
+                       vecho "could not download cover with glyrc" >&2
+               else
+                       ALBUMARTURL="glyrc"
+               fi
+       fi
+       if [ "$INTERACTIVE" = "y" ]; then
+               if [ -s "$ABCDETEMPDIR/$ALBUMARTFILE" ]; then
+                       # display properties of coverart when identify is available
+                       if new_checkexec $IDENTIFY; then
+                               $IDENTIFY $IDENTIFYOPTS "$ABCDETEMPDIR/$ALBUMARTFILE" >&2
+                       fi
+                       # display coverart when DISPLAY is set and display command is available
+                       if new_checkexec $DISPLAYCMD && [ "$DISPLAY" != "" ]; then
+                               $DISPLAYCMD $DISPLAYCMDOPTS "$ABCDETEMPDIR/$ALBUMARTFILE" >&2 &
+                       fi
+               else
+                       # nothing downloaded yet
+                       vecho "automatic album art downloading failed" >&2
+               fi
+               # see if the user can find a better album art manually
+               echo -n "Do you want to enter URL or local path for the album art [y/N]? " >&2
+               read YESNO
+               while [ "$YESNO" != "y" ] && [ "$YESNO" != "n" ] && [ "$YESNO" != "Y" ] && \
+                       [ "$YESNO" != "N" ] && [ "$YESNO" != "" ]
+               do
+                       echo -n 'Invalid selection. Please answer "y" or "n": ' >&2
+                       read YESNO
+               done
+               if [ "$YESNO" = "y" ] || [ "$YESNO" = "Y" ]; then
+                       echo -n "Enter URL or local path (ENTER to cancel) :" >&2
+                       read ALBUMARTURL
+                       if [ ! -z "$ALBUMARTURL" ]; then
+                               if [[ ${ALBUMARTURL} =~ (https?|ftp|file)://.* ]]; then
+                                       $HTTPGET "$ALBUMARTURL" > "$ABCDETEMPDIR/$ALBUMARTFILE"
+                                       if [ ! -s "$ABCDETEMPDIR/$ALBUMARTFILE" ]; then
+                                               vecho "unable to download $ALBUMARTURL" >&2
+                                       fi
+                               else # it's a local path
+                                       cp "$ALBUMARTURL" "$ABCDETEMPDIR/$ALBUMARTFILE"
+                                       if [ ! -s "$ABCDETEMPDIR/$ALBUMARTFILE" ]; then
+                                               vecho "unable to copy $ALBUMARTURL to $ABCDETEMPDIR/$ALBUMARTFILE" >&2
+                                       fi
+                               fi
+                       fi
+               fi
+       fi
+       # convert to ALBUMARTTYPE if ImageMagick is available, if not assume correct type
+       if [ -s "$ABCDETEMPDIR/$ALBUMARTFILE" ] && new_checkexec $IDENTIFY; then
+               ALBUMARTURLTYPE=$($IDENTIFY "$ABCDETEMPDIR/$ALBUMARTFILE" | cut -d' ' -f2)
+               if [ "$ALBUMARTURLTYPE" != "$ALBUMARTTYPE" -o "$ALBUMARTALWAYSCONVERT" = "y" ]; then
+                       if new_checkexec $CONVERT; then
+                               mv "$ABCDETEMPDIR/$ALBUMARTFILE" "$ABCDETEMPDIR/$ALBUMARTFILE.tmp"
+                               $CONVERT "$ABCDETEMPDIR/$ALBUMARTFILE.tmp" $CONVERTOPTS "$ABCDETEMPDIR/$ALBUMARTFILE"
+                               rm -f "$ABCDETEMPDIR/$ALBUMARTFILE.tmp"
+                       else
+                               rm -f "$ABCDETEMPDIR/$ALBUMARTFILE"
+                               vecho "sorry, cannot convert $ALBUMARTURLTYPE to $ALBUMARTTYPE without ImageMagick convert" >&2
+                       fi
+               fi
+       fi
+       # copy to target directories
+       if [ -s "$ABCDETEMPDIR/$ALBUMARTFILE" ]; then
+               for OUTPUT in $(echo $OUTPUTTYPE | tr , \ )
+               do
+                       # put cover in the same place as the album
+                       if [ "$VARIOUSARTISTS" = "y" ] ; then
+                               ALBUMARTDIR="$(eval echo "$VAOUTPUTFORMAT")"
+                       else
+                               ALBUMARTDIR="$(eval echo "$OUTPUTFORMAT")"
+                       fi
+                       FINALALBUMARTDIR="$(dirname "$OUTPUTDIR/$ALBUMARTDIR")"
+                       vecho "copying cover to target directory $FINALALBUMARTDIR" >&2
+                       mkdir -p "$FINALALBUMARTDIR"
+                       cp "$ABCDETEMPDIR/$ALBUMARTFILE" "$FINALALBUMARTDIR"
+               done
+               rm -f "$ABCDETEMPDIR/$ALBUMARTFILE"
+               echo "get-album-art=$ALBUMARTURL" >> "$ABCDETEMPDIR/status"
+       else
+               log warning "could not get cover"
+               echo "get-album-art=none" >> "$ABCDETEMPDIR/status"
+       fi
+}
+
 # do_cdread [tracknumber]
 # do_cdread onetrack [firsttrack] [lasttrack]
 #
@@ -2895,11 +3129,12 @@ do_cdread ()
                UTRACKNUM=$FIRSTTRACK
                case "$CDROMREADERSYNTAX" in
                        flac) READTRACKNUMS="$FIRSTTRACK.1-$(($LASTTRACK + 1)).0" ;;
-                       cdparanoia)
+                       cdparanoia|libcdio)
                                #XX FIXME XX
                                # Add a variable to check if tracks are provided in command line and if not, use "0-" to rip the tracks
                                READTRACKNUMS="$FIRSTTRACK-$LASTTRACK" ;;
                        cdda2wav | icedax) READTRACKNUMS="$FIRSTTRACK+$LASTTRACK" ;;
+                       pird) READTRACKNUMS="$FIRSTTRACK..$LASTTRACK" ;;
                        *) echo "abcde error: $CDROMREADERSYNTAX does not support ONETRACK mode"
                                exit 1 ;;
                esac
@@ -2910,23 +3145,20 @@ do_cdread ()
        if [ "$USEPIPES" = "y" ]; then
                TEMPARG="PIPERIPPER_$CDROMREADERSYNTAX"
                FILEARG="$( eval echo "\$$TEMPARG" )"
-               REDIR="y"
+               REDIR=""
                PIPE_MESSAGE="and encoding "
        else
                WAVDATA="$ABCDETEMPDIR/track$UTRACKNUM.wav"
                case "$CDROMREADERSYNTAX" in
-               ## FIXME ## Find the cases for dagrab and flac, to avoid exceptions
+               ## FIXME ## Find the cases for flac, to avoid exceptions
                        flac)
                                FILEARG="--output-name=$WAVDATA"
                                ;;
-                       dagrab)
-                               FILEARG="-f $WAVDATA"
-                               ;;
                        *)
                                FILEARG="$WAVDATA"
                                ;;
                esac
-               REDIR="n"
+               REDIR=">&2"
        fi
        if [ "$1" = "onetrack" ]; then
                echo "Grabbing ${PIPE_MESSAGE}tracks $UTRACKNUM - $LASTTRACK as one track ..." >&2
@@ -2942,16 +3174,11 @@ do_cdread ()
                ### FIXME ### use an exception for flac, since it uses -o
                ### FIXME ### Shall we just use -o $FILEARG ??
                flac)
-                       # Avoid problems wit math expressions by unpadding the given UTRACKNUM
+                       # Avoid problems with math expressions by unpadding the given UTRACKNUM
                        STRIPTRACKNUM=$(expr $UTRACKNUM + 0)
                        nice $READNICE $FLAC -d -f --cue=${READTRACKNUMS:-$STRIPTRACKNUM.1-$(($STRIPTRACKNUM + 1)).0} "$FILEARG" "$CDROM" ;;
-               cdparanoia)
-                       if [ "$REDIR" = "y" ]; then
-                               nice $READNICE $CDROMREADER -$CDPARANOIACDROMBUS "$CDROM" ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" >&2
-                       else
-                               nice $READNICE $CDROMREADER -$CDPARANOIACDROMBUS "$CDROM" ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG"
-                       fi;;
-
+               cdparanoia|libcdio)
+                       nice $READNICE $CDROMREADER -$CDPARANOIACDROMBUS "$CDROM" ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" $REDIR ;;
                cdda2wav | icedax)
                        if [ "$OSFLAVOUR" = "OSX" ] ; then
                                # Hei, we have to unmount the device before running anything like cdda2wav/icedax in OSX
@@ -2967,19 +3194,17 @@ do_cdread ()
                                        CDDA2WAVCDROM="$CDROMID"
                                fi
                        fi
-                       if [ "$REDIR" = "y" ]; then
-                               nice $READNICE $CDROMREADER -D $CDDA2WAVCDROM -t ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" >&2
-                       else
-                               nice $READNICE $CDROMREADER -D $CDDA2WAVCDROM -t ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG"
-                       fi ;;
-               ## FIXME ## We have an exception for dagrab, since it uses -f
-               ## FIXME ## Shall we just use -f $FILEARG ??
-               dagrab)
-               if [ "$REDIR" = "y" ]; then
-                               nice $READNICE $CDROMREADER -d "$CDROM" -v $UTRACKNUM "$FILEARG" >&2
+                       nice $READNICE $CDROMREADER -D $CDDA2WAVCDROM -t ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" $REDIR ;;
+               dagrab) nice $READNICE $CDROMREADER -d "$CDROM" -f "$FILEARG" -v $UTRACKNUM >&2 ;;
+               pird)
+                       if [ "$USEPIPES" = "y" ]; then
+                               nice $READNICE $CDROMREADER -j ${READTRACKNUMS:-$UTRACKNUM} "$CDROM" "$FILEARG"
                        else
-                               nice $READNICE $CDROMREADER -d "$CDROM" -v $UTRACKNUM "$FILEARG"
-                       fi ;;
+                               # Write ripped audio data to stdout and redirect to $FILEARG.
+                               # $REDIR can be ignored. Progress is written to stderr by default.
+                               nice $READNICE $CDROMREADER -j ${READTRACKNUMS:-$UTRACKNUM} "$CDROM" "$PIPERIPPER_pird" > "$FILEARG"
+                       fi
+                       ;;
                cddafs)
                        # Find the track's mounted path
                        REALTRACKNUM=$(expr $UTRACKNUM + 0)
@@ -2987,20 +3212,11 @@ do_cdread ()
                        FILEPATH=$(find "$FILEPATH" | grep "/$REALTRACKNUM ");
                        # If the file exists, copy it
                        if [ -e "$FILEPATH" ] ; then
-                               if [ "$REDIR" = "y" ]; then
-                                       nice $READNICE $CDROMREADER "$FILEPATH" "$FILEARG" >&2
-                               else
-                                       nice $READNICE $CDROMREADER "$FILEPATH" "$FILEARG"
-                               fi
+                               nice $READNICE $CDROMREADER "$FILEPATH" "$FILEARG" $REDIR
                        else
                                false
                        fi ;;
-               debug)
-                       if [ "$REDIR" = "y" ]; then
-                               nice $READNICE $CDROMREADER -$CDPARANOIACDROMBUS "$CDROM" -w $UTRACKNUM-[:1] "$FILEARG" >&2
-                       else
-                               nice $READNICE $CDROMREADER -$CDPARANOIACDROMBUS "$CDROM" -w $UTRACKNUM-[:1] "$FILEARG"
-                       fi ;;
+               debug) nice $READNICE $CDROMREADER -$CDPARANOIACDROMBUS "$CDROM" -w $UTRACKNUM-[:1] "$FILEARG" $REDIR ;;
        esac
        RETURN=$?
        # If we get some error or we get some missing wav
@@ -3146,9 +3362,12 @@ ENCODERSYNTAX=default
 
 MP3ENCODERSYNTAX=default
 OGGENCODERSYNTAX=default
+OPUSENCODERSYNTAX=default
 FLACENCODERSYNTAX=default
 SPEEXENCODERSYNTAX=default
-MPPENCODERSYNTAX=default
+MPCENCODERSYNTAX=default
+WVENCODERSYNTAX=default
+APENCODERSYNTAX=default
 AACENCODERSYNTAX=default
 NORMALIZERSYNTAX=default
 CUEREADERSYNTAX=default
@@ -3165,7 +3384,7 @@ VAPLAYLISTFORMAT='${ARTISTFILE}-${ALBUMFILE}.${OUTPUT}.m3u'
 VAPLAYLISTDATAPREFIX=''
 DOSPLAYLIST=n
 COMMENT=''
-ID3TAGV=2
+ID3TAGV=id3v2.4
 ENCNICE=10
 READNICE=10
 DISTMP3NICE=10
@@ -3196,27 +3415,37 @@ MP3ENC=mp3enc
 # ogg
 VORBIZE=vorbize
 OGGENC=oggenc
+#opus
+OPUSENC=opusenc
 # flac
 FLAC=flac
 # speex
 SPEEXENC=speexenc
-# mpp (Musepack)
-MPPENC=mppenc
+# mpc (Musepack)
+MPCENC=mpcenc
+# wv (wavpack)
+WVENC=wavpack
+# ape
+APENC=mac
+APETAG=apetag
 # m4a
-AACENC=faac
+FAAC=faac
+NEROAACENC=neroAacEnc
+FDKAAC=fdkaac
 
 ID3=id3
 ID3V2=id3v2
 EYED3=eyeD3
 VORBISCOMMENT=vorbiscomment
 METAFLAC=metaflac
-AACTAG=faac
-ATOMICPARSLEY=AtomicParsley
+NEROAACTAG=neroAacTag
 
 CDPARANOIA=cdparanoia
+CD_PARANOIA=cd-paranoia
 CDDA2WAV=icedax
 DAGRAB=dagrab
 CDDAFS=cp
+PIRD=pird
 CDDISCID=cd-discid
 CDDBTOOL=cddb-tool
 MUSICBRAINZ=abcde-musicbrainz-tool
@@ -3227,11 +3456,20 @@ NORMALIZE=normalize-audio
 CDSPEED=eject
 VORBISGAIN=vorbisgain
 MP3GAIN=mp3gain
-MPPGAIN=replaygain
+MPCGAIN=mpcgain
+WVGAIN=wvgain
+# For Wavpack replay gain we set both the default of 'track gain' 
+# as well as this option for 'album gain'. Better media players
+# such as vlc can select either or neither.              Andrew.     
+WVGAINOPTS='-a'
 MKCUE=mkcue
 MKTOC=cdrdao
 DIFF=diff
 CUE2DISCID=builtin
+GLYRC=glyrc
+IDENTIFY=identify
+CONVERT=convert
+DISPLAYCMD=display
 
 # Options for programs called from abcde
 # mp3
@@ -3247,19 +3485,35 @@ MP3GAINOPTS="-a -k"
 VORBIZEOPTS=
 OGGENCOPTS=
 VORBISGAINOPTS="--album"
+#opus
+OPUSENCOPTS=
 # flac
-FLACOPTS=
+# The flac option is a workaround for an error where flac fails
+# to encode with error 'floating point exception'. This is flac 
+# error in get_console_width(), corrected in flac 1.3.1
+FLACOPTS="--silent"
 FLACGAINOPTS="--add-replay-gain"
 # speex
 SPEEXENCOPTS=
 # mpc
-MPPENCOPTS=
+MPCENCOPTS=
+# wv
+WVENCOPTS=
+# ape
+# Monkey's Audio Console (mac) chokes without a mode setting
+# so we set one here.
+APENCOPTS='-c4000'
 # m4a
-AACENCOPTS=
+FAACENCOPTS=
+NEROACENCOPTS=
+# fdkaac chokes without either a bitrate or bitrate-mode specified so 
+# we set bitrate here.
+FDKAACENCOPTS='--bitrate 192k'
 
 ID3OPTS=
-ID3V2OPTS=
+EYED3OPTS=""
 CDPARANOIAOPTS=
+PIRDOPTS=
 CDDA2WAVOPTS=
 DAGRABOPTS=
 CDDAFSOPTS="-f"
@@ -3274,6 +3528,15 @@ MKTOCOPTS=""
 VORBISCOMMENTOPTS="-R"
 METAFLACOPTS="--no-utf8-convert"
 DIFFOPTS=
+GLYRCOPTS=
+IDENTIFYOPTS=
+CONVERTOPTS=
+DISPLAYCMDOPTS="-resize 512x512 -title abcde_album_art"
+
+# Defaults for album art downloads
+ALBUMARTFILE="cover.jpg"
+ALBUMARTTYPE="JPEG"
+ALBUMARTALWAYSCONVERT="n"
 
 # Default to one process if -j isn't specified
 MAXPROCS=1
@@ -3283,16 +3546,10 @@ ACTIONS=cddb,read,encode,tag,move,clean
 
 # This option is basically for Debian package dependencies:
 # List of preferred outputs - by default, run with whatever we have in the path
-DEFAULT_OUTPUT_BINARIES=vorbis:oggenc,flac:flac,mp3:toolame,mp3:lame,mp3:bladeenc,spx:speex,m4a:faac
+DEFAULT_OUTPUT_BINARIES=vorbis:oggenc,flac:flac,mp3:toolame,mp3:lame,mp3:bladeenc,spx:speex,m4a:faac:opus
 
 # List of preferred cdromreaders - by default, run whichever we have in the path
-DEFAULT_CDROMREADERS="cdparanoia icedax cdda2wav"
-
-# List of quality levels associated with the encoders:
-DEFAULT_QUALITY_XLO="oggenc:-q -1,lame:-q 9,speex:--quality 1,m4a:"
-DEFAULT_QUALITY_LO="oggenc:-q 1,lame:-q 7,speex:--quality 5,m4a:"
-DEFAULT_QUALITY_HI="oggenc:-q 7,lame:--preset standard,speex:--quality 9,m4a:"
-DEFAULT_QUALITY_XHI="oggenc:-q 10,lame:--preset extreme,speex:--quality 10,m4a:"
+DEFAULT_CDROMREADERS="cdparanoia icedax cdda2wav libcdio pird"
 
 # Assume fetch if under FreeBSD. curl is used for Mac OS X. wget is used for
 # Linux/OpenBSD. ftp is user for NetBSD.
@@ -3309,6 +3566,8 @@ elif [ X$(uname) = "XDarwin" ] ; then
        # We should have diskutil in OSX, but let's be sure...
        NEEDDISKUTIL=y
        CDROMREADERSYNTAX=cddafs
+       # We won't find the eject program in OSX, and doing checkexec will fail further below...
+       unset EJECT
 elif [ X$(uname) = "XOpenBSD" ] ; then
        HTTPGET=wget
        MD5SUM=md5
@@ -3326,10 +3585,7 @@ else
 fi
 
 # If CDDBAVAIL is set to n, no CDDB read is done
-# If USEID3 is set to n, no ID3 tagging is done
 CDDBAVAIL=y
-USEID3=y
-USEID3V2=y
 
 # There we go..
 # But before we get into business, let us chop off any GREP environmental
@@ -3373,7 +3629,7 @@ fi
 if [ "$CDROM" = "" ] ; then
        if [ -e /dev/cdroms/cdrom0 ]; then
                CDROM=/dev/cdroms/cdrom0
-       elif [ "$OSFLAVOUR" = "OSX" ] && [[ $(diskutil list) =~ CD_part.*(disk.)$'\n' ]]; then
+       elif [ "$OSFLAVOUR" = "OSX" ] && [[ $(diskutil list) =~ CD_part[^/]*(disk.)$'\n' ]]; then
                CDROM=/dev/${BASH_REMATCH[1]}
        elif [ -e /dev/cdrom ]; then
                CDROM=/dev/cdrom
@@ -3389,24 +3645,24 @@ if [ "$CDROM" = "" ] ; then
 fi
 
 # We used to use EXTRAVERBOSE=y to turn on more debug output. Now
-# that's changed to a number to allow for more control. If
-# EXTRAVERBOSE=y, set it to 1 for backwards compatibility.
-if [ "$EXTRAVERBOSE" = "y" ]; then
-       EXTRAVERBOSE=1
-fi
-if [ "$EXTRAVERBOSE" = "n" ]; then
-       EXTRAVERBOSE=0
-fi
+# that's changed to a number to allow for more control. Deal with
+# EXTRAVERBOSE=y/n, set it to 1/0 for backwards compatibility.
+case "$EXTRAVERBOSE" in
+       *y*|*Y*)
+               EXTRAVERBOSE=1
+               ;;
+       *n*|*N*)
+               EXTRAVERBOSE=0
+               ;;
+esac
 
 # Parse command line options
-#while getopts 1a:bc:C:d:Dehj:klLmMnNo:pPq:r:Rs:S:t:T:vVxw:W: opt ; do
-while getopts 1a:bBc:C:d:Defghj:klLmMnNo:pPq:r:s:S:t:T:UvVxX:w:W:z opt ; do
+while getopts 1a:bc:C:d:DefgGhj:klLmMnNo:pPr:s:S:t:T:UvVxX:w:W:z opt ; do
        case "$opt" in
                1) ONETRACK=y ;;
                a) ACTIONS="$OPTARG" ;;
                A) EXPACTIONS="$OPTARG" ;;
                b) BATCHNORM=y ;;
-               B) NOBATCHREPLAYGAIN=y ;;
                c) if [ -e "$OPTARG" ] ; then . "$OPTARG" ; else log error "config file \"$OPTARG\" cannot be found." ; exit 1 ; fi ;;
                C) DISCID="$( echo ${OPTARG#abcde.} | tr -d /)" ;;
                d) CDROM="$OPTARG" ;;
@@ -3416,6 +3672,7 @@ while getopts 1a:bBc:C:d:Defghj:klLmMnNo:pPq:r:s:S:t:T:UvVxX:w:W:z opt ; do
                E) ENCODING="$OPTARG" ;;
                f) FORCE=y ;;
                g) NOGAP=y ;;
+               G) GETALBUMART=y ;;
                i) INLINETAG=y ;;
                j) MAXPROCS="$OPTARG" ;;
                k) KEEPWAVS=y ;;
@@ -3428,7 +3685,6 @@ while getopts 1a:bBc:C:d:Defghj:klLmMnNo:pPq:r:s:S:t:T:UvVxX:w:W:z opt ; do
                o) OUTPUTTYPE="$OPTARG" ;;
                p) PADTRACKS=y ;;
                P) USEPIPES=y ;;
-               q) QUALITYLEVEL="$OPTARG" ;;
                r) REMOTEHOSTS="$OPTARG" ;;
                R) CDDBLOCALRECURSIVE=y ;;
                s) SHOWCDDBFIELDS="$OPTARG" ;;
@@ -3447,7 +3703,7 @@ while getopts 1a:bBc:C:d:Defghj:klLmMnNo:pPq:r:s:S:t:T:UvVxX:w:W:z opt ; do
                X) CUE2DISCID="$OPTARG" ;;
                w) COMMENT="$OPTARG" ;;
                W) if echo $OPTARG | grep "[[:digit:]]" > /dev/null 2>&1 ; then
-                        STARTTRACKNUMBER="${OPTARG}01"
+                        STARTTRACKNUMBER="${OPTARG}$(printf %02d ${STARTTRACKNUMBER:-01})"
                         STARTTRACKNUMBERTAG="y"
                         COMMENT="CD${OPTARG}"
                         DISCNUMBER="${OPTARG}"
@@ -3512,8 +3768,9 @@ if [ "$ONETRACK" = "y" ]; then
        # FIXME # remove check as soon as we find out about the other readers
        case "$CDROMREADERSYNTAX" in
                flac) ;;
-               cdparanoia) ;;
+               cdparanoia | libcdio) ;;
                cdda2wav | icedax) ;;
+               pird) ;;
                *) log error "$CDROMREADERSYNTAX does not support ONETRACK mode"
                        exit 1 ;;
        esac
@@ -3584,6 +3841,7 @@ do
                replaygain) DOCDDB=y; DOREAD=y; DOENCODE=y; DOTAG=y; DOMOVE=y; DOREPLAYGAIN=y;;
                playlist) DOCDDB=y; DOPLAYLIST=y;;
                clean) DOCLEAN=y;;
+               getalbumart) GETALBUMART=y;;
        esac
 done
 
@@ -3700,6 +3958,12 @@ case "$CDROMREADERSYNTAX" in
                CDROMREADER="$CDPARANOIA"
                CDROMREADEROPTS="$CDPARANOIAOPTS"
                ;;
+       libcdio)
+               # GNU's libcdio package will use cd-paranoia but I believe will be happy with
+               # the standard cdparanoia options. If I am wrong this will need to be fixed :).
+               CDROMREADER="$CD_PARANOIA"
+               CDROMREADEROPTS="$CDPARANOIAOPTS"
+               ;;
        cdda2wav | icedax)
                CDROMREADER="$CDDA2WAV"
                CDROMREADEROPTS="$CDDA2WAVOPTS"
@@ -3708,6 +3972,10 @@ case "$CDROMREADERSYNTAX" in
                CDROMREADER="$DAGRAB"
                CDROMREADEROPTS="$DAGRABOPTS"
                ;;
+       pird)
+               CDROMREADER="$PIRD"
+               CDROMREADEROPTS="$PIRDOPTS"
+               ;;
        cddafs)
                CDROMREADER="$CDDAFS"
                CDROMREADEROPTS="$CDDAFSOPTS"
@@ -3727,26 +3995,34 @@ case "$NORMALIZERSYNTAX" in
 esac
 
 # Allow -o OUTPUT(1):OPTIONS(1),...,OUTPUT(N):OPTIONS(N) mode of operation
-if echo "$OUTPUTTYPE" | grep ":" > /dev/null 2>&1 ; then
-       for OUTPUT in "$(echo "$OUTPUTTYPE" | tr \  \|| tr , \ | tr \| \ )"; do
+case "$OUTPUTTYPE" in *:*)
+       for OUTPUT in $(echo "$OUTPUTTYPE" | tr \  \|| tr , \ ); do
+               OUTPUT="$(echo "$OUTPUT" | tr \| \ )"
                case "$OUTPUT" in
                        vorbis:*|ogg:*) OGGENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;;
+                       opus:*) OPUSENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;;
                        mp3:*)  MP3ENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;;
                        flac:*) FLACENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;;
                        spx:*)  SPEEXENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;;
-                       mpc:*)  MPPENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;;
-                       m4a:*)  AACENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;;
+                       mpc:*)  MPCENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;;
+                       wv:*)   WVENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;;
+                       ape:*)  APENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;;
+                       m4a:*|aac:*)  AACENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;;
                esac
        done
-       for OUTPUT in "$(echo "$OUTPUTTYPE" | tr , \ )"; do
-               TEMPOUTPUT=$( echo "$OUTPUT" | cut -d: -f1 )
+       # Allows commandline selection of options while using multiple outputs.
+       # Example: abcde -o 'flac:-8,mp3:-b 320'       Patch by Matthias Andree.           
+       for OUTPUT in $(echo "$OUTPUTTYPE" | tr -d '    ' | tr , ' '); do
+               TEMPOUTPUT=${OUTPUT%%:*}
                TEMPOUTPUTTYPE="${TEMPOUTPUTTYPE:+$TEMPOUTPUTTYPE,}$TEMPOUTPUT"
        done
        OUTPUTTYPE="$TEMPOUTPUTTYPE"
-fi
+       ;;
+esac
 
 # If nothing has been specified, use oggenc for oggs and lame for mp3s and flac
-# for flacs and speexenc for speex and mppenc for mpps and faac for m4as
+# for flacs and speexenc for speex and mpcenc for mpcs and faac for m4as and
+# wavpack for wvs...
 
 # Getting ready for multiple output changes
 for OUTPUT in $(echo $OUTPUTTYPE | tr , \ )
@@ -3758,6 +4034,10 @@ do
                        [ "$DOREPLAYGAIN" = "y" ] && NEEDVORBISGAIN=y
                        OGGOUTPUTCONTAINER=ogg
                        ;;
+               opus)
+                       [ "$OPUSENCODERSYNTAX" = "default" ] && OPUSENCODERSYNTAX=opusenc
+                       OPUSOUTPUTCONTAINER=opus
+                       ;;
                mp3)
                        [ "$MP3ENCODERSYNTAX" = "default" ] && MP3ENCODERSYNTAX=lame
                        [ "$DOTAG" = "y" ] && NEEDTAGGER=y
@@ -3774,12 +4054,28 @@ do
 #                      [ "$DOREPLAYGAIN" = "y" ] &&
                        ;;
                mpc)
-                       [ "$MPPENCODERSYNTAX" = "default" ] && MPPENCODERSYNTAX=mppenc
-                       [ "$DOREPLAYGAIN" = "y" ] && NEEDMPPGAIN=y
+                       [ "$MPCENCODERSYNTAX" = "default" ] && MPCENCODERSYNTAX=mpcenc
+                       [ "$DOREPLAYGAIN" = "y" ] && NEEDMPCGAIN=y
+                       ;;
+               wv)
+                       [ "$WVENCODERSYNTAX" = "default" ] && WVENCODERSYNTAX=wavpack
+                       [ "$DOTAG" = "y" ]
+                       [ "$DOREPLAYGAIN" = "y" ] && NEEDWVGAIN=y
+                       ;;
+               ape)
+                       [ "$APENCODERSYNTAX" = "default" ] && APENCODERSYNTAX=mac
+                       [ "$DOTAG" = "y" ] && NEEDAPETAG=y
+                       ;;
+               aac)
+                       [ "$AACENCODERSYNTAX" = "default" ] && AACENCODERSYNTAX=faac
+                       [ "$DOTAG" = "n" ]
+               # Neither Faac nor AtomicParsley can tag the .aac files which are used for faac
+               # compiled without libmp4v2... Andrew.
                        ;;
                m4a)
                        [ "$AACENCODERSYNTAX" = "default" ] && AACENCODERSYNTAX=faac
-                       [ "$DOTAG" = "y" ] && CHECKATOMICPARSLEY=y
+                       [ "$DOTAG" = "y" ] && CHECKFAACBUILD=y
+                       [ "$AACENCODERSYNTAX" = "neroAacEnc" ] && NEEDNEROAACTAG=y
                        ;;
                wav)
                        if [ "$KEEPWAVS" = "y" ]; then
@@ -3834,10 +4130,16 @@ case "$OGGENCODERSYNTAX" in
                OGGENCODER="$OGGENC"
                ;;
 esac
+case "$OPUSENCODERSYNTAX" in
+       opusenc)
+               OPUSENCODEROPTS="${OPUSENCODEROPTSCLI:-$OPUSENCOPTS}"
+               OPUSENCODER="$OPUSENC"
+               ;;
+esac
 case "$FLACENCODERSYNTAX" in
        flac)
                FLACENCODEROPTS="${FLACENCODEROPTSCLI:-$FLACOPTS}"
-               FLACENCODER="$FLAC"     
+               FLACENCODER="$FLAC"
                if [ "$DOREPLAYGAIN" = "y" ]; then
                        FLACENCODEROPTS="${FLACENCODEROPTS} --replay-gain"
                fi
@@ -3858,29 +4160,94 @@ case "$SPEEXENCODERSYNTAX" in
                SPEEXENCODER="$SPEEXENC"
                ;;
 esac
-case "$MPPENCODERSYNTAX" in
-       mppenc)
-               MPPENCODEROPTS="${MPPENCODEROPTSCLI:-$MPPENCOPTS}"
-               MPPENCODER="$MPPENC"
+case "$MPCENCODERSYNTAX" in
+       mpcenc)
+               MPCENCODEROPTS="${MPCENCODEROPTSCLI:-$MPCENCOPTS}"
+               MPCENCODER="$MPCENC"
+               ;;
+esac
+case "$WVENCODERSYNTAX" in
+       wavpack)
+               WVENCODEROPTS="${WVENCODEROPTSCLI:-$WVENCOPTS}"
+               WVENCODER="$WVENC"
+               ;;
+esac
+case "$APENCODERSYNTAX" in
+       mac)
+               APENCODEROPTS="${APENCODEROPTSCLI:-$APENCOPTS}"
+               APENCODER="$APENC"
                ;;
 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.
        faac)
-               AACENCODEROPTS="${AACENCODEROPTSCLI:-$AACENCOPTS}"
-               AACENCODER="$AACENC"
+               if [ -z "$FAACENCOPTS" ] && [ -n "$AACENCOPTS" ]; then
+                       AACENCODEROPTS="${AACENCODEROPTSCLI:-$AACENCOPTS}"
+                       AACENCODER="$FAAC"
+               else
+                       AACENCODEROPTS="${AACENCODEROPTSCLI:-$FAACENCOPTS}"
+                       AACENCODER="$FAAC"
+               fi
+               ;;
+       neroAacEnc)
+               if [ -z "$NEROAACENCOPTS" ] && [ -n "$AACENCOPTS" ]; then
+                       AACENCODEROPTS="${AACENCODEROPTSCLI:-$AACENCOPTS}"
+                       AACENCODER="$NEROAACENC"
+               else        
+                       AACENCODEROPTS="${AACENCODEROPTSCLI:-$NEROAACENCOPTS}"
+                       AACENCODER="$NEROAACENC"
+               fi
+               ;;
+       fdkaac)
+               if [ -z "$FDKAACENCOPTS" ] && [ -n "$AACENCOPTS" ]; then
+                       AACENCODEROPTS="${AACENCODEROPTSCLI:-$AACENCOPTS}"
+                       AACENCODER="$FDKAAC"
+               else
+                       AACENCODEROPTS="${AACENCODEROPTSCLI:-$FDKAACENCOPTS}"
+                       AACENCODER="$FDKAAC"
+               fi
                ;;
 esac
 
 # and which tagger
-if [ "$ID3TAGV" = "1" ]; then
-       TAGGER="$ID3"
-       TAGGEROPTS="$ID3OPTS"
-else
-       TAGGER="$EYED3"
-       TAGGEROPTS="$ID3V2OPTS"
-       ID3SYNTAX=eyed3
-       TAGGEROPTS="--set-encoding=utf16-LE $ID3V2OPTS"
-fi
+case "$ID3TAGV" in
+       id3v1)
+               TAGGER="$ID3"
+               ID3SYNTAX=id3
+               TAGGEROPTS="$ID3OPTS"
+               ;;
+       id3v2.3)
+               TAGGER="$ID3V2"
+               ID3SYNTAX=id3v2
+               TAGGEROPTS="$ID3V2OPTS"
+               ;;
+       id3v2.4)
+               TAGGER="$EYED3"
+               # Note that eyeD3 is set to tag in utf-16 (below). This causes
+               # trouble with CDDBPROTO=5 (which we test here) but also
+               # with cached cddb files in latin1 (which we cannot test).
+               if [ "$CDDBPROTO" -lt 6 ]; then
+                       log warning "You cannot have id3v2.4 tags encoded in latin1. Setting CDDBPROTO to 6 for now."
+                       CDDBPROTO=6
+               fi
+               # eyeD3 version 0.7 changed syntax
+               if $EYED3 --help 2>&1 | grep -q -- --set-encoding ; then
+                       # only if it offers the --set-encoding, assume <= 0.6.x
+                       ID3SYNTAX=eyed3_06
+                       TAGGEROPTS="--set-encoding utf16-LE $EYED3OPTS"
+               else
+                       # anything wrong, any failure, assume >= 0.7
+                       ID3SYNTAX=eyed3
+                       TAGGEROPTS="--encoding utf16 $EYED3OPTS"
+               fi
+               ;;
+       *)
+               log error "Error: ID3TAGV must be either \"id3v1\", \"id3v2.3\" or \"id3v2.4\""
+               exit 1
+               ;;
+esac
 
 # NOGAP is specific to lame. Other encoders fail ...
 if [ "$NOGAP" = "y" ] && [ ! "$MP3ENCODER" = "lame" ]; then
@@ -3947,27 +4314,46 @@ fi
 
 if [ X"$CDSPEEDVALUE" != "X" ] && [ "$DOREAD" = "y" ]; then
        case "$CDROMREADERSYNTAX" in
-               cdparanoia|debug) CDROMREADEROPTS="$CDPARANOIAOPTS -S $CDSPEEDVALUE" ;;
+               cdparanoia|libcdio|debug) CDROMREADEROPTS="$CDPARANOIAOPTS -S $CDSPEEDVALUE" ;;
+               pird) CDROMREADEROPTS="$PIRDOPTS -s $CDSPEEDVALUE" ;;
                ### FIXME ### translate "cue2discid" from python to bash
                flac) NEEDMETAFLAC=y ; NEEDCUE2DISCID=y ; CDSPEEDVALUE="" ;;
                *) NEEDCDSPEED=y ;;
        esac
 fi
 
+if [ "$GETALBUMART" = "y" ]; then
+       NEEDHTTPGET="y"
+       NEEDGLYRC="y"
+fi
+
 ###USEPIPESSUPPORT###
 
 # Rippers with USEPIPE support
-# FIXME # Include here all the rippers we can figure out support pipes
 PIPERIPPER_cdparanoia="-"
+PIPERIPPER_libcdio="-"
+# Note that by default in abcde cdda2wav redirects to icedax.        
+PIPERIPPER_cdda2wav="-"
 PIPERIPPER_debug="-"
 PIPERIPPER_flac="-c "
+PIPERIPPER_pird="-"
 
 # Encoders with USEPIPE support
-# FIXME # Include here all the encoders we can figure out support pipes
+PIPE_mp3enc="-sti"
 PIPE_lame="-"
-PIPE_bladeenc="-"
+PIPE_bladeenc="stdin"
 PIPE_oggenc="-"
+PIPE_opusenc="-"
 PIPE_flac="-"
+PIPE_speexenc="-"
+PIPE_mpcenc="-"
+PIPE_wavpack="-"
+PIPE_faac="-"
+# Both neroAacEnc and fdkaac seem to manage without the addition of
+# the 'ignorelength' option in PIPE_$AACENCODERSYNTAX when piping
+# in this manner.                                           Andrew.
+PIPE_neroAacEnc="-"
+PIPE_fdkaac="-"
 
 # Figure out if we can use pipes with the ripper/encoder combination
 # exit otherwise
@@ -3978,53 +4364,68 @@ if [ "$USEPIPES" = "y" ]; then
                        PIPEENCODERSVARCHECK="PIPE_$MP3ENCODERSYNTAX" ;;
                vorbis|ogg)
                        PIPEENCODERSVARCHECK="PIPE_$OGGENCODERSYNTAX" ;;
+               opus)
+                       PIPEENCODERSVARCHECK="PIPE_$OPUSENCODERSYNTAX" ;;
                flac)
                        PIPEENCODERSVARCHECK="PIPE_$FLACENCODERSYNTAX" ;;
                spx)
-                       PIPEENCODERSVARCHECK="PIPE_$SPEEXENCODER" ;;
+                       PIPEENCODERSVARCHECK="PIPE_$SPEEXENCODERSYNTAX" ;;
                mpc)
-                       PIPEENCODERSVARCHECK="PIPE_$MPPENCODER" ;;
+                       PIPEENCODERSVARCHECK="PIPE_$MPCENCODERSYNTAX" ;;
+               wv)
+                       PIPEENCODERSVARCHECK="PIPE_$WVENCODERSYNTAX" ;;
+               m4a)
+                       PIPEENCODERSVARCHECK="PIPE_$AACENCODERSYNTAX" ;;
+               aac)
+                       PIPEENCODERSVARCHECK="PIPE_$AACENCODERSYNTAX" ;;
        esac
        decho "PIPERIPPERSVARCHECK: $( eval echo "\$$PIPERIPPERSVARCHECK" )"
        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
 
 # Make sure a buncha things exist
 for X in $CDROMREADER $CDDISCID ${NEEDTAGGER+$TAGGER} $MP3ENCODER \
-       $OGGENCODER $FLACENCODER $SPEEXENCODER $MPPENCODER \
-       $AACENCODER $CDDBTOOL \
-       ${NEEDATOMICPARSLEY+$ATOMICPARSLEY} \
+       $OGGENCODER $OPUSENCODER $FLACENCODER $SPEEXENCODER $MPCENCODER \
+       $AACENCODER $WVENCODER $CDDBTOOL $APENCODER \
        ${NEEDHTTPGET+$HTTPGET} ${NEEDDISTMP3+$DISTMP3} \
        ${NEEDCOMMENTER+$VORBISCOMMENT} ${NEEDMETAFLAC+$METAFLAC} \
        ${NEEDNORMALIZER+$NORMALIZER} ${NEEDEJECT+$EJECT} \
        ${NEEDDISKUTIL+diskutil} ${NEEDCDSPEED+$CDSPEED} \
        ${NEEDVORBISGAIN+$VORBISGAIN} ${NEEDMP3GAIN+$MP3GAIN} \
-       ${NEEDMPPGAIN+$MPPGAIN} ${NEEDCUEREADER+$CUEREADER} \
-       ${NEEDCUE2DISCID+$CUE2DISCID}
+       ${NEEDMPCGAIN+$MPCGAIN} ${NEEDCUEREADER+$CUEREADER} \
+       ${NEEDWVGAIN+WVGAIN} ${NEEDAPETAG+$APETAG} \
+       ${NEEDCUE2DISCID+$CUE2DISCID} ${NEEDNEROAACTAG+$NEROAACTAG} \
+       ${NEEDGLYRC+$GLYRC}
 do
        checkexec "$X"
 done
 
-if [ "$CHECKATOMICPARSLEY" = "y" ]; then
-       if ! new_checkexec "$ATOMICPARSLEY"; then
-               echo "WARNING: $ATOMICPARSLEY Not Found Not Post-Tagging!"
-               DOTAG='n'
+# Under Debian and Ubuntu faac is compiled without libmp4v2 which means no support
+# for the mp4 container and no tagging capability. (AtomicParsley also cannot tag
+# these files). The resulting files are actually ADTS streams which belong in an 
+# aac container and with some version sniffing this is all cleaned up below. If
+# faac is compiled with libmp4v2 inline tagging occurs with faac.
+
+# FIXME: Should this be in this location? (Better incorporated into the checks above.)
+if [ "$CHECKFAACBUILD" = "y" ] && [ "$AACENCODERSYNTAX" = "faac" ] ; then
+       if faac --help 2>&1 | grep -q -F 'MP4 support unavailable.'; then 
+               echo "WARNING: Your copy of Faac does not have mp4 support"
+               echo "WARNING: Encoding untagged files to aac..."
+               OUTPUTTYPE=aac
        else
-               echo "Using $ATOMICPARSLEY To Tag AAC Tracks."
+               echo "Using Faac to Tag AAC Tracks..."
        fi
 fi
 
@@ -4109,7 +4510,8 @@ fi
 
 if [ X"$CDSPEEDVALUE" != "X" ]; then
        case "$CDROMREADERSYNTAX" in
-               cdparanoia|debug) ;;
+               cdparanoia|libcdio|debug) ;;
+               pird) ;;
                flac) ;;
                *) do_cdspeed ;;
        esac
@@ -4145,6 +4547,10 @@ if [ ! "$ONETRACK" = "y" ]; then
        fi
 fi
 
+if [ "$GETALBUMART" = "y" ]; then
+       do_getalbumart
+fi
+
 # For the lowdisk option, only one program is running at once so the encoder
 # can be unsilenced right away.
 if [ "$LOWDISK" = "y" ] || [ "$ONETRACK" = "y" ]; then
@@ -4223,7 +4629,7 @@ post_read
 
 # We are now finished with the cdrom - it can be safely ejected. Note that
 # abcde will not have completed yet.
-if [ "$EJECTCD" = "y" ] && [ -x $(which $EJECT) ]; then
+if [ "$EJECTCD" = "y" ]; then
        # We check if the disk we are processing is actually the disk inside the
        # CD tray. If not, we do not eject the CD, since it might be so that the
        # user ejected it manually.
@@ -4240,7 +4646,7 @@ if [ "$EJECTCD" = "y" ] && [ -x $(which $EJECT) ]; then
                $eject $EJECTOPTS $cd
        elif [ X"$(uname)" = X"Darwin" ] ; then
                diskutil eject ${CDROM#/dev/} 0
-       else
+    elif [ -x $(which $EJECT) ]; then
                $EJECT $EJECTOPTS "$CDROM"
        fi
        #fi