X-Git-Url: https://git.hcoop.net/clinton/abcde.git/blobdiff_plain/1a064efbc8a90d7cd31185b1f7a2c816ec817c8c..cb8015449a7e31b1fff05da8a9698ff13389b564:/abcde diff --git a/abcde b/abcde index 55951fc..7925440 100755 --- a/abcde +++ b/abcde @@ -11,7 +11,7 @@ # Copyright for this work is to expire January 1, 2010, after which it # shall be public domain. -VERSION="2.3.99-$Id$" +VERSION="2.3.99" usage () { @@ -28,10 +28,11 @@ echo " Specify a configuration file (overrides system and user config file echo "-C " echo " Specify discid to resume from (only needed if you no longer have the cd)" echo "-d " -echo " Specify CDROM device to grab" +echo " Specify CDROM device to grab (flac uses a single-track flac file)" echo "-D Debugging mode (equivalent to sh -x abcde)" echo "-e Erase encoded track information from status file" #echo "-E Set the encoding information for the tags" +echo "-f Force operations that otherwise are considered harmful. Read \"man abcde\"" echo "-h This help information" #echo "-i Tag files while encoding, when possible (local only) -NWY-" echo "-j <#> Number of encoder processes to run at once (localhost)" @@ -43,7 +44,7 @@ echo "-N Noninteractive. Never prompt for anything" echo "-m Modify playlist to include CRLF endings, to comply with some players" echo "-M Create a CUE file" echo "-o " -echo " Output file type(s) (vorbis,mp3,flac,spx,mpc). Defaults to vorbis" +echo " Output file type(s) (vorbis,mp3,flac,spx,mpc,wav). Defaults to vorbis" echo "-p Pad track numbers with 0's (if less than 10 tracks)" echo "-P Use UNIX pipes to read+encode without wav files" echo "-r " @@ -62,6 +63,7 @@ echo "-x Eject CD after all tracks are read" echo "-w " echo " Add a comment to the CD tracks" echo "-W <#> Contatenate CDs: -T #01 -w \"CD #\"" +echo "-z Use debug CDROMREADERSYNTAX option (needs cdparanoia)" echo "" echo "Tracks is a space-delimited list of tracks to grab." echo "Ranges specified with hyphens are allowed (i.e., 1-5)." @@ -83,12 +85,17 @@ f_seq_row () f_seq_line () { i=$1 - while [ $i -ne `expr $2 + 1` ] - do - printf $i" " - i=`expr $i + 1` - done - echo + if echo i | grep -q "[[:digit:]]" ; then + while [ $i -ne `expr $2 + 1` ] + do + printf $i" " + i=`expr $i + 1` + done + echo + else + echo "abcde: syntax error while processing track numbers" >&2 + exit 1 + fi } # Functions to replace the need of awk {print $1} and {print $NF} @@ -139,6 +146,29 @@ checkstatus () fi } +# chechwarnings [blurb] +# Returns "0" if the blurb was found (meaning there was an warning), +# returns 1 if it wasn't (yes this is a little backwards). +# Does not print the blurb on stdout. +# Otherwise, returns "". +checkwarnings () +{ + if [ -e "$ABCDETEMPDIR/warnings" ]; then :; else + return 1 + fi + # Take the last line in the status file if there's multiple matches + PATTERN="^$1(:.*)?$" + BLURB="$(egrep $PATTERN "$ABCDETEMPDIR/warnings" | tail -n 1)" + + if [ -z "$BLURB" ]; then + # negative, we did not have a negative... + return 1 + else + # affirmative, we had a negative... + return 0 + fi +} + # checkerrors [blurb] # Returns "0" if the blurb was found (meaning there was an error), # returns 1 if it wasn't (yes this is a little backwards). @@ -315,34 +345,50 @@ do_gettracknum() do_replaygain() { - run_command "" echo "Adding reply-gain information..." - for OUTPUT in $( echo $OUTPUTTYPE | tr , \ ) - do - OUTPUTFILES="" - for UTRACKNUM in $TRACKQUEUE + if checkstatus replaygain; then :; else + run_command "" echo "Adding replygain information..." + for OUTPUT in $( echo $OUTPUTTYPE | tr , \ ) + # THE OUTPUT NEEDS TO BE CORRECTED WITH THE CONTAINER? do - CDDBTRACKNUM=$(expr $UTRACKNUM - 1) - do_getcddbinfo TRACKNAME - splitvarious - TRACKFILE=$(mungefilename "$TRACKNAME") - ARTISTFILE=$(mungefilename "$TRACKARTIST") - ALBUMFILE=$(mungefilename "$DALBUM") - do_gettrucknum - if [ "$VARIOUSARTISTS" = "y" ]; then - OUTPUTFILE=$(eval echo $VAOUTPUTFORMAT) - else - OUTPUTFILE=$(eval echo $OUTPUTFORMAT) - fi - OUTPUTFILES="$OUTPUTDIR/$OUTPUTFILE.$OUTPUT $OUTPUTFILES" + case $OUTPUT in + vorbis|ogg) + OUTPUT=$OGGOUTPUTCONTAINER + ;; + flac) + OUTPUT=$FLACOUTPUTCONTAINER + ;; + esac + OUTPUTFILES="" + for UTRACKNUM in $TRACKQUEUE + do + CDDBTRACKNUM=$(expr $UTRACKNUM - 1) + do_getcddbinfo TRACKNAME + splitvarious + TRACKFILE="$(mungefilename "$TRACKNAME")" + ARTISTFILE="$(mungefilename "$TRACKARTIST")" + ALBUMFILE="$(mungefilename "$DALBUM")" + do_gettracknum + if [ "$VARIOUSARTISTS" = "y" ]; then + OUTPUTFILE=$(eval echo $VAOUTPUTFORMAT) + else + OUTPUTFILE=$(eval echo $OUTPUTFORMAT) + fi + OUTPUTFILES="$OUTPUTDIR/$OUTPUTFILE.$OUTPUT $OUTPUTFILES" + done + case "$OUTPUT" in + flac) + run_command replaygain-flac $METAFLAC --add-replay-gain $OUTPUTFILES + ;; + vorbis|ogg) + run_command replaygain-vorbis $VORBISGAIN --album $OUTPUTFILES + ;; + *);; + esac done - case "$OUTPUT" in - flac);; - ogg);; - *);; - esac - echo vorbisgain-$OUTPUT >> "$ABCDETEMPDIR/status" - done - echo vorbisgain >> "$ABCDETEMPDIR/status" + if checkerrors replaygain-.{3,6}; then :; else + run_command replaygain true + fi + fi } # This code splits the a Various Artist track name from one of the following @@ -362,34 +408,34 @@ splitvarious () if [ "$VARIOUSARTISTS" = "y" ] && [ ! "$ONETRACK" = "y" ]; then case "$VARIOUSARTISTSTYLE" in forward) - DTITLEARTIST=$(echo "$TRACKNAME" | sed 's- / -~-g') - TRACKARTIST=$(echo "$DTITLEARTIST" | cut -f1 -d~) - TRACKNAME=$(echo "$DTITLEARTIST" | cut -f2 -d~) + DTITLEARTIST="$(echo "$TRACKNAME" | sed 's- / -~-g')" + TRACKARTIST="$(echo "$DTITLEARTIST" | cut -f1 -d~)" + TRACKNAME="$(echo "$DTITLEARTIST" | cut -f2 -d~)" ;; forward-dash) - DTITLEARTIST=$(echo "$TRACKNAME" | sed 's, - ,~,g') - TRACKARTIST=$(echo "$DTITLEARTIST" | cut -f1 -d~) - TRACKNAME=$(echo "$DTITLEARTIST" | cut -f2 -d~) + DTITLEARTIST="$(echo "$TRACKNAME" | sed 's, - ,~,g')" + TRACKARTIST="$(echo "$DTITLEARTIST" | cut -f1 -d~)" + TRACKNAME="$(echo "$DTITLEARTIST" | cut -f2 -d~)" ;; reverse) - DTITLEARTIST=$(echo "$TRACKNAME" | sed 's- / -~-g') - TRACKARTIST=$(echo "$DTITLEARTIST" | cut -f2 -d~) - TRACKNAME=$(echo "$DTITLEARTIST" | cut -f1 -d~) + DTITLEARTIST="$(echo "$TRACKNAME" | sed 's- / -~-g')" + TRACKARTIST="$(echo "$DTITLEARTIST" | cut -f2 -d~)" + TRACKNAME="$(echo "$DTITLEARTIST" | cut -f1 -d~)" ;; reverse-dash) - DTITLEARTIST=$(echo "$TRACKNAME" | sed 's, - ,~,g') - TRACKARTIST=$(echo "$DTITLEARTIST" | cut -f2 -d~) - TRACKNAME=$(echo "$DTITLEARTIST" | cut -f1 -d~) + DTITLEARTIST="$(echo "$TRACKNAME" | sed 's, - ,~,g')" + TRACKARTIST="$(echo "$DTITLEARTIST" | cut -f2 -d~)" + TRACKNAME="$(echo "$DTITLEARTIST" | cut -f1 -d~)" ;; colon) - DTITLEARTIST=$(echo "$TRACKNAME" | sed 's-: -~-g') - TRACKARTIST=$(echo "$DTITLEARTIST" | cut -f1 -d~) - TRACKNAME=$(echo "$DTITLEARTIST" | cut -f2 -d~) + DTITLEARTIST="$(echo "$TRACKNAME" | sed 's-: -~-g')" + TRACKARTIST="$(echo "$DTITLEARTIST" | cut -f1 -d~)" + TRACKNAME="$(echo "$DTITLEARTIST" | cut -f2 -d~)" ;; trailing-paren) - DTITLEARTIST=$(echo "$TRACKNAME" | sed 's,^\(.*\) (\(.*\)),\1~\2,') - TRACKARTIST=$(echo "$DTITLEARTIST" | cut -f2 -d~) - TRACKNAME=$(echo "$DTITLEARTIST" | cut -f1 -d~) + DTITLEARTIST="$(echo "$TRACKNAME" | sed 's,^\(.*\) (\(.*\)),\1~\2,')" + TRACKARTIST="$(echo "$DTITLEARTIST" | cut -f2 -d~)" + TRACKNAME="$(echo "$DTITLEARTIST" | cut -f1 -d~)" ;; esac elif [ "$VARIOUSARTISTS" = "y" ] && [ "$ONETRACK" = "y" ]; then @@ -566,14 +612,10 @@ return 0 do_tag () { COMMENTOUTPUT="$(eval echo ${COMMENT})" + CDDBDISCID=$(echo $TRACKINFO | cut -d' ' -f1) run_command '' echo "Tagging track $1 of $TRACKS: $TRACKNAME..." # If we want to start the tracks with a given number, we need to modify the # TRACKNUM value before evaluation -# if [ -n "$STARTTRACKNUMBER" -a -n "$STARTTRACKNUMBERTAG" ] ; then -# # Get the trackpadding from the current track -# CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c) -# TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK )) -# fi if [ -n "$STARTTRACKNUMBERTAG" ] ; then do_gettracknum fi @@ -667,11 +709,12 @@ do_tag () mpc) run_command tagtrack-$OUTPUT-$1 true ;; + wav) + run_command tagtrack-$OUTPUT-$1 true + ;; 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 @@ -703,7 +746,7 @@ do_batch_encode () else for UTRACKNUM in $TRACKQUEUE do - echo encodetrack-$UTRACKNUM >> status + run_command encodetrack-$UTRACKNUM true done fi ) @@ -746,6 +789,7 @@ do_encode () mp3) case "$MP3ENCODERSYNTAX" in # FIXME # check if mp3enc needs -if for pipes + # FIXME # I have not been able to find a working mp3enc binary mp3enc) FILEARG="-if $IN" ;; @@ -849,15 +893,19 @@ do_encode () ## FIXME ## to the encoder ends up empty. $RUN_COMMAND nice $ENCNICE $MPPENCODER $MPPENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" "$IN" "$OUT" ;; + wav) + # In case of wav output we need nothing. Just keep the wavs. + run_command encodetrack-$OUTPUT-$1 true + ;; esac done # Only remove .wav if the encoding succeeded - if checkerrors "encodetrack-(.{3,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" + if [ ! "$KEEPWAVS" = "move" ] ; then + rm -f "$IN" + fi fi fi else @@ -970,7 +1018,7 @@ do_batch_gain () do MP3FILES="$TRACKFILES track$UTRACKNUM.mp3" done - # XXX: Hard-coded batch option! + # FIXME # Hard-coded batch option! $NORMALIZER -b $NORMALIZEROPTS $TRACKFILES RETURN=$? if [ "$RETURN" != "0" ]; then @@ -1047,27 +1095,20 @@ do_move () # ''' -> '' # '?' -> '' # Eat control characters - ALBUMFILE=$(mungefilename "$DALBUM") - ARTISTFILE=$(mungefilename "$TRACKARTIST") - TRACKFILE=$(mungefilename "$TRACKNAME") - GENRE=$(mungegenre "$GENRE") - YEAR=$(echo $CDYEAR) + ALBUMFILE="$(mungefilename "$DALBUM")" + ARTISTFILE="$(mungefilename "$TRACKARTIST")" + TRACKFILE="$(mungefilename "$TRACKNAME")" + GENRE="$(mungegenre "$GENRE")" + YEAR="$(echo $CDYEAR)" # If we want to start the tracks with a given number, we need to modify the # TRACKNUM value before evaluation - # if [ -n "$STARTTRACKNUMBER" ] ; then - # # Get the trackpadding from the current track - # CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c) - # TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK )) - # else - # TRACKNUM=${UTRACKNUM} - # fi do_gettracknum # Supported variables for OUTPUTFORMAT are GENRE, ALBUMFILE, ARTISTFILE, # TRACKFILE, and TRACKNUM. if [ "$VARIOUSARTISTS" = "y" ]; then - OUTPUTFILE=$(eval echo $VAOUTPUTFORMAT) - else - OUTPUTFILE=$(eval echo $OUTPUTFORMAT) + OUTPUTFILE="$(eval echo "$VAOUTPUTFORMAT")" + else + OUTPUTFILE="$(eval echo "$OUTPUTFORMAT")" fi if checkerrors "tagtrack-$OUTPUT-$1"; then :; else # Once we know the specific output was successful, we can change the OUTPUT to the value containing the container @@ -1080,10 +1121,30 @@ do_move () ;; esac # Check that the directory for OUTPUTFILE exists, if it doesn't, create it - OUTPUTFILEDIR=$(dirname "$OUTPUTDIR/$OUTPUTFILE") - # mkdir -p shouldn't return an error if the directory already exists - mkdir -p "$OUTPUTFILEDIR" - run_command movetrack-$1 mv "$ABCDETEMPDIR/track$1.$OUTPUT" "$OUTPUTDIR/$OUTPUTFILE.$OUTPUT" + OUTPUTFILEDIR="$(dirname "$OUTPUTDIR/$OUTPUTFILE")" + case $OUTPUT in + wav) + if [ "$DOCLEAN" != "y" ] && [ "$FORCE" != "y" ]; then + # FIXME # introduce warnings? + : + else + # mkdir -p shouldn't return an error if the directory already exists + mkdir -p "$OUTPUTFILEDIR" + run_command movetrack-$1 mv "$ABCDETEMPDIR/track$1.$OUTPUT" "$OUTPUTDIR/$OUTPUTFILE.$OUTPUT" + if checkstatus movetrack-output-$OUTPUT; then :; else + run_command movetrack-output-$OUTPUT true + fi + fi + ;; + *) + # mkdir -p shouldn't return an error if the directory already exists + mkdir -p "$OUTPUTFILEDIR" + run_command movetrack-$1 mv "$ABCDETEMPDIR/track$1.$OUTPUT" "$OUTPUTDIR/$OUTPUTFILE.$OUTPUT" + if checkstatus movetrack-output-$OUTPUT; then :; else + run_command movetrack-output-$OUTPUT true + fi + ;; + esac # Lets move the cue file if CUEFILE=$(checkstatus cuefile) >/dev/null ; then if [ -r "$ABCDETEMPDIR/$CUEFILE" ]; then @@ -1092,6 +1153,14 @@ do_move () #run_command '' vecho "Copying cue file to its destination directory..." if checkstatus onetrack >/dev/null ; then case $OUTPUT in + wav) + if [ "$DOCLEAN" != "y" ] && [ "$FORCE" != "y" ]; then + # We dont have the dir, since it was not created before. + : + else + run_command movecue-$OUTPUT cp "$ABCDETEMPDIR/$CUEFILE" "$OUTPUTDIR/$OUTPUTFILE.cue" + fi + ;; # NOTE: Creating a cue file with the 3-char-extension files is to comply with # http://brianvictor.tripod.com/mp3cue.htm#details [a-z0-9][a-z0-9][a-z0-9]) @@ -1121,11 +1190,19 @@ 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 - ALBUMFILE=$(mungefilename "$DALBUM") - ARTISTFILE=$(mungefilename "$DARTIST") + ALBUMFILE="$(mungefilename "$DALBUM")" + ARTISTFILE="$(mungefilename "$DARTIST")" GENRE=$(mungegenre "$GENRE") YEAR=${CDYEAR:-$CDYEAR} if [ "$VARIOUSARTISTS" = "y" ] ; then @@ -1164,19 +1241,12 @@ do_playlist () #TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2 -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//') do_getcddbinfo TRACKNAME splitvarious - TRACKFILE=$(mungefilename "$TRACKNAME") - ARTISTFILE=$(mungefilename "$TRACKARTIST") - ALBUMFILE=$(mungefilename "$DALBUM") + TRACKFILE="$(mungefilename "$TRACKNAME")" + ARTISTFILE="$(mungefilename "$TRACKARTIST")" + ALBUMFILE="$(mungefilename "$DALBUM")" # If we want to start the tracks with a given number, we need to modify the # TRACKNUM value before evaluation - # if [ -n "$STARTTRACKNUMBER" ] ; then - # # Get the trackpadding from the current track - # CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c) - # TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK )) - # else - # TRACKNUM=${UTRACKNUM} - # fi - do_gettrucknum + do_gettracknum if [ "$VARIOUSARTISTS" = "y" ]; then OUTPUTFILE=$(eval echo $VAOUTPUTFORMAT) else @@ -1223,11 +1293,21 @@ do_discid () if [ "$OSFLAVOUR" = "OSX" ]; then disktool -u ${CDROM#/dev/} fi - TRACKINFO=$($CDDISCID $CDROM) + if [ "$CDROMREADERSYNTAX" = "flac" ] ; then + TRACKINFO=$($METAFLAC $METAFLACOPTS --export-cuesheet-to=- $CDROM | $CUE2DISCID) + else + TRACKINFO=$($CDDISCID $CDROM) + fi # Make sure there's a CD in there by checking cd-discid's return code - if [ "$?" = "1" ]; then - echo "abcde error: CD could not be read. Perhaps there's no CD in the drive?" >&2 - exit 1 + if [ ! "$?" = "0" ]; then + if [ "$CDROMREADERSYNTAX" = "flac" ] ; then + echo "abcde error: cuesheet information from the flac file could not be read." >&2 + echo "abcde error: Perhaps the flac file does not contain a cuesheet?." >&2 + exit 1 + else + echo "abcde error: CD could not be read. Perhaps there's no CD in the drive?" >&2 + exit 1 + fi fi # In OSX, remount the disc again if [ "$OSFLAVOUR" = "OSX" ]; then @@ -1262,12 +1342,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 @@ -1398,10 +1476,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 @@ -1413,7 +1489,6 @@ do_discid () # Create a proper CUE file based on the CUE file we created before. do_cleancue() { - # FIXME # we can get the name of the cuefile from the status file if CUEFILE_IN="$ABCDETEMPDIR"/$(checkstatus cuefile); then CUEFILE_OUT=$CUEFILE_IN.out ### FIXME ### checkstatus cddb @@ -2022,6 +2097,8 @@ do_cdread () LASTTRACK=$3 UTRACKNUM=$FIRSTTRACK case "$CDROMREADERSYNTAX" in + ### FIXME ### How are we calculating the tracks in flac mode? + flac) READTRACKNUMS="$FIRSTTRACK.1-$(($LASTTRACK + 1)).0" ;; cdparanoia) READTRACKNUMS="$FIRSTTRACK-$LASTTRACK" ;; cdda2wav) READTRACKNUMS="$FIRSTTRACK+$LASTRACK" ;; *) echo "abcde error: $CDROMREADERSYNTAX does not support ONETRACK mode" @@ -2039,7 +2116,10 @@ do_cdread () else WAVDATA="$ABCDETEMPDIR/track$UTRACKNUM.wav" case "$CDROMREADERSYNTAX" in - ## FIXME ## Find the case for dagrab, to avoid exceptions + ## FIXME ## Find the cases for dagrab and flac, to avoid exceptions + flac) + FILEARG="--output-name=$WAVDATA" + ;; dagrab) FILEARG="-f $WAVDATA" ;; @@ -2061,6 +2141,10 @@ do_cdread () fi fi case "$CDROMREADERSYNTAX" in + ### FIXME ### use an exception for flac, since it uses -o + ### FIXME ### Shall we just use -o $FILEARG ?? + flac) + nice $READNICE $FLAC -d --cue=${READTRACKNUMS:-$UTRACKNUM.1-$(($UTRACKNUM + 1)).0} "$FILEARG" "$CDROM" ;; cdparanoia) nice $READNICE $CDROMREADER -$CDPARANOIACDROMBUS $CDROM ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" $REDIR ;; cdda2wav) @@ -2270,6 +2354,7 @@ VORBISGAIN=vorbisgain MKCUE=mkcue MKTOC=cdrdao DIFF=diff +CUE2DISCID=cue2discid # Options for programs called from abcde # mp3 @@ -2394,7 +2479,7 @@ fi # Parse command line options #while getopts 1a:A:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do -while getopts 1a:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do +while getopts 1a:bc:C:d:Defhj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W:z opt ; do case "$opt" in 1) ONETRACK=y ;; a) ACTIONS="$OPTARG" ;; @@ -2408,7 +2493,7 @@ while getopts 1a:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do h) usage; exit ;; e) ERASEENCODEDSTATUS=y ;; E) ENCODING="$OPTARG" ;; -# f) FORCECDDBUSELOCAL=y ;; + f) FORCE=y ;; i) INLINETAG=y ;; j) MAXPROCS="$OPTARG" ;; k) KEEPWAVS=y ;; @@ -2446,16 +2531,28 @@ while getopts 1a:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do exit 1 fi ;; + z) CDROMREADERSYNTAX=debug ;; ?) usage; exit ;; esac done shift $(($OPTIND - 1)) +# If the user specified a flac file, then switch to special flac mode +if echo $CDROM | grep -i -q '.flac$'; then + vecho "abcde: switching to flac CDROMREADERSYNTAX..." + CDROMREADERSYNTAX=flac + if [ "$EJECTCD" = "y" ];then + vecho "abcde: CDROM flac mode, deactivating EJECTCD..." + EJECTCD=n + fi +fi + # Decide if we can continue. if [ "$ONETRACK" = "y" ]; then # FIXME # remove check as soon as we find out about the other readers case "$CDROMREADERSYNTAX" in + flac) ;; cdparanoia) ;; cdda2wav) ;; *) echo "abcde error: $CDROMREADERSYNTAX does not support ONETRACK mode" @@ -2498,6 +2595,7 @@ DOENCODE=n DOPOSTPROCESS=n DOTAG=n DOMOVE=n +DOREPLAYGAIN=n DOPLAYLIST=n DOCLEAN=n @@ -2512,11 +2610,17 @@ do # postprocess) DOPREPROCESS=y; DOENCODE=y; DOREAD=y;; tag) DOTAG=y; DOREAD=y; DOENCODE=y; DOCDDB=y;; move) DOMOVE=y; DOTAG=y; DOREAD=y; DOENCODE=y; DOCDDB=y;; + replaygain) DOCDDB=y; DOREAD=y; DOENCODE=y; DOTAG=y; DOMOVE=y; DOREPLAYGAIN=y;; playlist) DOCDDB=y; DOPLAYLIST=y;; clean) DOCLEAN=y;; esac done +if [ "$DONORMALIZE" = "y" ] && [ "$DOREPLAYGAIN" = "y" ]; then + # FIXME # should we abort on error or just inform the user? + : +fi + for SHOWCDDBFIELD in $(echo $SHOWCDDBFIELDS | tr , \ ); do case $SHOWCDDBFIELD in y*|Y*) SHOWCDDBYEAR="y";; @@ -2609,6 +2713,10 @@ case "$CDROMREADERSYNTAX" in CDROMREADER="$CDDAFS" CDROMREADEROPTS="$CDDAFSOPTS" ;; + flac) + CDROMREADER="$FLAC" + CDROMREADEROPTS="$FLACOPTS" + ;; esac # There's only one normalize... @@ -2621,7 +2729,7 @@ 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 , \ ); do + for OUTPUT in "$(echo "$OUTPUTTYPE" | tr , \ )"; do case "$OUTPUT" in vorbis:*|ogg:*) OGGENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;; mp3:*) MP3ENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;; @@ -2630,7 +2738,7 @@ if echo "$OUTPUTTYPE" | grep ":" > /dev/null 2>&1 ; then mpc:*) MPPENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;; esac done - for OUTPUT in $(echo $OUTPUTTYPE | tr , \ ); do + for OUTPUT in "$(echo "$OUTPUTTYPE" | tr , \ )"; do TEMPOUTPUT=$( echo "$OUTPUT" | cut -d: -f1 ) TEMPOUTPUTTYPE="${TEMPOUTPUTTYPE:+$TEMPOUTPUTTYPE,}$TEMPOUTPUT" done @@ -2655,6 +2763,7 @@ do ;; flac) [ "$FLACENCODERSYNTAX" = "default" ] && FLACENCODERSYNTAX=flac + [ "$REPLAYGAIN" = "y" ] && NEEDMETAFLAC=y [ "$DOTAG" = "y" ] && NEEDMETAFLAC=y ;; spx) @@ -2663,6 +2772,12 @@ do mpc) [ "$MPPENCODERSYNTAX" = "default" ] && MPPENCODERSYNTAX=mppenc ;; + wav) + if [ "$KEEPWAVS" = "y" ]; then + vecho "Unsetting the KEEPWAVS option, since the resulting wav files were requested..." + fi + KEEPWAVS=move + ;; *) echo "abcde error: Invalid OUTPUTTYPE defined" >&2 exit 1 ;; @@ -2794,6 +2909,8 @@ fi if [ X"$CDSPEEDVALUE" != "X" ]; then case "$CDROMREADERSYNTAX" in cdparanoia|debug) CDROMREADEROPTS="$CDPARANOIAOPTS -S $CDSPEEDVALUE" ;; + ### FIXME ### translate "cue2discid" from python to bash + flac) NEEDMETAFLAC=y ; NEEDCUE2DISCID=y ;; *) NEEDCDSPEED=y ;; esac fi @@ -2801,6 +2918,7 @@ fi # Rippers with USEPIPE support # FIXME # Include here all the rippers we can figure out support pipes PIPE_cdparanoia="-" +PIPE_flac="-c " # Encoders with USEPIPE support # FIXME # Include here all the encoders we can figure out support pipes @@ -2826,8 +2944,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 @@ -2845,7 +2963,8 @@ for X in $CDROMREADER $CDDISCID ${NEEDTAGGER+$TAGGER} $MP3ENCODER \ ${NEEDCOMMENTER+$VORBISCOMMENT} ${NEEDMETAFLAC+$METAFLAC} \ ${NEEDNORMALIZER+$NORMALIZER} ${NEEDEJECT+$EJECT} \ ${NEEDDISKTOOL+disktool} ${NEEDCDSPEED+$CDSPEED} \ - ${NEEDVORBISGAIN+$VORBISGAIN} ${NEEDCUEREADER+$CUEREADER} + ${NEEDVORBISGAIN+$VORBISGAIN} ${NEEDCUEREADER+$CUEREADER} \ + ${NEEDCUE2DISCID+$CUE2DISCID} do # Cut off the command-line options we just added in X=$(echo $X | cut -d' ' -f2) @@ -2902,14 +3021,15 @@ if [ "$DOCDDB" = "y" ]; then fi do_cddbedit - eval $($CDDBTOOL parse "$CDDBDATA") + eval "$($CDDBTOOL parse "$CDDBDATA")" fi # Before reading tracks, we set the speed of the device if [ X"$CDSPEEDVALUE" != "X" ]; then case "$CDROMREADERSYNTAX" in - cdparanoia|debug) : ;; + cdparanoia|debug) ;; + flac) ;; *) do_cdspeed ;; esac fi @@ -3211,7 +3331,7 @@ if [ "$DOENCODE" = "y" -a "$USEPIPES" != "y" ]; then fi # If the above didn't catch the stragglers, this will wait -if checkstatus replaygain; then :; else +if [ "$REPLAYGAIN" = "y" ]; then do_replaygain fi # Check to see if run_command logged any errors @@ -3225,6 +3345,15 @@ if [ "$KEEPWAVS" = "y" ];then # Don't clean up DOCLEAN=n fi +# Check if we have moved all the formats we had previously encoded, if we are not using the FORCE. +if [ ! "$FORCE" = "y" ]; then + ENCODED_FORMATS=$(egrep "^encodetrack-(.{3,6})-(.{1,2})$" "$ABCDETEMPDIR/status" | cut -d"-" -f2 | sort -u | tr '\n' '|') + MOVED_FORMATS=$(egrep "^movetrack-output-(.{3,6})$" "$ABCDETEMPDIR/status" | cut -d"-" -f2 | sort -u | tr '\n' '|') + if [ "$ENCODED_FORMATS" != "$MOVED_FORMATS" ]; then + echo "Not all encoded formats have been requested to be moved." + echo "Use \"-a clean -f -C $DISCID\" to force the removal of the remaining data." + fi +fi if [ "$DOCLEAN" = "y" ]; then # Wipe all the evidence # Gimme gimme gimme some more time!