X-Git-Url: https://git.hcoop.net/clinton/abcde.git/blobdiff_plain/b1d7b11a5ab580505448080d7b11d3e4179bf4ee..d823b8fc40e953b872be749c47c11333dd6d9c71:/abcde diff --git a/abcde b/abcde index b5b720e..539c95c 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,7 +28,7 @@ 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" @@ -43,7 +43,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 " @@ -321,7 +321,7 @@ do_gettracknum() do_replaygain() { if checkstatus replaygain; then :; else - run_command "" echo "Adding reply-gain information..." + run_command "" echo "Adding replygain information..." for OUTPUT in $( echo $OUTPUTTYPE | tr , \ ) # THE OUTPUT NEEDS TO BE CORRECTED WITH THE CONTAINER? do @@ -360,9 +360,7 @@ do_replaygain() *);; esac done - if checkerrors replaygain-.{3,6}; then - run_command replaygain false - else + if checkerrors replaygain-.{3,6}; then :; else run_command replaygain true fi fi @@ -589,14 +587,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 @@ -690,11 +684,12 @@ do_tag () mpc) run_command tagtrack-$OUTPUT-$1 true ;; + wav) + run_command tagtrack-$OUTPUT-$1 true + ;; esac done - if checkerrors "tagtrack-(.{3,6})-$1"; then - run_command tagtrack-$1 false - else + if checkerrors "tagtrack-(.{3,6})-$1"; then :; else run_command tagtrack-$1 true fi @@ -726,7 +721,7 @@ do_batch_encode () else for UTRACKNUM in $TRACKQUEUE do - echo encodetrack-$UTRACKNUM >> status + run_command encodetrack-$UTRACKNUM true done fi ) @@ -872,15 +867,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,6})-$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 @@ -1077,13 +1076,6 @@ do_move () 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. @@ -1144,6 +1136,14 @@ do_playlist () { for OUTPUT in $(echo $OUTPUTTYPE | tr , \ ) do + case $OUTPUT in + vorbis|ogg) + OUTPUT=$OGGOUTPUTCONTAINER + ;; + flac) + OUTPUT=$FLACOUTPUTCONTAINER + ;; + esac # Create a playlist file for the playlist data to go into. # We used to wipe it out if it existed. Now we request permision if interactive. for LASTTRACK in $TRACKQUEUE; do :; done @@ -1192,13 +1192,6 @@ do_playlist () 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_gettracknum if [ "$VARIOUSARTISTS" = "y" ]; then OUTPUTFILE=$(eval echo $VAOUTPUTFORMAT) @@ -1246,11 +1239,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 @@ -1285,12 +1288,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 @@ -1421,10 +1422,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 @@ -2045,6 +2044,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" @@ -2062,7 +2063,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" ;; @@ -2084,6 +2088,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) @@ -2293,6 +2301,7 @@ VORBISGAIN=vorbisgain MKCUE=mkcue MKTOC=cdrdao DIFF=diff +CUE2DISCID=cue2discid # Options for programs called from abcde # mp3 @@ -2417,7 +2426,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:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W:z opt ; do case "$opt" in 1) ONETRACK=y ;; a) ACTIONS="$OPTARG" ;; @@ -2469,16 +2478,28 @@ while getopts 1a:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do exit 1 fi ;; + z) echo "Placeholder for a future autodebug option" ;; ?) 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" @@ -2639,6 +2660,10 @@ case "$CDROMREADERSYNTAX" in CDROMREADER="$CDDAFS" CDROMREADEROPTS="$CDDAFSOPTS" ;; + flac) + CDROMREADER="$FLAC" + CDROMREADEROPTS="$FLACOPTS" + ;; esac # There's only one normalize... @@ -2685,6 +2710,7 @@ do ;; flac) [ "$FLACENCODERSYNTAX" = "default" ] && FLACENCODERSYNTAX=flac + [ "$REPLAYGAIN" = "y" ] && NEEDMETAFLAC=y [ "$DOTAG" = "y" ] && NEEDMETAFLAC=y ;; spx) @@ -2693,6 +2719,10 @@ do mpc) [ "$MPPENCODERSYNTAX" = "default" ] && MPPENCODERSYNTAX=mppenc ;; + wav) + vecho "Unsetting the KEEPWAVS option, since the resulting wav files were requested..." + KEEPWAVS=move + ;; *) echo "abcde error: Invalid OUTPUTTYPE defined" >&2 exit 1 ;; @@ -2824,6 +2854,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 @@ -2831,6 +2863,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 @@ -2856,8 +2889,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 @@ -2875,7 +2908,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) @@ -2939,7 +2973,8 @@ fi if [ X"$CDSPEEDVALUE" != "X" ]; then case "$CDROMREADERSYNTAX" in - cdparanoia|debug) : ;; + cdparanoia|debug) ;; + flac) ;; *) do_cdspeed ;; esac fi @@ -3241,7 +3276,7 @@ if [ "$DOENCODE" = "y" -a "$USEPIPES" != "y" ]; then fi # If the above didn't catch the stragglers, this will wait -if [ "$DOREPLAYGAIN" = "y" ]; then +if [ "$REPLAYGAIN" = "y" ]; then do_replaygain fi # Check to see if run_command logged any errors