2 # Copyright (c) 1998-2001 Robert Woodcock <rcw@debian.org>
3 # Copyright (c) 2003-2005 Jesus Climent <jesus.climent@hispalinux.es>
4 # This code is hereby licensed for public consumption under either the
5 # GNU GPL v2 or greater, or Larry Wall's Artistic license - your choice.
7 # You should have received a copy of the GNU General Public License
8 # along with this program; if not, write to the Free Software
9 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
11 # Copyright for this work is to expire January 1, 2010, after which it
12 # shall be public domain.
14 VERSION
="2.3.99-$Id $"
18 echo "This is abcde v$VERSION."
19 echo "Usage: abcde [options] [tracks]"
21 echo "-1 Encode the whole CD in a single file"
22 echo "-a <action1[,action2]...>"
23 echo " Actions to perform (cddb,read,normalize,encode,tag,move,playlist,clean)"
24 #echo "-A Experimental actions (retag, transcode)"
25 echo "-b Batch mode: enable album normalization and nogap encoding"
27 echo " Specify a configuration file (overrides system and user config files)"
29 echo " Specify discid to resume from (only needed if you no longer have the cd)"
31 echo " Specify CDROM device to grab"
32 echo "-D Debugging mode (equivalent to sh -x abcde)"
33 echo "-e Erase encoded track information from status file"
34 #echo "-E Set the encoding information for the tags"
35 echo "-h This help information"
36 #echo "-i Tag files while encoding, when possible (local only) -NWY-"
37 echo "-j <#> Number of encoder processes to run at once (localhost)"
38 echo "-k Keep the wav tracks for later use"
39 echo "-l Use low disk space algorithm"
40 echo "-L Use local CDDB storage directory"
41 echo "-n No lookup. Don't query CDDB, just create and use template"
42 echo "-N Noninteractive. Never prompt for anything"
43 echo "-m Modify playlist to include CRLF endings, to comply with some players"
44 echo "-M Create a CUE file"
45 echo "-o <type1[,type2]...>"
46 echo " Output file type(s) (vorbis,mp3,flac,spx,mpc). Defaults to vorbis"
47 echo "-p Pad track numbers with 0's (if less than 10 tracks)"
48 echo "-P Use UNIX pipes to read+encode without wav files"
49 echo "-r <host1[,host2]...>"
50 echo " Also encode on these remote hosts"
51 echo "-R Add replaygain values to the tag info (only for vorbis,flac)"
53 echo " Show dielfs from the CDDB info (year,genre)"
54 echo "-S <#> Set the CD speed"
55 #echo "-t File types to preprocess (wav)"
56 #echo "-T Set postprocessing options"
57 echo "-t <#> Start the track numbering at a given number"
58 echo "-T <#> Same as -t but modifies tag numbering"
59 echo "-v Show version number and exit"
60 echo "-V Be a bit more verbose about what is happening behind the scenes"
61 echo "-x Eject CD after all tracks are read"
63 echo " Add a comment to the CD tracks"
64 echo "-W <#> Contatenate CDs: -T #01 -w \"CD #\""
66 echo "Tracks is a space-delimited list of tracks to grab."
67 echo "Ranges specified with hyphens are allowed (i.e., 1-5)."
69 #echo "Double hyphens are used to concatenate tracks"
72 # Funtions to replace the need of seq, which is too distribution dependant.
76 while [ $i -ne `expr $2 + 1` ]
86 if echo i |
grep -q "[[:digit:]]" ; then
87 while [ $i -ne `expr $2 + 1` ]
94 echo "abcde: syntax error while processing track numbers" >&2
99 # Functions to replace the need of awk {print $1} and {print $NF}
102 if [ X
"$1" = "X" ]; then
103 for first
in `cat`; do
114 if [ X
"$1" = "X" ]; then
115 for stdin
in `cat`; do
119 for last
in $@
; do :; done
124 # checkstatus [blurb]
125 # Returns "0" if the blurb was found, returns 1 if it wasn't
126 # Puts the blurb content, if available, on stdout.
127 # Otherwise, returns "".
130 # Take the last line in the status file if there's multiple matches
132 BLURB
=$
(egrep $PATTERN "$ABCDETEMPDIR/status" |
tail -n 1)
134 if [ -z "$BLURB" ]; then
139 # See if there's a = in it
140 if [ "$(echo $BLURB | grep -c =)" != "0" ]; then
141 echo "$(echo $BLURB | cut -f2- -d=)"
147 # checkerrors [blurb]
148 # Returns "0" if the blurb was found (meaning there was an error),
149 # returns 1 if it wasn't (yes this is a little backwards).
150 # Does not print the blurb on stdout.
151 # Otherwise, returns "".
154 if [ -e "$ABCDETEMPDIR/errors" ]; then :; else
157 # Take the last line in the status file if there's multiple matches
159 BLURB
="$(egrep $PATTERN "$ABCDETEMPDIR/errors
" | tail -n 1)"
161 if [ -z "$BLURB" ]; then
162 # negative, we did not have a negative...
165 # affirmative, we had a negative...
171 # Finds the right pager in the system to display a file
175 # Use the debian sensible-pager wrapper to pick the pager
176 # user has requested via their $PAGER environment variable
177 if [ -x "/usr/bin/sensible-pager" ]; then
178 /usr
/bin
/sensible-pager
"$PAGEFILE"
179 elif [ -x "$PAGER" ]; then
180 # That failed, try to load the preferred editor, starting
181 # with their PAGER variable
183 # If that fails, check for less
184 elif [ -x /usr
/bin
/less ]; then
185 /usr
/bin
/less -f "$PAGEFILE"
186 # more should be on all UNIX systems
187 elif [ -x /bin
/more ]; then
188 /bin
/more "$PAGEFILE"
190 # No bananas, just cat the thing
195 # run_command [blurb] [command...]
196 # Runs a command, silently if necessary, and updates the status file
201 # See if this is supposed to be silent
202 if [ "$(checkstatus encode-output)" = "loud" ]; then
206 # Special case for SMP, since
207 # encoder output is never displayed, don't mute echos
208 if [ -z "$BLURB" -a "$MAXPROCS" != "1" ]; then
217 normalize|normalize-audio
)
218 if [ "$RETURN" = "2" ]; then
219 # File was already normalized.
224 if [ "$RETURN" != "0" ]; then
225 # Put an error in the errors file. For various reasons we
226 # can't capture a copy of the program's output but we can
227 # log what we attempted to execute and the error code
228 # returned by the program.
229 if [ "$BLURB" ]; then
232 echo "${TWEAK}returned code $RETURN: $@" >> "$ABCDETEMPDIR/errors"
233 return $RETURN # Do not pass go, do not update the status file
235 if [ "$BLURB" ]; then
236 echo $BLURB >> "$ABCDETEMPDIR/status"
240 # relpath() and slash() are Copyright (c) 1999 Stuart Ballard and
241 # distributed under the terms of the GNU GPL v2 or later, at your option
243 # Function to determine if a word contains a slash.
252 # Function to give the relative path from one file to another.
253 # Usage: relpath fromfile tofile
254 # eg relpath music/Artist/Album.m3u music/Artist/Album/Song.mp3
255 # (the result would be Album/Song.mp3)
256 # Output is relative path to $2 from $1 on stdout
258 # This code has the following restrictions:
259 # Multiple ////s are not collapsed into single /s, with strange effects.
260 # Absolute paths and ../s are handled wrong in FR (but they work in TO)
261 # If FR is a directory it must have a trailing /
269 /*) ;; # No processing is needed for absolute paths
271 # Loop through common prefixes, ignoring them.
272 while slash
"$FR" && [ "$(echo "$FR" | cut -d/ -f1)" = "$(echo "$TO" | cut -d/ -f1)" ]
274 FR
="$(echo "$FR" | cut -d/ -f2-)"
275 TO
="$(echo "$TO" | cut -d/ -f2-)"
277 # Loop through directory portions left in FR, adding appropriate ../s.
280 FR
="$(echo "$FR" | cut -d/ -f2-)"
290 # Finds an specific field from cddbinfo
292 # TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2 -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')
293 # TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2 -d= | tr -d \[:cntrl:\])
294 # TRACKNAME="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
300 TRACKNAME
="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
303 TRACKNAME
="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
309 # Get the track number we are going to use for different actions
312 if [ -n "$STARTTRACKNUMBER" ] ; then
313 # Get the trackpadding from the current track
314 CURRENTTRACKPADDING
=$
(echo -n $UTRACKNUM |
wc -c)
315 TRACKNUM
=$
( printf %0.
${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
317 TRACKNUM
=${UTRACKNUM}
323 if checkstatus replaygain
; then :; else
324 run_command
"" echo "Adding reply-gain information..."
325 for OUTPUT
in $
( echo $OUTPUTTYPE |
tr , \
)
326 # THE OUTPUT NEEDS TO BE CORRECTED WITH THE CONTAINER?
330 OUTPUT
=$OGGOUTPUTCONTAINER
333 OUTPUT
=$FLACOUTPUTCONTAINER
337 for UTRACKNUM
in $TRACKQUEUE
339 CDDBTRACKNUM
=$
(expr $UTRACKNUM - 1)
340 do_getcddbinfo TRACKNAME
342 TRACKFILE
="$(mungefilename "$TRACKNAME")"
343 ARTISTFILE
="$(mungefilename "$TRACKARTIST")"
344 ALBUMFILE
="$(mungefilename "$DALBUM")"
346 if [ "$VARIOUSARTISTS" = "y" ]; then
347 OUTPUTFILE
=$
(eval echo $VAOUTPUTFORMAT)
349 OUTPUTFILE
=$
(eval echo $OUTPUTFORMAT)
351 OUTPUTFILES
="$OUTPUTDIR/$OUTPUTFILE.$OUTPUT $OUTPUTFILES"
355 run_command replaygain-flac
$METAFLAC --add-replay-gain $OUTPUTFILES
358 run_command replaygain-vorbis
$VORBISGAIN --album $OUTPUTFILES
363 if checkerrors replaygain-.
{3,6}; then :; else
364 run_command replaygain true
369 # This code splits the a Various Artist track name from one of the following
372 # forward: Artist / Track
373 # forward-dash: Artist - Track
374 # reverse: Track / Artist
375 # reverse-dash: Track - Artist
376 # colon: Artist: Track
377 # trailing-paren: Artist (Track)
380 # VARIOUSARTISTS, VARIOUSARTISTSTYLE, TRACKNAME, TRACKARTIST
383 if [ "$VARIOUSARTISTS" = "y" ] && [ ! "$ONETRACK" = "y" ]; then
384 case "$VARIOUSARTISTSTYLE" in
386 DTITLEARTIST
="$(echo "$TRACKNAME" | sed 's- / -~-g')"
387 TRACKARTIST
="$(echo "$DTITLEARTIST" | cut -f1 -d~)"
388 TRACKNAME
="$(echo "$DTITLEARTIST" | cut -f2 -d~)"
391 DTITLEARTIST
="$(echo "$TRACKNAME" | sed 's, - ,~,g')"
392 TRACKARTIST
="$(echo "$DTITLEARTIST" | cut -f1 -d~)"
393 TRACKNAME
="$(echo "$DTITLEARTIST" | cut -f2 -d~)"
396 DTITLEARTIST
="$(echo "$TRACKNAME" | sed 's- / -~-g')"
397 TRACKARTIST
="$(echo "$DTITLEARTIST" | cut -f2 -d~)"
398 TRACKNAME
="$(echo "$DTITLEARTIST" | cut -f1 -d~)"
401 DTITLEARTIST
="$(echo "$TRACKNAME" | sed 's, - ,~,g')"
402 TRACKARTIST
="$(echo "$DTITLEARTIST" | cut -f2 -d~)"
403 TRACKNAME
="$(echo "$DTITLEARTIST" | cut -f1 -d~)"
406 DTITLEARTIST
="$(echo "$TRACKNAME" | sed 's-: -~-g')"
407 TRACKARTIST
="$(echo "$DTITLEARTIST" | cut -f1 -d~)"
408 TRACKNAME
="$(echo "$DTITLEARTIST" | cut -f2 -d~)"
411 DTITLEARTIST
="$(echo "$TRACKNAME" | sed 's,^\(.*\) (\(.*\)),\1~\2,')"
412 TRACKARTIST
="$(echo "$DTITLEARTIST" | cut -f2 -d~)"
413 TRACKNAME
="$(echo "$DTITLEARTIST" | cut -f1 -d~)"
416 elif [ "$VARIOUSARTISTS" = "y" ] && [ "$ONETRACK" = "y" ]; then
417 TRACKARTIST
="Various"
419 TRACKARTIST
="$DARTIST"
424 local genre
=$
(echo "${@}" |
tr '[A-Z]' '[a-z]')
428 "classic rock") id
=1 ;;
446 "industrial") id
=19 ;;
447 "alternative") id
=20 ;;
449 "death metal") id
=22 ;;
451 "soundtrack") id
=24 ;;
452 "euro-techno") id
=25 ;;
456 "jazz+funk") id
=29 ;;
459 "classical") id
=32 ;;
460 "instrumental") id
=33 ;;
464 "sound clip") id
=37 ;;
467 "alt. rock") id
=40 ;;
472 "meditative") id
=45 ;;
473 "instrum. pop") id
=46 ;;
474 "instrum. rock") id
=47 ;;
478 "techno-indust.") id
=51 ;;
479 "electronic") id
=52 ;;
481 "eurodance") id
=54 ;;
483 "southern rock") id
=56 ;;
488 "christian rap") id
=61 ;;
489 "pop/funk"|
"pop / funk") id
=62 ;;
491 "native american") id
=64 ;;
494 "psychadelic") id
=67 ;;
496 "showtunes") id
=69 ;;
500 "acid punk") id
=73 ;;
501 "acid jazz") id
=74 ;;
505 "rock & roll") id
=78 ;;
506 "hard rock") id
=79 ;;
508 "folk/rock") id
=81 ;;
509 "national folk") id
=82 ;;
516 "bluegrass") id
=89 ;;
517 "avantgarde") id
=90 ;;
518 "gothic rock") id
=91 ;;
519 "progress. rock") id
=92 ;;
520 "psychadel. rock") id
=93 ;;
521 "symphonic rock") id
=94 ;;
522 "slow rock") id
=95 ;;
525 "easy listening") id
=98 ;;
531 "chamber music") id
=104 ;;
533 "symphony") id
=106 ;;
534 "booty bass") id
=107 ;;
536 "porn groove") id
=109 ;;
538 "slow jam") id
=111 ;;
542 "folklore") id
=115 ;;
544 "power ballad") id
=117 ;;
545 "rhythmic soul") id
=118 ;;
546 "freestyle") id
=119 ;;
548 "punk rock") id
=121 ;;
549 "drum solo") id
=122 ;;
550 "a capella") id
=123 ;;
551 "euro-house") id
=124 ;;
552 "dance hall") id
=125 ;;
554 "drum & bass") id
=127 ;;
555 "club-house") id
=128 ;;
556 "hardcore") id
=129 ;;
560 "negerpunk") id
=133 ;;
561 "polsk punk") id
=134 ;;
563 "christian gangsta rap") id
=136 ;;
564 "heavy metal") id
=137 ;;
565 "black metal") id
=138 ;;
566 "crossover") id
=139 ;;
567 "contemporary christian")id
=140 ;;
568 "christian rock") id
=141 ;;
569 "merengue") id
=142 ;;
571 "thrash metal") id
=144 ;;
574 "synthpop") id
=147 ;;
575 "rock/pop"|
"rock / pop") id
=148 ;;
582 # do_tag [tracknumber]
583 # id3 tags a filename
585 # TRACKS, TRACKNAME, TRACKARTIST, TAGGER, TAGGEROPTS, VORBISCOMMENT, METAFLAC,
586 # COMMENT, DALBUM, DARTIST, CDYEAR, CDGENRE (and temporarily) ID3TAGV
589 COMMENTOUTPUT
="$(eval echo ${COMMENT})"
590 run_command
'' echo "Tagging track $1 of $TRACKS: $TRACKNAME..."
591 # If we want to start the tracks with a given number, we need to modify the
592 # TRACKNUM value before evaluation
593 # if [ -n "$STARTTRACKNUMBER" -a -n "$STARTTRACKNUMBERTAG" ] ; then
594 # # Get the trackpadding from the current track
595 # CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c)
596 # TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
598 if [ -n "$STARTTRACKNUMBERTAG" ] ; then
601 for OUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
605 # id3v2 v0.1.9 claims to have solved the -c bug, so we merge both id3 and id3v2
606 GENREID
=$
(do_getgenreid
"${CDGENRE}")
611 # FIXME # track numbers in mp3 come with 1/10, so we cannot happily substitute them with $TRACKNUM
612 run_command tagtrack-
$OUTPUT-$1 $TAGGER $TAGGEROPTS --commen=::"$COMMENTOUTPUT" \
613 -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" -Y "$CDYEAR" \
614 -G "$GENREID" -n "${TRACKNUM:-$1}" "${TRACKNUM:+-N $TRACKS}" \
615 "${ENCODING:+--set-encoding=$ENCODING}"
616 "$ABCDETEMPDIR/track$1.$OUTPUT"
619 # FIXME # track numbers in mp3 come with 1/10, so we cannot happily substitute them with $TRACKNUM
620 run_command tagtrack-
$OUTPUT-$1 $TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \
621 -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" -y "$CDYEAR" \
622 -g "$GENREID" -T "${TRACKNUM:-$1/$TRACKS}" \
623 "$ABCDETEMPDIR/track$1.$OUTPUT"
628 case "$OGGENCODERSYNTAX" in
630 # vorbiscomment can't do in-place modification, mv the file first
631 if [ -f "$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER" -a ! -f "$ABCDETEMPDIR/track$1.uncommented.$OGGOUTPUTCONTAINER" ]; then
632 mv "$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER" "$ABCDETEMPDIR/track$1.uncommented.$OGGOUTPUTCONTAINER"
635 # These are from http://www.xiph.org/ogg/vorbis/doc/v-comment.html
636 echo ARTIST
="$TRACKARTIST"
638 echo TITLE
="$TRACKNAME"
639 if [ -n "$CDYEAR" ]; then
642 if [ -n "$CDGENRE" ]; then
643 echo GENRE
="$CDGENRE"
645 echo TRACKNUMBER
=${TRACKNUM:-$1}
646 echo CDDB
=$CDDBDISCID
647 if [ "$(eval echo ${COMMENT})" != "" ]; then
648 case "$COMMENTOUTPUT" in
649 *=*) echo "$COMMENTOUTPUT";;
650 *) echo COMMENT
="$COMMENTOUTPUT";;
653 ) | run_command tagtrack-
$OUTPUT-$1 $VORBISCOMMENT $VORBISCOMMENTOPTS -w \
654 "$ABCDETEMPDIR/track$1.uncommented.$OGGOUTPUTCONTAINER" "$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER"
655 # Doublecheck that the commented file was created successfully before wiping the original
656 if [ -f "$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER" ]; then
657 rm -f "$ABCDETEMPDIR/track$1.uncommented.$OGGOUTPUTCONTAINER"
659 mv "$ABCDETEMPDIR/track$1.uncommented.$OGGOUTPUTCONTAINER" "$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER"
666 echo ARTIST
="$TRACKARTIST"
668 echo TITLE
="$TRACKNAME"
669 if [ -n "$CDYEAR" ]; then
672 if [ -n "$CDGENRE" ]; then
673 echo GENRE
="$CDGENRE"
675 echo TRACKNUMBER
="${TRACKNUM:-$1}"
676 echo CDDB
="$CDDBDISCID"
677 if [ "$(eval echo ${COMMENT})" != "" ]; then
678 case "$COMMENTOUTPUT" in
679 *=*) echo "$COMMENTOUTPUT";;
680 *) echo COMMENT
="$COMMENTOUTPUT";;
683 ) | run_command tagtrack-
$OUTPUT-$1 $METAFLAC $METAFLACOPTS --import-tags-from=- "$ABCDETEMPDIR/track$1.$FLACOUTPUTCONTAINER"
686 run_command tagtrack-
$OUTPUT-$1 true
689 run_command tagtrack-
$OUTPUT-$1 true
693 if checkerrors
"tagtrack-(.{3,6})-$1"; then :; else
694 run_command tagtrack-
$1 true
701 # OUTPUTTYPE, {FOO}ENCODERSYNTAX, ENCNICE, ENCODER, ENCODEROPTS
704 # The commands here don't go through run_command because they're never supposed to be silenced
705 echo "Batch encoding tracks: $TRACKQUEUE"
706 OUTPUT
=$
(echo $OUTPUTTYPE |
grep "mp3" )
709 case "$MP3ENCODERSYNTAX" in
714 for UTRACKNUM
in $TRACKQUEUE
716 TRACKFILES
="$TRACKFILES track$UTRACKNUM.wav"
718 nice
$ENCNICE $MP3ENCODER $MP3ENCODEROPTS `[ "$MP3ENCODER" = "lame" ] && echo "--nogap"` $TRACKFILES
720 if [ "$RETURN" != "0" ]; then
721 echo "batch-encode: $ENCODER returned code $RETURN" >> errors
723 for UTRACKNUM
in $TRACKQUEUE
725 run_command encodetrack-
$UTRACKNUM true
733 # Other encoders fall through to normal encoding as the tracks
734 # have not been entered in the status file.
737 # do_encode [tracknumber] [hostname]
738 # If no hostname is specified, encode locally
740 # TRACKS, TRACKNAME, TRACKARTIST, DISTMP3, DISTMP3OPTS, {FOO}ENCODERSYNTAX, OUTPUTTYPE, ENCODEROPTS, DALBUM, DARTIST, ENCNICE, CDYEAR, CDGENRE, COMMENT
743 if [ "$USEPIPES" = "y" ]; then
746 TEMPARG
="PIPE_$MP3ENCODERSYNTAX"
749 TEMPARG
="PIPE_$OGGENCODERSYNTAX"
752 TEMPARG
="PIPE_$FLACENCODERSYNTAX"
755 TEMPARG
="PIPE_$SPEEXENCODER"
758 TEMPARG
="PIPE_$MPPENCODER"
761 IN
="$( eval echo "\$
$TEMPARG" )"
763 IN
="$ABCDETEMPDIR/track$1.wav"
766 case "$MP3ENCODERSYNTAX" in
767 # FIXME # check if mp3enc needs -if for pipes
781 # We need IN to proceed, if we are not using pipes.
782 if [ -s "$IN" -o X
"$USEPIPES" = "Xy" ] ; then
783 for OUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
787 OUT
="$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER"
790 OUT
="$ABCDETEMPDIR/track$1.$FLACOUTPUTCONTAINER"
793 OUT
="$ABCDETEMPDIR/track$1.$OUTPUT"
796 if [ X
"$USEPIPES" = "Xy" ]; then
799 run_command
'' echo "Encoding track $1 of $TRACKS: $TRACKNAME..."
800 RUN_COMMAND
="run_command encodetrack-$OUTPUT-$1"
806 case "$MP3ENCODERSYNTAX" in
807 lame|gogo
) $RUN_COMMAND nice
$ENCNICE $MP3ENCODER $MP3ENCODEROPTS "$IN" "$OUT" ;;
808 bladeenc
) $RUN_COMMAND nice
$ENCNICE $MP3ENCODER $MP3ENCODEROPTS -quit "$IN" ;;
809 l3enc|xingmp3enc
) $RUN_COMMAND nice
$ENCNICE $MP3ENCODER "$IN" "$OUT" $MP3ENCODEROPTS ;;
810 # FIXME # Relates to the previous FIXME since it might need the "-if" removed.
811 mp3enc
) $RUN_COMMAND nice
$ENCNICE $MP3ENCODER -if "$IN" -of "$OUT" $MP3ENCODEROPTS ;;
815 $RUN_COMMAND nice
$DISTMP3NICE $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" >/dev
/null
2>&1
822 case "$OGGENCODERSYNTAX" in
823 vorbize
) $RUN_COMMAND nice
$ENCNICE $OGGENCODER $OGGENCODEROPTS -w "$OUT" "$IN" ;;
824 oggenc
) $RUN_COMMAND nice
$ENCNICE $OGGENCODER $OGGENCODEROPTS -o "$OUT" "$IN" ;;
828 $RUN_COMMAND nice
$DISTMP3NICE $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" >/dev
/null
2>&1
835 case "$FLACENCODERSYNTAX" in
836 flac
) $RUN_COMMAND nice
$ENCNICE $FLACENCODER $FLACENCODEROPTS -o "$OUT" "$IN" ;;
842 echo "$DISTMP3 $DISTMP3OPTS $2 $IN $OUT >/dev/null 2>&1"
843 $RUN_COMMAND nice
$DISTMP3NICE $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" > /dev
/null
2>&1
848 if [ "$(eval echo ${COMMENT})" != "" ]; then
851 *) COMMENT
="COMMENT=$COMMENT" ;;
853 COMMENT
="--comment \"$COMMENT\""
855 # Quick hack to avoid tagging Ogg/Speex, since there is no other way to tag than inline tagging
856 if [ ! "$DOTAG" = "y" ]; then
857 $RUN_COMMAND nice
$ENCNICE $SPEEXENCODER $SPEEXENCODEROPTS --author "$TRACKARTIST" --title "$TRACKNAME" "$COMMENT" "$IN" "$OUT"
859 $RUN_COMMAND nice
$ENCNICE $SPEEXENCODER $SPEEXENCODEROPTS "$IN" "$OUT"
863 # MPP/MP+(Musepack) format (.mpc) is done locally, with inline
865 # I tried compiling the mppenc from corecodecs.org and got some
866 # errors, so I have not tried it myself.
867 ## FIXME ## Needs some cleanup to determine if an empty tag sent
868 ## FIXME ## to the encoder ends up empty.
869 $RUN_COMMAND nice
$ENCNICE $MPPENCODER $MPPENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" "$IN" "$OUT"
873 # Only remove .wav if the encoding succeeded
874 if checkerrors
"encodetrack-(.{3,6})-$1"; then :; else
875 run_command encodetrack-
$1 true
876 if [ ! "$KEEPWAVS" = "y" ] ; then
881 run_command
"" echo "HEH! The file we were about to encode disappeared:"
882 run_command
"" echo ">> $IN"
883 run_command encodetrack-
$1 false
887 # do_preprocess [tracknumber]
889 # TRACKS, TRACKNAME, TRACKARTIST, DISTMP3, DISTMP3OPTS, {FOO}ENCODERSYNTAX, OUTPUTTYPE, ENCODEROPTS, DALBUM, DARTIST, ENCNICE, CDYEAR, CDGENRE, COMMENT
892 # IN="$ABCDETEMPDIR/track$1.wav"
893 # # We need IN to proceed.
894 # if [ -s "$IN" ] ; then
895 # for OUTPUT in $(echo $OUTPUTTYPE | tr , \ )
897 # #OUT="$ABCDETEMPDIR/track$1.$OUTPUT"
898 # run_command '' echo "Pre-processing track $1 of $TRACKS..."
899 # case "$POSTPROCESSFORMAT" in
901 # run_command preprocess-$OUTPUT-$1 nice $PRENICE $WAV_PRE $IF $OF ;;
903 # run_command preprocess-$OUTPUT-$1 nice $PRENICE $MP3_PRE $IF $OF ;;
905 # run_command preprocess-$OUTPUT-$1 nice $PRENICE $OGG_PRE $IF $OF ;;
907 # run_command preprocess-$OUTPUT-$1 nice $PRENICE $FLAC_PRE $IF $OF ;;
909 # run_command preprocess-$OUTPUT-$1 nice $PRENICE $SPX_PRE $IF $OF ;;
912 # # Only remove .wav if the encoding succeeded
913 # if checkerrors "preprocess-(.{3,4})-$1"; then
914 # run_command preprocess-$1 false
916 # run_command preprocess-$1 true
919 # if [ "$(checkstatus encode-output)" = "loud" ]; then
920 # echo "HEH! The file we were about to pre-process disappeared:"
923 # run_command preprocess-$1 false
928 # do_postprocess [tracknumber]
930 # TRACKS, TRACKNAME, TRACKARTIST, DISTMP3, DISTMP3OPTS, {FOO}ENCODERSYNTAX, OUTPUTTYPE, ENCODEROPTS, DALBUM, DARTIST, ENCNICE, CDYEAR, CDGENRE, COMMENT
933 # for POSTPROCESSFORMAT in $(echo $POSTPROCESSFORMATS | tr , \ )
935 # IN="$ABCDETEMPDIR/track$1.$POSTPROCESSFORMAT"
936 # # We need IN to proceed.
937 # if [ -s "$IN" ] ; then
938 # #OUT="$ABCDETEMPDIR/track$1.$OUTPUT"
939 # run_command '' echo "Post-processing track $1 of $TRACKS..."
940 # case "$POSTPROCESSFORMAT" in
942 # run_command postprocess-$OUTPUT-$1 nice $POSTNICE $MP3_POST $IF $OF ;;
944 # run_command postprocess-$OUTPUT-$1 nice $POSTNICE $OGG_POST $IF $OF ;;
946 # run_command postprocess-$OUTPUT-$1 nice $POSTNICE $FLAC_POST $IF $OF ;;
948 # run_command postprocess-$OUTPUT-$1 nice $POSTNICE $SPX_POST $IF $OF ;;
950 # # Only remove .wav if the encoding succeeded
951 # if checkerrors "postprocess-(.{3,4})-$1"; then
952 # run_command postprocess-$1 false
954 # run_command postprocess-$1 true
957 # if [ "$(checkstatus encode-output)" = "loud" ]; then
958 # echo "HEH! The file we were about to post-process disappeared:"
961 # run_command postprocess-$1 false
976 # MP3GAIN, MP3GAINOPTS, VORBISGAIN, VORBISGAINOPTS
980 # The commands here don't go through run_command because they're never supposed to be silenced
981 echo "Batch analizing gain in tracks: $TRACKQUEUE"
986 for UTRACKNUM
in $TRACKQUEUE
988 MP3FILES
="$TRACKFILES track$UTRACKNUM.mp3"
990 # XXX: Hard-coded batch option!
991 $NORMALIZER -b $NORMALIZEROPTS $TRACKFILES
993 if [ "$RETURN" != "0" ]; then
994 echo "batch-normalize: $NORMALIZER returned code $RETURN" >> errors
996 for UTRACKNUM
in $TRACKQUEUE
998 echo normalizetrack-
$UTRACKNUM >> status
1004 # do_batch_normalize
1006 # NORMALIZER, NORMALIZEROPTS
1007 do_batch_normalize
()
1009 # The commands here don't go through run_command because they're never supposed to be silenced
1010 echo "Batch normalizing tracks: $TRACKQUEUE"
1015 for UTRACKNUM
in $TRACKQUEUE
1017 TRACKFILES
="$TRACKFILES track$UTRACKNUM.wav"
1019 # XXX: Hard-coded batch option!
1020 $NORMALIZER -b $NORMALIZEROPTS $TRACKFILES
1022 if [ "$RETURN" != "0" ]; then
1023 echo "batch-normalize: $NORMALIZER returned code $RETURN" >> errors
1025 for UTRACKNUM
in $TRACKQUEUE
1027 echo normalizetrack-
$UTRACKNUM >> status
1033 # do_normalize [tracknumber]
1035 # TRACKS, TRACKNAME, NORMALIZER, NORMALIZEROPTS
1038 IN
="$ABCDETEMPDIR/track$1.wav"
1039 if [ -e "$IN" ] ; then
1040 run_command
'' echo "Normalizing track $1 of $TRACKS: $TRACKNAME..."
1041 run_command normalizetrack-
$1 $NORMALIZER $NORMALIZEROPTS "$IN"
1043 if [ "$(checkstatus encode-output)" = "loud" ]; then
1044 echo "HEH! The file we were about to normalize disappeared:"
1047 run_command normalizetrack-
$1 false
"File $IN was not found"
1051 # do_move [tracknumber]
1052 # Deduces the outfile from environment variables
1053 # Creates directory if necessary
1055 # TRACKNUM, TRACKNAME, TRACKARTIST, DALBUM, OUTPUTFORMAT, CDGENRE, CDYEAR
1058 for OUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
1060 # Create ALBUMFILE, ARTISTFILE, TRACKFILE
1061 # Munge filenames as follows:
1066 # Eat control characters
1067 ALBUMFILE
="$(mungefilename "$DALBUM")"
1068 ARTISTFILE
="$(mungefilename "$TRACKARTIST")"
1069 TRACKFILE
="$(mungefilename "$TRACKNAME")"
1070 GENRE
="$(mungegenre "$GENRE")"
1071 YEAR
="$(echo $CDYEAR)"
1072 # If we want to start the tracks with a given number, we need to modify the
1073 # TRACKNUM value before evaluation
1074 # if [ -n "$STARTTRACKNUMBER" ] ; then
1075 # # Get the trackpadding from the current track
1076 # CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c)
1077 # TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
1079 # TRACKNUM=${UTRACKNUM}
1082 # Supported variables for OUTPUTFORMAT are GENRE, ALBUMFILE, ARTISTFILE,
1083 # TRACKFILE, and TRACKNUM.
1084 if [ "$VARIOUSARTISTS" = "y" ]; then
1085 OUTPUTFILE
="$(eval echo "$VAOUTPUTFORMAT")"
1087 OUTPUTFILE
="$(eval echo "$OUTPUTFORMAT")"
1089 if checkerrors
"tagtrack-$OUTPUT-$1"; then :; else
1090 # Once we know the specific output was successful, we can change the OUTPUT to the value containing the container
1093 OUTPUT
=$OGGOUTPUTCONTAINER
1096 OUTPUT
=$FLACOUTPUTCONTAINER
1099 # Check that the directory for OUTPUTFILE exists, if it doesn't, create it
1100 OUTPUTFILEDIR
="$(dirname "$OUTPUTDIR/$OUTPUTFILE")"
1101 # mkdir -p shouldn't return an error if the directory already exists
1102 mkdir
-p "$OUTPUTFILEDIR"
1103 run_command movetrack-
$1 mv "$ABCDETEMPDIR/track$1.$OUTPUT" "$OUTPUTDIR/$OUTPUTFILE.$OUTPUT"
1104 # Lets move the cue file
1105 if CUEFILE
=$
(checkstatus cuefile
) >/dev
/null
; then
1106 if [ -r "$ABCDETEMPDIR/$CUEFILE" ]; then
1107 if checkstatus movecue-
$OUTPUT; then :; else
1108 # Silence the Copying output since it overlaps with encoding processes...
1109 #run_command '' vecho "Copying cue file to its destination directory..."
1110 if checkstatus onetrack
>/dev
/null
; then
1112 # NOTE: Creating a cue file with the 3-char-extension files is to comply with
1113 # http://brianvictor.tripod.com/mp3cue.htm#details
1114 [a-z0-9
][a-z0-9
][a-z0-9
])
1115 run_command movecue-
$OUTPUT cp "$ABCDETEMPDIR/$CUEFILE" "$OUTPUTDIR/$OUTPUTFILE.cue"
1118 run_command movecue-
$OUTPUT cp "$ABCDETEMPDIR/$CUEFILE" "$OUTPUTDIR/$OUTPUTFILE.$OUTPUT.cue"
1122 run_command movecue-
$OUTPUT cp "$ABCDETEMPDIR/$CUEFILE" "$OUTPUTFILEDIR/$CUEFILE"
1124 echo movecue-
$OUTPUT >> "$ABCDETEMPDIR/status"
1133 # Create the playlist if wanted
1135 # PLAYLISTFORMAT, PLAYLISTDATAPREFIX, VAPLAYLISTFORMAT, VAPLAYLISTDATAPREFIX,
1136 # VARIOUSARTISTS, OUTPUTDIR
1139 for OUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
1143 OUTPUT
=$OGGOUTPUTCONTAINER
1146 OUTPUT
=$FLACOUTPUTCONTAINER
1149 # Create a playlist file for the playlist data to go into.
1150 # We used to wipe it out if it existed. Now we request permision if interactive.
1151 for LASTTRACK
in $TRACKQUEUE; do :; done
1152 ALBUMFILE
="$(mungefilename "$DALBUM")"
1153 ARTISTFILE
="$(mungefilename "$DARTIST")"
1154 GENRE
=$
(mungegenre
"$GENRE")
1155 YEAR
=${CDYEAR:-$CDYEAR}
1156 if [ "$VARIOUSARTISTS" = "y" ] ; then
1157 PLAYLISTFILE
=$
(eval echo $VAPLAYLISTFORMAT)
1159 PLAYLISTFILE
=$
(eval echo $PLAYLISTFORMAT)
1161 FINALPLAYLISTDIR
=$
(dirname "$OUTPUTDIR/$PLAYLISTFILE")
1162 mkdir
-p "$FINALPLAYLISTDIR"
1163 if [ -s "$OUTPUTDIR/$PLAYLISTFILE" ]; then
1164 echo -n "Erase, Append to, or Keep the existing playlist file? [e/a/k] (e): " >&2
1165 if [ "$INTERACTIVE" = "y" ]; then
1166 while [ "$DONE" != "y" ]; do
1168 case $ERASEPLAYLIST in
1169 e|E|a|A|k|K
) DONE
=y
;;
1177 # Once we erase the playlist, we use append to create the new one.
1178 [ "$ERASEPLAYLIST" = "e" -o "$ERASEPLAYLIST" = "E" ] && rm -f "$OUTPUTDIR/$PLAYLISTFILE" && ERASEPLAYLIST
=a
1180 # The playlist does not exist, so we can safelly use append to create the new list
1183 if [ "$ERASEPLAYLIST" = "a" -o "$ERASEPLAYLIST" = "A" ]; then
1184 touch "$OUTPUTDIR/$PLAYLISTFILE"
1185 for UTRACKNUM
in $TRACKQUEUE
1187 # Shares some code with do_move since the filenames have to match
1188 CDDBTRACKNUM
=$
(expr $UTRACKNUM - 1)
1189 #TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2 -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')
1190 do_getcddbinfo TRACKNAME
1192 TRACKFILE
="$(mungefilename "$TRACKNAME")"
1193 ARTISTFILE
="$(mungefilename "$TRACKARTIST")"
1194 ALBUMFILE
="$(mungefilename "$DALBUM")"
1195 # If we want to start the tracks with a given number, we need to modify the
1196 # TRACKNUM value before evaluation
1197 # if [ -n "$STARTTRACKNUMBER" ] ; then
1198 # # Get the trackpadding from the current track
1199 # CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c)
1200 # TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
1202 # TRACKNUM=${UTRACKNUM}
1205 if [ "$VARIOUSARTISTS" = "y" ]; then
1206 OUTPUTFILE
=$
(eval echo $VAOUTPUTFORMAT)
1208 OUTPUTFILE
=$
(eval echo $OUTPUTFORMAT)
1210 if [ "$VARIOUSARTISTS" = "y" ]; then
1211 if [ "$VAPLAYLISTDATAPREFIX" ] ; then
1212 echo ${VAPLAYLISTDATAPREFIX}$OUTPUTFILE.
$OUTPUT >> "$OUTPUTDIR/$PLAYLISTFILE"
1214 relpath
"$PLAYLISTFILE", "$OUTPUTFILE.$OUTPUT" >> "$OUTPUTDIR/$PLAYLISTFILE"
1217 if [ "$PLAYLISTDATAPREFIX" ]; then
1218 echo ${PLAYLISTDATAPREFIX}$OUTPUTFILE.
$OUTPUT >> "$OUTPUTDIR/$PLAYLISTFILE"
1220 relpath
"$PLAYLISTFILE", "$OUTPUTFILE.$OUTPUT" >> "$OUTPUTDIR/$PLAYLISTFILE"
1225 ## this will convert the playlist to have CRLF line-endings, if specified
1226 ## (some hardware players insist on CRLF endings)
1227 if [ "$DOSPLAYLIST" = "y" ]; then
1228 awk '{substr("\r",""); printf "%s\r\n", $0}' "$OUTPUTDIR/$PLAYLISTFILE" > "$ABCDETEMPDIR/PLAYLISTFILE.tmp"
1229 # mv -f "$ABCDETEMPDIR/PLAYLISTFILE.tmp" "$OUTPUTDIR/$PLAYLISTFILE"
1230 cat "$ABCDETEMPDIR/PLAYLISTFILE.tmp" |
sed 's/\//\\/' > "$OUTPUTDIR/$PLAYLISTFILE"
1232 echo "playlistcomplete" >> "$ABCDETEMPDIR/status"
1237 # This essentially the start of things
1240 # Query the CD to get the track info, unless the user specified -C
1241 # or we are using some actions which do not need the CDDB data at all
1242 #if [ ! X"$EXPACTIONS" = "X" ]; then
1244 #elif [ -z "$DISCID" ]; then
1245 if [ -z "$DISCID" ]; then
1246 vecho
-n "Getting CD track info... "
1247 # In OSX, unmount the disc before a query
1248 if [ "$OSFLAVOUR" = "OSX" ]; then
1249 disktool
-u ${CDROM#/dev/}
1251 TRACKINFO
=$
($CDDISCID $CDROM)
1252 # Make sure there's a CD in there by checking cd-discid's return code
1253 if [ "$?" = "1" ]; then
1254 echo "abcde error: CD could not be read. Perhaps there's no CD in the drive?" >&2
1257 # In OSX, remount the disc again
1258 if [ "$OSFLAVOUR" = "OSX" ]; then
1259 disktool
-m ${CDROM#/dev/}
1263 TRACKINFO
=$
(cat "$WAVOUTPUTDIR/abcde.$DISCID/discid")
1266 # Get a full enumeration of tracks, sort it, and put it in the TRACKQUEUE.
1267 # This needs to be done now because a section of the resuming code will need
1270 # get the number of digits to pad TRACKNUM with - we'll use this later
1271 # a CD can only hold 99 tracks, but since we support a feature for starting
1272 # numbering the tracks from a given number, we might need to set it as a
1273 # variable for the user to define... or obtain it somehow.
1274 if [ "$PADTRACKS" = "y" ] ; then
1278 ABCDETEMPDIR
="$WAVOUTPUTDIR/abcde.$(echo $TRACKINFO | cut -f1 -d' ')"
1279 if [ -z "$TRACKQUEUE" ]; then
1280 if [ ! "$STRIPDATATRACKS" = "y" ]; then
1281 case "$CDROMREADERSYNTAX" in
1283 if [ "$WEHAVEACD" = "y" ]; then
1284 vecho
"Querying the CD for audio tracks..."
1285 CDPARANOIAOUTPUT
="$( $CDROMREADER -$CDPARANOIACDROMBUS $CDROM -Q --verbose 2>&1 )"
1287 if [ ! "$RET" = "0" ];then
1288 echo "Warning: Something went wrong while querying the CD... Maybe a DATA CD?"
1290 TRACKS
="$(echo "$CDPARANOIAOUTPUT" | egrep '^[[:space:]]+[[:digit:]]' | tail -n 1 | get_first | tr -d ".
" | tr '\n' ' ')"
1291 CDPARANOIAAUDIOTRACKS
="$TRACKS"
1293 if [ -f "$ABCDETEMPDIR/status" ] && TRACKS
=$
(checkstatus cdparanoia-audio-tracks
); then :; else
1294 TRACKS
=$
(echo $TRACKINFO | cut
-f2 -d' ')
1298 *) TRACKS
=$
(echo $TRACKINFO | cut
-f2 -d' ') ;;
1301 TRACKS
=$
(echo $TRACKINFO | cut
-f2 -d' ')
1303 if echo "$TRACKS" |
grep "[[:digit:]]" > /dev
/null
2>&1 ;then :;else
1304 echo "The disc does not contain any tracks. Giving up..."
1307 echo -n "Grabbing entire CD - tracks: "
1308 if [ ! "$PADTRACKS" = "y" ] ; then
1309 TRACKNUMPADDING
=$
(echo -n $TRACKS |
wc -c |
tr -d ' ')
1311 TRACKS
=$
(printf "%0.${TRACKNUMPADDING}d" $TRACKS)
1313 while [ "$X" -ne "$TRACKS" ]
1315 X
=$
(printf "%0.${TRACKNUMPADDING}d" $
(expr $X + 1))
1316 TRACKQUEUE
=$
(echo "$TRACKQUEUE" $X)
1320 TRACKS
=$
(echo $TRACKINFO | cut
-f2 -d' ')
1321 # User-supplied track queue.
1322 # Weed out non-numbers, whitespace, then sort and weed out duplicates
1323 TRACKQUEUE
=$
(echo $TRACKQUEUE |
sed 's-[^0-9 ]--g' |
tr ' ' '\n' |
grep -v ^$ |
sort -n |
uniq |
tr '\n' ' ' |
sed 's- $--g')
1324 # Once cleaned, obtain the highest value in the trackqueue for number padding
1325 for LASTTRACK
in $TRACKQUEUE; do :; done
1326 if [ ! "$PADTRACKS" = "y" ] ; then
1327 TRACKNUMPADDING
=$
(echo -n $LASTTRACK |
wc -c |
tr -d ' ')
1329 # Now we normalize the trackqueue
1330 for TRACK
in $TRACKQUEUE ; do
1331 TRACKNUM
=$
(printf %0.
${TRACKNUMPADDING}d $
(expr ${TRACK} + 0 ))
1332 PADTRACKQUEUE
=$
(echo $PADTRACKQUEUE $TRACKNUM)
1334 TRACKQUEUE
=$PADTRACKQUEUE
1335 echo Grabbing tracks
: "$TRACKQUEUE"
1338 QUEUEDTRACKS
=$
(echo $TRACKQUEUE |
wc -w |
tr -d ' ')
1340 # We have the discid, create a temp directory after it to store all the temp
1343 if [ -e "$ABCDETEMPDIR" ]; then
1344 echo -n "abcde: attempting to resume from $ABCDETEMPDIR"
1345 # It already exists, see if it's a directory
1346 if [ ! -d "$ABCDETEMPDIR" ]; then
1347 # This is a file/socket/fifo/device/etc, not a directory
1350 echo "abcde: file $ABCDETEMPDIR already exists and does not belong to abcde." >&2
1351 echo "Please investigate, remove it, and rerun abcde." >&2
1355 # It's a directory, let's see if it's owned by us
1356 if [ ! -O "$ABCDETEMPDIR" ]; then
1357 # Nope, complain and exit
1359 echo "abcde: directory $ABCDETEMPDIR already exists and is not owned by you." >&2
1360 echo "Please investigate, remove it, and rerun abcde." >&2
1364 # See if it's populated
1365 if [ ! -f "$ABCDETEMPDIR/discid" ]; then
1366 # Wipe and start fresh
1367 echo "abcde: $ABCDETEMPDIR/discid not found. Abcde must remove and recreate" >&2
1368 echo -n "this directory to continue. Continue? [y/n] (n)" >&2
1369 if [ "$INTERACTIVE" = "y" ]; then
1375 if [ "$ANSWER" != "y" ]; then
1378 rm -rf "$ABCDETEMPDIR" ||
exit 1
1379 mkdir
"$ABCDETEMPDIR"
1380 if [ "$?" -gt "0" ]; then
1381 # Directory already exists or could not be created
1382 echo "abcde: Temp directory $ABCDETEMPDIR could not be created." >&2
1386 # Everything is fine. Check for ^encodetracklocation-
1387 # and encode-output entries in the status file and
1388 # remove them. These are not relevant across sessions.
1389 if [ -f "$ABCDETEMPDIR/status" ]; then
1390 mv "$ABCDETEMPDIR/status" "$ABCDETEMPDIR/status.old"
1391 grep -v ^encodetracklocation-
< "$ABCDETEMPDIR/status.old" \
1392 |
grep -v ^encode-output
> "$ABCDETEMPDIR/status"
1394 # Remove old error messages
1395 if [ -f "$ABCDETEMPDIR/errors" ]; then
1396 rm -f "$ABCDETEMPDIR/errors"
1400 # We are starting from scratch
1401 mkdir
"$ABCDETEMPDIR"
1402 if [ "$?" -gt "0" ]; then
1403 # Directory already exists or could not be created
1404 echo "abcde: Temp directory $ABCDETEMPDIR could not be created." >&2
1407 cat /dev
/null
> "$ABCDETEMPDIR/status"
1409 if [ X
"$MAKECUEFILE" = "Xy" -a X
"$WEHAVEACD" = "Xy" ]; then
1410 if checkstatus cuefile
> /dev
/null
2>&1 ; then :; else
1411 CUEFILE
=cue-$
(echo "$TRACKINFO" | cut
-f1 -d' ').txt
1412 vecho
"Creating cue file..."
1413 if $CUEREADER $CUEREADEROPTS > "$ABCDETEMPDIR/$CUEFILE"; then
1414 echo cuefile
=$CUEFILE >> "$ABCDETEMPDIR/status"
1416 echo "abcde: reading the CUE sheet with mkcue is still considered experimental"
1417 echo "abcde: and there was a problem with the CD reading. abcde will continue,"
1418 echo "abcde: but consider reporting the problem to the abcde author"
1422 # If we got the CDPARANOIA status and it is not recorded, save it now
1423 if [ -n "$CDPARANOIAAUDIOTRACKS" ]; then
1424 if checkstatus cdparanoia-audio-tracks
> /dev
/null
2>&1; then :; else
1425 echo cdparanoia-audio-tracks
=$CDPARANOIAAUDIOTRACKS >> "$ABCDETEMPDIR/status"
1429 # Create the discid file
1430 echo "$TRACKINFO" > "$ABCDETEMPDIR/discid"
1434 # Create a proper CUE file based on the CUE file we created before.
1437 # FIXME # we can get the name of the cuefile from the status file
1438 if CUEFILE_IN
="$ABCDETEMPDIR"/$
(checkstatus cuefile
); then
1439 CUEFILE_OUT
=$CUEFILE_IN.out
1440 ### FIXME ### checkstatus cddb
1441 if [ -e "$CDDBDATA" ]; then
1442 vecho
"Adding metadata to the cue file..."
1443 # FIXME It doesn't preserve spaces! Why?
1444 # FIXME parse $track into PERFORMER and TITLE - abcde already has code for this?
1446 echo "PERFORMER \"$DARTIST\"" >> "$CUEFILE_OUT"
1447 echo "TITLE \"$DALBUM\"" >> "$CUEFILE_OUT"
1448 cat "$CUEFILE_IN" |
while read line
1450 if echo "$line" |
grep -q "INDEX"
1452 eval track
="\$TRACK$n"
1454 echo "TITLE \"$track\"" >> "$CUEFILE_OUT"
1456 echo "$line" >> "$CUEFILE_OUT"
1458 mv "$CUEFILE_OUT" "$CUEFILE_IN"
1459 echo "cleancuefile" >> "$ABCDETEMPDIR/status"
1465 # Parses a CDDB file and outputs the title and the track names.
1466 # Variables: CDDBFILE
1470 # List out disc title/author and contents
1471 if [ "$ONETRACK" = "y" ]; then
1472 vecho
"ONETRACK mode selected: displaying only the title of the CD..."
1474 echo "---- $(grep DTITLE "${CDDBPARSEFILE}" | cut '-d=' -f2- | tr -d \\r\\n ) ----"
1475 if [ X
"$SHOWCDDBYEAR" = "Xy" ]; then
1476 PARSEDYEAR
=$
(grep DYEAR
"${CDDBPARSEFILE}" | cut
'-d=' -f2-)
1477 if [ ! X
"$PARSEDYEAR" = "X" ]; then
1478 echo "Year: $PARSEDYEAR"
1481 if [ X
"$SHOWCDDBGENRE" = "Xy" ]; then
1482 PARSEDGENRE
=$
(grep DGENRE
"${CDDBPARSEFILE}" | cut
'-d=' -f2-)
1483 if [ ! X
"$PARSEDGENRE" = "X" ]; then
1484 echo "Genre: $PARSEDGENRE"
1487 if [ ! "$ONETRACK" = "y" ]; then
1488 for TRACK
in $
(f_seq_row
1 $TRACKS)
1490 echo $TRACK: "$(grep ^TTITLE$(expr $TRACK - 1)= "${CDDBPARSEFILE}" | cut -f2- -d= | tr -d \\r\\n)"
1496 # Check for a local CDDB file, and report success
1499 if checkstatus cddb-readcomplete
&& checkstatus cddb-choice
>/dev
/null
; then :; else
1501 CDDBLOCALSUCCESS
="n"
1502 CDDBDISCID
=$
(echo $TRACKINFO | cut
-d' ' -f1)
1503 CDDBLOCALFILE
="${CDDBLOCALDIR}/${CDDBDISCID}"
1506 # If the user has selected to check a local CDDB repo, we proceed with it
1507 if [ -r "${CDDBLOCALFILE}" ]; then
1508 # List out disc title/author and contents
1509 do_cddbparse
"${CDDBLOCALFILE}"
1510 echo -n "Locally cached CDDB entry found, use it? [y/n] (y): "
1511 if [ "$INTERACTIVE" = "y" ]; then
1513 while [ "$USELOCALRESP" != "y" ] && [ "$USELOCALRESP" != "n" ] && [ "$USELOCALRESP" != "" ] ; do
1514 echo -n 'Invalid selection. Please answer "y" or "n": '
1517 [ x
"$USELOCALRESP" = "x" ] && USELOCALRESP
="y"
1521 if [ "$USELOCALRESP" = "y" ]; then
1522 #echo "Using local copy of CDDB data"
1523 cp "${CDDBLOCALFILE}" "$ABCDETEMPDIR/cddbread.1"
1524 echo 999 > "$ABCDETEMPDIR/cddbquery" # Assuming 999 isn't used by CDDB
1525 echo cddb-readcomplete
>> "$ABCDETEMPDIR/status"
1526 do_cddbparse
"${CDDBLOCALFILE}" > "$ABCDETEMPDIR/cddbchoices"
1527 echo cddb-choice
=1 >> "$ABCDETEMPDIR/status"
1528 CDDBLOCALSUCCESS
="y"
1530 #echo "Not using local copy of CDDB data"
1531 CDDBLOCALSUCCESS
="n"
1534 CDDBLOCALSUCCESS
="n"
1542 # Perform CDDB protocol version check if it hasn't already been done
1543 if checkstatus cddb-statcomplete
; then :; else
1544 if [ "$CDDBAVAIL" = "n" ]; then
1546 echo 503 > "$ABCDETEMPDIR/cddbstat"
1549 CDDBUSER
=$
(echo $HELLOINFO | cut
-f1 -d'@')
1550 CDDBHOST
=$
(echo $HELLOINFO | cut
-f2- -d'@')
1551 while test $rc -eq 1 -a $CDDBPROTO -ge 3; do
1552 vecho
"Checking CDDB server status..."
1553 $CDDBTOOL stat
$CDDBURL $CDDBUSER $CDDBHOST $CDDBPROTO > "$ABCDETEMPDIR/cddbstat"
1554 RESPONSECODE
=$
(head -n 1 "$ABCDETEMPDIR/cddbstat" | cut
-f1 -d' ')
1555 case "$RESPONSECODE" in
1556 210) # 210 OK, status information follows (until terminating `.')
1559 501|
*) # 501 Illegal CDDB protocol level: <n>.
1560 CDDBPROTO
=`expr $CDDBPROTO - 1`
1564 if test $rc -eq 1; then
1568 echo cddb-statcomplete
>> "$ABCDETEMPDIR/status"
1576 CDDBDISCID
=$
(echo $TRACKINFO | cut
-d' ' -f1)
1577 CDDBLOCALFILE
="${CDDBLOCALDIR}/${CDDBDISCID}"
1579 # Perform CDDB query if it hasn't already been done
1580 if checkstatus cddb-querycomplete
; then :; else
1581 if [ "$CDDBAVAIL" = "n" ]; then
1583 echo 503 > "$ABCDETEMPDIR/cddbquery"
1584 # The default CDDBLOCALSUCCESS is "n"
1585 # This part will be triggered if the user CDDB repo does not
1586 # contain the entry, or if we are not trying to use the repo.
1588 vecho
"Querying the CDDB server..."
1589 CDDBUSER
=$
(echo $HELLOINFO | cut
-f1 -d'@')
1590 CDDBHOST
=$
(echo $HELLOINFO | cut
-f2- -d'@')
1591 $CDDBTOOL query
$CDDBURL $CDDBPROTO $CDDBUSER $CDDBHOST $TRACKINFO > "$ABCDETEMPDIR/cddbquery"
1597 # no match found in database,
1598 # wget/fetch error, or user requested not to use CDDB
1599 # Make up an error code (503) that abcde
1600 # will recognize in do_cddbread
1601 # and compensate by making a template
1602 echo 503 > "$ABCDETEMPDIR/cddbquery"
1604 *) # strange and unknown error
1605 echo ERRORCODE
=$ERRORCODE
1606 echo "abcde: $CDDBTOOL returned unknown error code"
1610 echo cddb-querycomplete
>> "$ABCDETEMPDIR/status"
1617 # If it's not to be used, generate a template.
1618 # Then, display it (or them) and let the user choose/edit it
1619 if checkstatus cddb-readcomplete
; then :; else
1620 vecho
"Obtaining CDDB results..."
1621 # If CDDB is to be used, interpret the query results and read all
1622 # the available entries.
1623 rm -f "$ABCDETEMPDIR/cddbchoices"
1624 CDDBCHOICES
=1 # Overridden by multiple matches
1625 RESPONSECODE
=$
(head -n 1 "$ABCDETEMPDIR/cddbquery" | cut
-f1 -d' ')
1626 case "$RESPONSECODE" in
1628 # One exact match, retrieve it
1629 # 200 [section] [discid] [artist] / [title]
1630 if checkstatus cddb-read-1-complete
; then :; else
1631 echo -n "Retrieving 1 CDDB match..." >> "$ABCDETEMPDIR/cddbchoices"
1632 $CDDBTOOL read $CDDBURL $CDDBPROTO $CDDBUSER $CDDBHOST $
(cut
-f2,3 -d' ' "$ABCDETEMPDIR/cddbquery") > "$ABCDETEMPDIR/cddbread.1"
1633 echo "done." >> "$ABCDETEMPDIR/cddbchoices"
1634 echo cddb-read-1-complete
>> "$ABCDETEMPDIR/status"
1635 echo cddb-choice
=1 >> "$ABCDETEMPDIR/status"
1637 # List out disc title/author and contents
1638 echo ---- "$(cut '-d ' -f4- "$ABCDETEMPDIR/cddbquery
")" ---- >> "$ABCDETEMPDIR/cddbchoices"
1639 for TRACK
in $
(f_seq_row
1 $TRACKS)
1641 echo $TRACK: "$(grep ^TTITLE$(expr $TRACK - 1)= "$ABCDETEMPDIR/cddbread
.1" | cut -f2- -d= | tr -d \\r\\n)" >> "$ABCDETEMPDIR/cddbchoices"
1643 echo >> "$ABCDETEMPDIR/cddbchoices"
1647 case "$RESPONSECODE" in
1648 202) echo "No CDDB match." >> "$ABCDETEMPDIR/cddbchoices" ;;
1649 403|
409) echo "CDDB entry is corrupt, or the handshake failed." >> "$ABCDETEMPDIR/cddbchoices" ;;
1650 503) echo "CDDB unavailable." >> "$ABCDETEMPDIR/cddbchoices" ;;
1652 $CDDBTOOL template $
(cat "$ABCDETEMPDIR/discid") > "$ABCDETEMPDIR/cddbread.0"
1653 # List out disc title/author and contents of template
1654 echo ---- Unknown Artist
/ Unknown Album
---- >> "$ABCDETEMPDIR/cddbchoices"
1656 for TRACK
in $
(f_seq_row
1 $TRACKS)
1658 echo $TRACK: "$(grep ^TTITLE$(expr $TRACK - 1)= "$ABCDETEMPDIR/cddbread
.0" | cut -f2- -d= | tr -d \\r\\n)" >> "$ABCDETEMPDIR/cddbchoices"
1660 echo >> "$ABCDETEMPDIR/cddbchoices"
1661 echo cddb-read-0-complete
>> "$ABCDETEMPDIR/status"
1662 echo cddb-choice
=0 >> "$ABCDETEMPDIR/status"
1665 # Multiple exact, (possibly multiple) inexact matches
1667 if [ "$RESPONSECODE" = "211" ]; then IN
=in; fi
1668 if [ "$(wc -l < "$ABCDETEMPDIR/cddbquery
" | tr -d ' ')" -eq 3 ]; then
1669 echo "One ${IN}exact match:" >> "$ABCDETEMPDIR/cddbchoices"
1670 tail -n +2 "$ABCDETEMPDIR/cddbquery" |
head -n 1 >> "$ABCDETEMPDIR/cddbchoices"
1671 echo cddb-choice
=1 >> "$ABCDETEMPDIR/status"
1673 echo "Multiple ${IN}exact matches:" >> "$ABCDETEMPDIR/cddbchoices"
1675 vecho
-n "Retrieving multiple matches... "
1676 grep -v ^
[.
]$
"$ABCDETEMPDIR/cddbquery" |
( X
=0
1677 read DISCINFO
# eat top line
1681 if checkstatus cddb-read-
$X-complete; then :; else
1682 $CDDBTOOL read $CDDBURL $CDDBPROTO $CDDBUSER $CDDBHOST $
(echo $DISCINFO | cut
-f1,2 -d' ') > "$ABCDETEMPDIR/cddbread.$X"
1683 echo cddb-read-
$X-complete >> "$ABCDETEMPDIR/status"
1685 # List out disc title/author and contents
1686 echo \
#$X: ---- "$DISCINFO" ---- >> "$ABCDETEMPDIR/cddbchoices"
1687 for TRACK
in $
(f_seq_row
1 $TRACKS)
1689 echo $TRACK: "$(grep ^TTITLE$(expr $TRACK - 1)= "$ABCDETEMPDIR/cddbread.
$X" | cut -f2- -d= | tr -d \\r\\n)" >> "$ABCDETEMPDIR/cddbchoices"
1691 echo >> "$ABCDETEMPDIR/cddbchoices"
1694 CDDBCHOICES
=$
(expr $
(cat "$ABCDETEMPDIR/cddbquery" |
wc -l) - 2)
1698 for TRACK
in $
(f_seq_row
1 $TRACKS)
1700 echo $TRACK: "$(grep ^TTITLE$(expr $TRACK - 1)= "$ABCDETEMPDIR/cddbread
.1" | cut -f2- -d= | tr -d \\r\\n)" >> "$ABCDETEMPDIR/cddbchoices"
1702 echo >> "$ABCDETEMPDIR/cddbchoices"
1703 echo cddb-read-1-complete
>> "$ABCDETEMPDIR/status"
1704 echo cddb-choice
=1 >> "$ABCDETEMPDIR/status"
1707 echo "cddb-readcomplete" >> "$ABCDETEMPDIR/status"
1714 if checkstatus cddb-edit
>/dev
/null
; then
1715 CDDBDATA
="$ABCDETEMPDIR/cddbread.$(checkstatus cddb-choice)"
1716 VARIOUSARTISTS
="$(checkstatus variousartists)"
1717 VARIOUSARTISTSTYLE
="$(checkstatus variousartiststyle)"
1720 if [ "$INTERACTIVE" = "y" ]; then
1721 # We should show the CDDB results both when we are not using the local CDDB repo
1722 # or when we are using it but we could not find a proper match
1723 if [ "$CDDBUSELOCAL" = "y" ] && [ ! "$CDDBLOCALSUCCESS" = "y" ] ||
[ ! "$CDDBUSELOCAL" = "y" ]; then
1724 # Display the $ABCDETEMPDIR/cddbchoices file created above
1725 # Pick a pager so that if the tracks overflow the screen the user can still view everything
1726 if [ -r "$ABCDETEMPDIR/cddbchoices" ]; then
1727 CDDBCHOICES
=$
(expr $
(cat "$ABCDETEMPDIR/cddbquery" |
wc -l) - 2)
1728 CHOICE
=$
(checkstatus cddb-choice
)
1729 if [ -n "$CHOICE" ] ; then
1730 case $CDDBCHOICES in
1731 1) cat "$ABCDETEMPDIR/cddbchoices" ;;
1733 echo "Selected: #$CHOICE"
1734 do_cddbparse
"$ABCDETEMPDIR/cddbread.$CHOICE"
1738 # The user has a choice to make, display the info in a pager if necessary
1739 if [ $
(cat "$ABCDETEMPDIR/cddbchoices" |
wc -l) -ge 24 ]; then
1740 page
"$ABCDETEMPDIR/cddbchoices"
1742 # It's all going to fit in one page, cat it
1743 cat "$ABCDETEMPDIR/cddbchoices" >&2
1747 # Setting the choice to an impossible integer to avoid errors in the numeric comparisons
1749 # I'll take CDDB read #3 for $400, Alex
1750 while [ $CDCHOICENUM -lt 0 ] ||
[ $CDCHOICENUM -gt $CDDBCHOICES ]; do
1751 echo -n "Which entry would you like abcde to use (0 for none)? [0-$CDDBCHOICES]: " >&2
1753 [ X
"$CDDBCHOICE" = "X" ] && CDDBCHOICE
=1
1754 if echo $CDDBCHOICE |
egrep -q "[[:digit:]]+,[[:digit:]]+" ; then
1755 if [ ! X
"$DIFF" = "X" ]; then
1756 PARSECHOICE1
=$
(echo $CDDBCHOICE | cut
-d"," -f1)
1757 PARSECHOICE2
=$
(echo $CDDBCHOICE | cut
-d"," -f2)
1758 if [ $PARSECHOICE1 -lt 1 ] ||
[ $PARSECHOICE1 -gt $CDDBCHOICES ] || \
1759 [ $PARSECHOICE2 -lt 1 ] ||
[ $PARSECHOICE2 -gt $CDDBCHOICES ] || \
1760 [ $PARSECHOICE1 -eq $PARSECHOICE2 ]; then
1761 echo "Invalid diff range. Please select two coma-separated numbers between 1 and $CDDBCHOICES" >&2
1764 # We parse the 2 choices to diff, store them in temporary files and diff them.
1765 for PARSECHOICE
in $
(echo $CDDBCHOICE |
tr , \
); do
1766 do_cddbparse
"$ABCDETEMPDIR/cddbread.$PARSECHOICE" > "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE"
1768 echo "Showing diff between choices $PARSECHOICE1 and $PARSECHOICE2..." > "$ABCDETEMPDIR/cddbread.diff"
1769 $DIFF $DIFFOPTS "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE1" "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE2" >> "$ABCDETEMPDIR/cddbread.diff"
1770 if [ $
(cat "$ABCDETEMPDIR/cddbread.diff" |
wc -l) -ge 24 ]; then
1771 page
"$ABCDETEMPDIR/cddbread.diff"
1773 cat "$ABCDETEMPDIR/cddbread.diff" >&2
1777 echo "The diff program was not found in your path. Please choose a number between 0 and $CDDBCHOICES." >&2
1780 if [ $CDCHOICENUM -lt 0 ] ||
[ $CDCHOICENUM -gt $CDDBCHOICES ]; then
1781 # Make sure we get a valid choice
1782 CDCHOICENUM
=$
(echo $CDDBCHOICE |
xargs printf %d
2>/dev
/null
)
1783 echo "Invalid selection. Please choose a number between 0 and $CDDBCHOICES." >&2
1787 if [ "$CDCHOICENUM" = "0" ]; then
1788 vecho
"Creating empty CDDB template..."
1790 $CDDBTOOL template $
(cat "$ABCDETEMPDIR/discid") > "$ABCDETEMPDIR/cddbread.0"
1792 echo "Selected: #$CDCHOICENUM ($(grep ^DTITLE= "$ABCDETEMPDIR/cddbread.
$CDCHOICENUM" | cut -f2- -d= | tr -d \\r\\n))" >&2
1793 do_cddbparse
"$ABCDETEMPDIR/cddbread.$CDCHOICENUM"
1795 echo "cddb-choice=$CDCHOICENUM" >> "$ABCDETEMPDIR/status"
1799 # We need some code to show the selected option when local repository is selected and we have found a match
1800 vecho
"Using cached CDDB match..." >&2
1801 # Display the $ABCDETEMPDIR/cddbchoices file created above
1802 # Pick a pager so that if the tracks overflow the screen the user can still view everything
1803 if [ -r "$ABCDETEMPDIR/cddbchoices" ]; then
1804 CDDBCHOICES
=$
(expr $
(cat "$ABCDETEMPDIR/cddbquery" |
wc -l) - 2)
1805 CHOICE
=$
(checkstatus cddb-choice
)
1806 if [ "$USELOCALRESP" = "y" ]; then :; else
1807 if [ -n "$CHOICE" ] ; then
1808 case $CDDBCHOICES in
1811 echo "Selected template."
1813 1) cat "$ABCDETEMPDIR/cddbchoices" ;;
1815 echo "Selected: #$CHOICE"
1816 do_cddbparse
"$ABCDETEMPDIR/cddbread.$CHOICE"
1824 # We're noninteractive - pick the first choice.
1825 # But in case we run a previous instance and selected a choice, use it.
1826 if [ -r "$ABCDETEMPDIR/cddbchoices" ]; then
1827 # Show the choice if we are not using the locally stored one
1828 # or when the local search failed to find a match.
1829 PREVIOUSCHOICE
=$
(checkstatus cddb-choice
)
1830 if [ "$CDDBUSELOCAL" = "y" ] && [ "$CDDBLOCALSUCCESS" = "n" ] ||
[ ! "$CDDBUSELOCAL" = "y" ]; then
1831 #if [ "$PREVIOUSCHOICE" ]; then
1832 cat "$ABCDETEMPDIR/cddbchoices"
1835 if [ ! -z "$PREVIOUSCHOICE" ] ; then
1836 CDCHOICENUM
=$PREVIOUSCHOICE
1839 echo "cddb-choice=$CDCHOICENUM" >> "$ABCDETEMPDIR/status"
1841 echo "Selected: #$CDCHOICENUM ($(grep ^DTITLE= "$ABCDETEMPDIR/cddbread.
$CDCHOICENUM" | cut -f2- -d= | tr -d \\r\\n))" >&2
1846 if checkstatus cddb-choice
>/dev
/null
; then :; else
1847 echo "abcde: internal error: cddb-choice not recorded." >&2
1850 CDDBDATA
="$ABCDETEMPDIR/cddbread.$(checkstatus cddb-choice)"
1851 echo -n "Edit selected CDDB data? [y/n] (" >&2
1852 if [ "$INTERACTIVE" = "y" ]; then
1853 if [ "$UNKNOWNDISK" = "y" ]; then
1856 [ "$EDITCDDB" != "n" ] && EDITCDDB
=y
1865 if [ "$EDITCDDB" = "y" ]; then
1866 CDDBDATAMD5SUM
=$
($MD5SUM "$CDDBDATA" | cut
-d " " -f 1);
1868 # Use the debian sensible-editor wrapper to pick the editor that the
1869 # user has requested via their $EDITOR environment variable
1870 if [ -x "/usr/bin/sensible-editor" ]; then
1871 /usr
/bin
/sensible-editor
"$CDDBDATA"
1872 elif [ -n "$EDITOR" ]; then
1873 if [ -x $
(which "${EDITOR%%\ *}") ]; then
1874 # That failed, try to load the preferred editor, starting
1875 # with their EDITOR variable
1876 eval $
(echo "$EDITOR") \"$CDDBDATA\"
1878 # If that fails, check for a vi
1879 elif which vi
>/dev
/null
2>&1; then
1881 elif [ -x /usr
/bin
/vim
]; then
1882 /usr
/bin
/vim
"$CDDBDATA"
1883 elif [ -x /usr
/bin
/vi
]; then
1884 /usr
/bin
/vi
"$CDDBDATA"
1885 elif [ -x /bin
/vi
]; then
1887 # nano should be on all (modern, i.e., sarge) debian systems
1888 elif which nano
>/dev
/null
2>&1 ; then
1890 elif [ -x /usr
/bin
/nano
]; then
1891 /usr
/bin
/nano
"$CDDBDATA"
1892 # mg should be on all OpenBSD systems
1893 elif which mg
>/dev
/null
2>&1 ; then
1895 elif [ -x /usr
/bin
/mg
]; then
1896 /usr
/bin
/mg
"$CDDBDATA"
1899 echo "No editor available. Check your EDITOR environment variable." >&2
1901 # delete editor backup file if it exists
1902 if [ -w "$CDDBDATA~" ]; then
1907 # Some heuristics first. Look at Disc Title, and if it starts with
1908 # "Various", then we'll assume Various Artists
1909 if [ "$(grep ^DTITLE= "$CDDBDATA" | cut -f2- -d= | egrep -ci '^(various|soundtrack|varios|sonora|ost)')" != "0" ]; then
1910 echo "Looks like a Multi-Artist CD" >&2
1913 echo -n "Is the CD multi-artist? [y/n] (n): " >&2
1914 if [ "$INTERACTIVE" = "y" ]; then
1921 if [ "$VARIOUSARTISTS" = "y" ] && [ ! "$ONETRACK" = "y" ]; then
1924 # Need NUMTRACKS before cddb-tool will return it:
1925 NUMTRACKS
=$
(egrep '^TTITLE[0-9]+=' "$CDDBDATA" |
wc -l)
1926 if [ "$(grep -c "^TTITLE.
*\
/" "$CDDBDATA")" -gt "$(expr $NUMTRACKS / 2 )" ]; then
1927 # More than 1/2 tracks contain a "/", so guess forward
1929 elif [ "$(grep -c "^TTITLE.
*\
-" "$CDDBDATA")" -gt "$(expr $NUMTRACKS / 2 )" ]; then
1930 # More than 1/2 contain a "-", so guess forward-dash
1932 elif [ "$(grep -c "^TTITLE.
*(.
*)" "$CDDBDATA")" -gt "$(expr $NUMTRACKS / 2 )" ]; then
1933 # More than 1/2 contain something in parens, so guess trailing-paren
1937 echo "1) Artist / Title" >&2
1938 echo "2) Artist - Title" >&2
1939 echo "3) Title / Artist" >&2
1940 echo "4) Title - Artist" >&2
1941 echo "5) Artist: Title" >&2
1942 echo "6) Title (Artist)" >&2
1943 echo "7) This is a single-artist CD" >&2
1944 echo -n "Which style of multiple artist entries is it? [1-7] ($DEFAULTSTYLE): " >&2
1945 if [ "$INTERACTIVE" = "y" ]; then
1946 read VARIOUSARTISTSTYLE
1948 echo $DEFAULTSTYLE >&2
1949 VARIOUSARTISTSTYLE
=$DEFAULTSTYLE
1951 VARIOUSARTISTSTYLE
=$
(echo 0$VARIOUSARTISTSTYLE |
xargs printf %d
)
1952 # If they press Enter, then the default style (0) was chosen
1953 while [ $VARIOUSARTISTSTYLE -lt 0 ] ||
[ $VARIOUSARTISTSTYLE -gt 7 ]; do
1954 echo "Invalid selection. Please choose a number between 1 and 7."
1955 echo -n "Selection [1-7]: "
1956 read VARIOUSARTISTSTYLE
1957 VARIOUSARTISTSTYLE
=$
(echo 0$VARIOUSARTISTSTYLE |
xargs printf %d
)
1959 if [ "$VARIOUSARTISTSTYLE" = "0" ]; then
1960 VARIOUSARTISTSTYLE
=$DEFAULTSTYLE
1962 vecho
"Selected: $VARIOUSARTISTSTYLE"
1963 case "$VARIOUSARTISTSTYLE" in
1965 VARIOUSARTISTSTYLE
=forward
1968 VARIOUSARTISTSTYLE
=forward-dash
1971 VARIOUSARTISTSTYLE
=reverse
1974 VARIOUSARTISTSTYLE
=reverse-dash
1977 VARIOUSARTISTSTYLE
=colon
1980 VARIOUSARTISTSTYLE
=trailing-paren
1988 echo "variousartists=$VARIOUSARTISTS" >> "$ABCDETEMPDIR/status"
1989 echo "variousartiststyle=$VARIOUSARTISTSTYLE" >> "$ABCDETEMPDIR/status"
1991 if [ "$EDITCDDB" = "y" ] && [ "$UNINTENTIONALLY_ANGER_THE_FREEDB_PEOPLE" = "y" ]; then
1992 if [ "$CDDBDATAMD5SUM" != "" ] && [ "$CDDBDATAMD5SUM" != "$($MD5SUM "$CDDBDATA" | cut -d " " -f 1)" ]; then
1993 # This works but does not have the necessary error checking
1994 # yet. If you are familiar with the CDDB spec
1995 # (see http://www.freedb.org/src/latest/DBFORMAT)
1996 # and can create an error-free entry on your own, then put
1997 # UNINTENTIONALLY_ANGER_THE_FREEDB_PEOPLE=y in your
1998 # abcde.conf to enable it. Put CDDBSUBMIT=email@address in
1999 # your abcde.conf to change the email address submissions are
2002 # submit the modified file, if they want
2003 if [ "$NOSUBMIT" != "y" ]; then
2004 echo -n "Do you want to submit this entry to $CDDBSUBMIT? [y/n] (n): "
2006 while [ "$YESNO" != "y" ] && [ "$YESNO" != "n" ] && [ "$YESNO" != "Y" ] && \
2007 [ "$YESNO" != "N" ] && [ "$YESNO" != "" ]
2009 echo -n 'Invalid selection. Please answer "y" or "n": '
2012 if [ "$YESNO" = "y" ] ||
[ "$YESNO" = "Y" ]; then
2013 echo -n "Sending..."
2014 $CDDBTOOL send
"$CDDBDATA" $CDDBSUBMIT
2020 # Make sure the cache directory exists
2021 mkdir
-p $CDDBLOCALDIR
2022 # Cache edited CDDB entry in the user's cddb dir
2023 if [ "$CDDBCOPYLOCAL" = "y" ] ||
[ "$COPYCDDBLOCAL" = "Y" ]; then
2024 cat "$CDDBDATA" |
tail -n $
(expr $
(cat "$CDDBDATA" |
wc -l ) - 1 ) > ${CDDBLOCALDIR}/$
(echo "$TRACKINFO" | cut
-d' ' -f1)
2027 echo "cddb-edit" >> "$ABCDETEMPDIR/status"
2030 # do_cdread [tracknumber]
2031 # do_cdread onetrack [firsttrack] [lasttrack]
2035 # The commands here don't go through run_command because they're never supposed to be silenced
2036 # return codes need to be doublechecked anyway, however
2037 if [ "$1" = "onetrack" ]; then
2038 # FIXME # Add the possibility of grabbing ranges of tracks in onetrack
2039 # FIXME # Until then, we grab the whole CD in one track, no matter what
2041 # We need the first and last track for cdda2wav
2044 UTRACKNUM
=$FIRSTTRACK
2045 case "$CDROMREADERSYNTAX" in
2046 cdparanoia
) READTRACKNUMS
="$FIRSTTRACK-$LASTTRACK" ;;
2047 cdda2wav
) READTRACKNUMS
="$FIRSTTRACK+$LASTRACK" ;;
2048 *) echo "abcde error: $CDROMREADERSYNTAX does not support ONETRACK mode"
2054 CDDBTRACKNUM
=$
(expr $UTRACKNUM - 1)
2055 if [ "$USEPIPES" = "y" ]; then
2056 TEMPARG
="PIPE_$CDROMREADERSYNTAX"
2057 FILEARG
="$( eval echo "\$
$TEMPARG" )"
2059 PIPE_MESSAGE
="and encoding "
2061 WAVDATA
="$ABCDETEMPDIR/track$UTRACKNUM.wav"
2062 case "$CDROMREADERSYNTAX" in
2063 ## FIXME ## Find the case for dagrab, to avoid exceptions
2065 FILEARG
="-f $WAVDATA"
2073 if [ "$1" = "onetrack" ]; then
2074 echo "Grabbing ${PIPE_MESSAGE}tracks $UTRACKNUM - $LASTTRACK as one track ..." >&2
2076 if [ -r "$CDDBDATA" ]; then
2077 #TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2 -d= | tr -d \[:cntrl:\])
2078 do_getcddbinfo TRACKNAME
2079 echo "Grabbing ${PIPE_MESSAGE}track $UTRACKNUM: $TRACKNAME..." >&2
2081 echo "Grabbing ${PIPE_MESSAGE}track $UTRACKNUM..." >&2
2084 case "$CDROMREADERSYNTAX" in
2086 nice
$READNICE $CDROMREADER -$CDPARANOIACDROMBUS $CDROM ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" $REDIR ;;
2088 if [ "$OSFLAVOUR" = "OSX" ] ; then
2089 # Hei, we have to unmount the device before running anything like cdda2wav in OSX
2090 disktool
-u ${CDROM#/dev/} 0
2091 # Also, in OSX the cdrom device for cdda2wav changes...
2092 CDDA2WAVCDROM
="IODVDServices"
2093 elif [ "$OSFLAVOUR" = "FBSD" ] ; then
2094 CDDA2WAVCDROM
="$CDROMID"
2096 if [ "$CDROMID" = "" ]; then
2097 CDDA2WAVCDROM
="$CDROM"
2099 CDDA2WAVCDROM
="$CDROMID"
2102 nice
$READNICE $CDROMREADER -D $CDDA2WAVCDROM -t ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" $REDIR
2104 ## FIXME ## We have an exception for dagrab, since it uses -f
2105 ## FIXME ## Shall we just use -f $FILEARG ??
2106 dagrab
) nice
$READNICE $CDROMREADER -d $CDROM -v $UTRACKNUM "$FILEARG" $REDIR
2109 # Find the track's mounted path
2110 REALTRACKNUM
=$
(expr $UTRACKNUM + 0)
2111 FILEPATH
=$
(mount |
grep "$CDROM on" |
sed 's/^[^ ]* on \(.*\) (.*/\1/')
2112 FILEPATH
=$
(find "$FILEPATH" |
grep "/$REALTRACKNUM ");
2113 # If the file exists, copy it
2114 if [ -e "$FILEPATH" ] ; then
2115 nice
$READNICE $CDROMREADER "$FILEPATH" "$FILEARG" $REDIR
2119 debug
) nice
$READNICE $CDROMREADER -$CDPARANOIACDROMBUS $CDROM -w $UTRACKNUM-[:1] "$FILEARG" $REDIR
2123 # If we get some error or we get some missing wav
2124 # (as long as we dont use pipes)
2125 if [ "$RETURN" != "0" -o \
( ! -s "$WAVDATA" -a X
"$USEPIPES" != "Xy" \
) ]; then
2126 # Thank goodness errors is only machine-parseable up to the
2127 # first colon, otherwise this woulda sucked
2128 if [ "$RETURN" = "0" -a ! -s "$WAVDATA" ]; then
2129 RETURN
=73 # fake a return code as cdparanoia return 0 also on aborted reads
2131 if [ "$USEPIPES" = "y" ]; then
2132 echo "readencodetrack-$UTRACKNUM: $CDROMREADER returned code $RETURN" >> "$ABCDETEMPDIR/errors"
2134 echo "readtrack-$UTRACKNUM: $CDROMREADER returned code $RETURN" >> "$ABCDETEMPDIR/errors"
2138 if [ "$USEPIPES" = "y" ]; then
2139 echo readencodetrack-
$UTRACKNUM >> "$ABCDETEMPDIR/status"
2141 echo readtrack-
$UTRACKNUM >> "$ABCDETEMPDIR/status"
2142 if [ "$1" = "onetrack" ]; then
2143 echo onetrack
>> "$ABCDETEMPDIR/status"
2150 # No values accepted, only uses env variables
2153 if "$CDSPEED" "$CDSPEEDOPTS" "$CDSPEEDVALUE" >/dev
/null
; then
2154 vecho
"Setting CD speed to ${CDSPEEDVALUE}x"
2156 echo "abcde: unable to set the device speed" >&2
2162 # vecho outputs a message if EXTRAVERBOSE is selected
2165 if [ x
"$EXTRAVERBOSE" != "x" ]; then
2170 # User-redefinable functions
2171 # Custom filename munging:
2174 #echo "$@" | sed s,:,\ -,g | tr \ /\* __+ | tr -d \'\"\?\[:cntrl:\]
2175 echo "$@" |
sed s
,:,\
-,g |
tr \
/ __ |
tr -d \'\"\?\
[:cntrl
:\
]
2178 # Custom genre munging:
2181 echo $CDGENRE |
tr "[:upper:]" "[:lower:]"
2185 # Empty pre_read function, to be defined in the configuration file.
2192 # Empty post_read function, to be defined in the configuration file.
2198 ###############################################################################
2201 # Start of execution
2202 ###############################################################################
2205 CDDBURL
="http://freedb.freedb.org/~cddb/cddb.cgi"
2206 CDDBSUBMIT
=freedb-submit@freedb.org
2208 HELLOINFO
="$(whoami)@$(hostname)"
2210 CDDBLOCALDIR
="$HOME/.cddb"
2213 # List of fields we parse and show during the CDDB parsing...
2214 SHOWCDDBFIELDS
="year,genre"
2217 CDROMREADERSYNTAX
=cdparanoia
2218 ENCODERSYNTAX
=default
2220 MP3ENCODERSYNTAX
=default
2221 OGGENCODERSYNTAX
=default
2222 FLACENCODERSYNTAX
=default
2223 SPEEXENCODERSYNTAX
=default
2224 MPPENCODERSYNTAX
=default
2225 NORMALIZERSYNTAX
=default
2226 CUEREADERSYNTAX
=default
2228 OUTPUTFORMAT
='${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
2229 # Use the following VAOUTPUTFORMAT to revert to 2.0.x VA format:
2230 #VAOUTPUTFORMAT=${OUTPUTFORMAT}
2231 VAOUTPUTFORMAT
='Various-${ALBUMFILE}/${TRACKNUM}.${ARTISTFILE}-${TRACKFILE}'
2232 ONETRACKOUTPUTFORMAT
='${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}'
2233 VAONETRACKOUTPUTFORMAT
='Various-${ALBUMFILE}/${ALBUMFILE}'
2234 PLAYLISTFORMAT
='${ARTISTFILE}-${ALBUMFILE}.${OUTPUT}.m3u'
2235 PLAYLISTDATAPREFIX
=''
2236 VAPLAYLISTFORMAT
='${ARTISTFILE}-${ALBUMFILE}.${OUTPUT}.m3u'
2237 VAPLAYLISTDATAPREFIX
=''
2245 VARIOUSARTISTSTYLE
=forward
2249 # If using scsi devices, cdda2wav needs a CDROMID, instead of a device node
2250 # i.e. CDROMID="1,0,0"
2252 # If we are using the IDE bus, we need CDPARANOIACDROMBUS defined as "d"
2253 # If we are using the ide-scsi emulation layer, we need to define a "g"
2254 CDPARANOIACDROMBUS
="d"
2256 # program paths - defaults to checking your $PATH
2262 XINGMP3ENC
=xingmp3enc
2277 CDPARANOIA
=cdparanoia
2286 VORBISCOMMENT
=vorbiscomment
2288 NORMALIZE
=normalize-audio
2290 VORBISGAIN
=vorbisgain
2295 # Options for programs called from abcde
2327 VORBISCOMMENTOPTS
="-R"
2328 METAFLACOPTS
="--no-utf8-convert"
2330 # Default to one process if -j isn't specified
2333 # List of actions to perform - by default, run to completion
2334 ACTIONS
=cddb
,read,encode
,tag
,move
,clean
2336 # List of prefered outputs - by default, run with whatever we have in the path
2337 # This option is basicaly for Debian package dependencies
2338 DEFAULT_OUTPUT_BINARIES
=vorbis
:oggenc
,flac
:flac
,mp3
:lame
,mp3
:bladeenc
,spx
:speex
2340 # Asume fetch if under FreeBSD. curl is used for Mac OS X. wget is used for Linux/OpenBSD/NetBSD.
2341 # Let's use these checkings to determine the OS flavour, which will be used later
2342 if [ X$
(uname
) = "XFreeBSD" ] ; then
2347 elif [ X$
(uname
) = "XDarwin" ] ; then
2350 # We should have disktool in OSX, but let's be sure...
2352 CDROMREADERSYNTAX
=cddafs
2353 elif [ X$
(uname
) = "XOpenBSD" ] ; then
2356 elif [ X$
(uname
) = "XNetBSD" ] ; then
2363 # If CDDBAVAIL is set to n, no CDDB read is done
2364 # If USEID3 is set to n, no ID3 tagging is done
2369 if [ -z "$OUTPUTDIR" ]; then
2373 if [ -z "$WAVOUTPUTDIR" ]; then
2374 WAVOUTPUTDIR
="$OUTPUTDIR"
2377 # Load system defaults
2378 if [ -r /etc
/abcde.conf
]; then
2381 # Load user preference defaults
2382 if [ -r $HOME/.abcde.conf
]; then
2386 # By this time, we need some HTTPGETOPTS already defined.
2387 # If the user has defined a non-default HTTPGET method, we should not be empty.
2389 if [ "$HTTPGETOPTS" = "" ] ; then
2391 wget
) HTTPGETOPTS
="-q -O -";;
2392 curl
) HTTPGETOPTS
="-f -s";;
2393 fetch
)HTTPGETOPTS
="-q -o -";;
2394 ftp) HTTPGETOPTS
="-q -o -";;
2395 *) echo "abcde warning: HTTPGET in non-standard and HTTPGETOPTS are not defined." >&2 ;;
2399 # If the CDROM has not been set yet, find a suitable one.
2400 # If this is a devfs system, default to /dev/cdroms/cdrom0
2401 # instead of /dev/cdrom
2402 if [ "$CDROM" = "" ] ; then
2403 if [ -e /dev
/cdroms
/cdrom0
]; then
2404 CDROM
=/dev
/cdroms
/cdrom0
2405 elif [ -e /dev
/cdrom
]; then
2407 elif [ -e /dev
/cd0c
]; then
2409 elif [ -e /dev
/acd0c
]; then
2411 elif [ -e /dev
/disk1
]; then
2416 # Parse command line options
2417 #while getopts 1a:A:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do
2418 while getopts 1a
:bc:C
:d
:Dehj
:klLmMnNo
:pPr
:Rs
:S
:t
:T
:vVxw
:W
: opt
; do
2421 a
) ACTIONS
="$OPTARG" ;;
2422 A
) EXPACTIONS
="$OPTARG" ;;
2424 c
) if [ -e "$OPTARG" ] ; then .
"$OPTARG" ; else echo "abcde error: config file \"$OPTARG\" cannot be found." >&2 ; exit 1 ; fi ;;
2425 C
) DISCID
="${OPTARG#abcde.}" ;;
2426 d
) CDROM
="$OPTARG" ;;
2428 e
) ERASEENCODEDSTATUS
=y
;;
2430 e
) ERASEENCODEDSTATUS
=y
;;
2431 E
) ENCODING
="$OPTARG" ;;
2432 # f) FORCECDDBUSELOCAL=y ;;
2434 j
) MAXPROCS
="$OPTARG" ;;
2437 L
) CDDBUSELOCAL
=y
;;
2442 o
) OUTPUTTYPE
="$OPTARG" ;;
2445 r
) REMOTEHOSTS
="$OPTARG" ;;
2447 s
) SHOWCDDBFIELDS
="$OPTARG" ;;
2448 S
) CDSPEEDVALUE
="$OPTARG" ;;
2449 # t) PREPROCESSFORMATS="$OPTARG"
2451 # T) POSTPROCESSFORMATS="$OPTARG" ;;
2452 t
) STARTTRACKNUMBER
="$OPTARG" ;;
2453 T
) STARTTRACKNUMBER
="$OPTARG" ; STARTTRACKNUMBERTAG
="y" ;;
2455 echo "This is abcde v$VERSION."
2456 echo "Usage: abcde [options] [tracks]"
2457 echo "abcde -h for extra help"
2460 V
) EXTRAVERBOSE
="y" ;;
2462 w
) COMMENT
="$OPTARG" ;;
2463 W
) if echo $OPTARG |
grep -q "[[:digit:]]" ; then
2464 STARTTRACKNUMBER
="${OPTARG}01" ; STARTTRACKNUMBERTAG
="y" ; COMMENT
="CD${OPTARG}"
2466 echo "abcde error: argument of -W must be integer"
2474 shift $
(($OPTIND - 1))
2476 # Decide if we can continue.
2477 if [ "$ONETRACK" = "y" ]; then
2478 # FIXME # remove check as soon as we find out about the other readers
2479 case "$CDROMREADERSYNTAX" in
2482 *) echo "abcde error: $CDROMREADERSYNTAX does not support ONETRACK mode"
2485 if [ "$BATCH" = "y" ]; then
2486 echo "abcde error: BATCH mode is not compatible with ONETRACK mode"
2489 # It does not matter how many tracks we want. In ONETRACK mode we grab them all
2490 # FIXME # allow ranges of tracks to be selected for onetrack ripping
2491 if [ $# -gt 0 ]; then
2492 vecho
"abcde warning: ONETRACK mode selected, grabbing all tracks..."
2495 while [ $# -gt 0 ]; do
2496 # Range parsing code courtesy of Vincent Ho
2497 RSTART
=$
(echo $1 | cut
-f1 -d-)
2498 REND
=$
(echo $1 | cut
-f2 -d-)
2499 if [ "$RSTART" = "$REND" ]; then
2502 NEWTRACKS
=$
(f_seq_line
$RSTART $REND)
2504 TRACKQUEUE
=$
(echo "$TRACKQUEUE" "$NEWTRACKS")
2509 # List of valid actions: cddb,read,normalize,encode,tag,move,playlist,clean
2510 # List of experimental actions: retag,transcode
2512 # Determine what actions are to be done from $ACTIONS and set the
2513 # following environment variables for them:
2526 for ACTION
in $
(echo $ACTIONS |
tr , \
)
2531 normalize
) DONORMALIZE
=y
; DOREAD
=y
;;
2532 # preprocess) DOPREPROCESS=y; DOREAD=y;;
2533 encode
) DOENCODE
=y
; DOREAD
=y
;;
2534 # postprocess) DOPREPROCESS=y; DOENCODE=y; DOREAD=y;;
2535 tag
) DOTAG
=y
; DOREAD
=y
; DOENCODE
=y
; DOCDDB
=y
;;
2536 move
) DOMOVE
=y
; DOTAG
=y
; DOREAD
=y
; DOENCODE
=y
; DOCDDB
=y
;;
2537 replaygain
) DOCDDB
=y
; DOREAD
=y
; DOENCODE
=y
; DOTAG
=y
; DOMOVE
=y
; DOREPLAYGAIN
=y
;;
2538 playlist
) DOCDDB
=y
; DOPLAYLIST
=y
;;
2543 if [ "$DONORMALIZE" = "y" ] && [ "$DOREPLAYGAIN" = "y" ]; then
2544 # FIXME # should we abort on error or just inform the user?
2548 for SHOWCDDBFIELD
in $
(echo $SHOWCDDBFIELDS |
tr , \
); do
2549 case $SHOWCDDBFIELD in
2550 y
*|Y
*) SHOWCDDBYEAR
="y";;
2551 g
*|G
*) SHOWCDDBGENRE
="y";;
2558 # At this point a CDROM has to be defined, so we check it exists.
2559 if [ X
"$CDROM" != "X" ] ; then
2560 if [ "$CDROMREADERSYNTAX" = "cdda2wav" ] && [ "$NEEDCDROMID" = "y" ] ; then
2561 if [ "$OSFLAVOUR" = "FBSD" ]; then
2562 if ! echo "$CDROMID" |
grep "^[0-9],[0-9],[0-9]$" >/dev
/null
2>&1 ; then
2563 echo "abcde error: CDROMID not in the right format for $CDROMREADERSYNTAX"
2564 echo "Use \"cdrecord -scanbus\" to obtain a adecuate ID an set CDROMID accordingly"
2568 elif [ ! -e "$CDROM" -a X
"$DOREAD" = "Xy" ]; then
2569 echo "abcde error: CDROM device cannot be found." >&2
2572 # avoid processing if we are not going to hit the CDROM.
2573 elif [ X
"$DOREAD" = "Xy" ]; then
2574 echo "abcde error: CDROM has not been defined or cannot be found" >&2
2578 # USEPIPES pre-tests, before we get into more serious stuff
2579 # Not compatible with:
2580 # - multiple outputs
2582 # - lowdisk algorithm
2584 if [ X
"$USEPIPES" = "Xy" ]; then
2585 if [ $
(echo "$OUTPUTTYPE" |
tr , \ |
wc -w ) -gt 1 ]; then
2586 echo "abcde error: Unix pipes not compatible with multiple outputs" >&2
2589 if [ X
"$DONORMALIZE" = "Xy" ]; then
2590 echo "abcde error: Unix pipes not compatible with normalizer"
2591 # FIXME # Do we need to exit or shall we just disable the mode?
2594 if [ X
"$DOENCODE" = "Xn" ]; then
2595 vecho
"Disabling Unix pipes since we are not encoding!"
2598 if [ X
"$LOWDISK" = "Xy" ]; then
2599 vecho
"abcde error: Unix pipes not compatible with lowdisk algorithm"
2604 # Check the encoding format from the ones available in the system, if nothing has been configured in the system.
2605 if [ X
"$OUTPUTTYPE" = "X" ]; then
2606 for DEFAULT_OUTPUT
in $
( echo "$DEFAULT_OUTPUT_BINARIES" |
tr , \
); do
2607 DEFAULT_OUTPUT_FORMAT
="$(echo $DEFAULT_OUTPUT | cut -d ":" -f 1)"
2608 DEFAULT_OUTPUT_BINARY
="$(echo $DEFAULT_OUTPUT | cut -d ":" -f 2)"
2609 if [ -x $
(which $DEFAULT_OUTPUT_BINARY) ] ; then
2610 OUTPUTTYPE
=$DEFAULT_OUTPUT_FORMAT
2611 vecho
"No default output type defined. Autoselecting $OUTPUTTYPE..." >&2
2615 if [ X
"$OUTPUTTYPE" = "X" ]; then
2616 echo "abcde error: no encoder found in the PATH" >&2
2617 echo "hits: are all dependencies installed? has the \$PATH been modified?" >&2
2622 # Decide which CDROM reader we're gonna use
2623 case "$CDROMREADERSYNTAX" in
2625 CDROMREADER
="$CDPARANOIA"
2626 CDROMREADEROPTS
="$CDPARANOIAOPTS"
2629 CDROMREADER
="$CDDA2WAV"
2630 CDROMREADEROPTS
="$CDDA2WAVOPTS"
2633 CDROMREADER
="$DAGRAB"
2634 CDROMREADEROPTS
="$DAGRABOPTS"
2637 CDROMREADER
="$CDDAFS"
2638 CDROMREADEROPTS
="$CDDAFSOPTS"
2642 # There's only one normalize...
2643 case "$NORMALIZERSYNTAX" in
2645 NORMALIZER
="$NORMALIZE"
2646 NORMALIZEROPTS
="$NORMALIZEOPTS"
2650 # Allow -o OUTPUT(1):OPTIONS(1),...,OUTPUT(N):OPTIONS(N) mode of operation
2651 if echo "$OUTPUTTYPE" |
grep ":" > /dev
/null
2>&1 ; then
2652 for OUTPUT
in "$(echo "$OUTPUTTYPE" | tr , \ )"; do
2654 vorbis
:*|ogg
:*) OGGENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
2655 mp3
:*) MP3ENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
2656 flac
:*) FLACENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
2657 spx
:*) SPEEXENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
2658 mpc
:*) MPPENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
2661 for OUTPUT
in "$(echo "$OUTPUTTYPE" | tr , \ )"; do
2662 TEMPOUTPUT
=$
( echo "$OUTPUT" | cut
-d: -f1 )
2663 TEMPOUTPUTTYPE
="${TEMPOUTPUTTYPE:+$TEMPOUTPUTTYPE,}$TEMPOUTPUT"
2665 OUTPUTTYPE
="$TEMPOUTPUTTYPE"
2668 # 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
2670 # Getting ready for multiple output changes
2671 for OUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
2675 [ "$OGGENCODERSYNTAX" = "default" ] && OGGENCODERSYNTAX
=oggenc
2676 [ "$DOTAG" = "y" ] && NEEDCOMMENTER
=y
2677 [ "$REPLAYGAIN" = "y" ] && NEEDVORBISGAIN
=y
2678 OGGOUTPUTCONTAINER
=ogg
2681 [ "$MP3ENCODERSYNTAX" = "default" ] && MP3ENCODERSYNTAX
=lame
2682 [ "$DOTAG" = "y" ] && NEEDTAGGER
=y
2685 [ "$FLACENCODERSYNTAX" = "default" ] && FLACENCODERSYNTAX
=flac
2686 [ "$DOTAG" = "y" ] && NEEDMETAFLAC
=y
2689 [ "$SPEEXENCODERSYNTAX" = "default" ] && SPEEXENCODERSYNTAX
=speexenc
2692 [ "$MPPENCODERSYNTAX" = "default" ] && MPPENCODERSYNTAX
=mppenc
2694 *) echo "abcde error: Invalid OUTPUTTYPE defined" >&2
2700 # decide which encoder
2701 case "$MP3ENCODERSYNTAX" in
2703 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$LAMEOPTS}"
2707 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$GOGOOPTS}"
2711 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$BLADEENCOPTS}"
2712 MP3ENCODER
="$BLADEENC"
2715 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$L3ENCOPTS}"
2719 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$XINGMP3ENCOPTS}"
2720 MP3ENCODER
="$XINGMP3ENC"
2723 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$MP3ENCOPTS}"
2724 MP3ENCODER
="$MP3ENC"
2727 case "$OGGENCODERSYNTAX" in
2729 OGGENCODEROPTS
="${OGGENCODEROPTSCLI:-$VORBIZEOPTS}"
2730 OGGENCODER
="$VORBIZE"
2733 OGGENCODEROPTS
="${OGGENCODEROPTSCLI:-$OGGENCOPTS}"
2734 OGGENCODER
="$OGGENC"
2737 case "$FLACENCODERSYNTAX" in
2739 FLACENCODEROPTS
="${FLACENCODEROPTSCLI:-$FLACOPTS}"
2741 # FLAC streams can be encapsulated on a Ogg transport layer
2742 if echo "$FLACENCODEROPTS" |
egrep -q -- "(^| )--ogg($| )" ;then
2743 echo "abcde error: FLAC on an Ogg container is not yet supported" >&2
2744 echo " due to problem with adding comments to such files" >&2
2746 FLACOUTPUTCONTAINER
=ogg
2748 FLACOUTPUTCONTAINER
=flac
2752 case "$SPEEXENCODERSYNTAX" in
2754 SPEEXENCODEROPTS
="${SPEEXENCODEROPTSCLI:-$SPEEXENCOPTS}"
2755 SPEEXENCODER
="$SPEEXENC"
2758 case "$MPPENCODERSYNTAX" in
2760 MPPENCODEROPTS
="${MPPENCODEROPTSCLI:-$MPPENCOPTS}"
2761 MPPENCODER
="$MPPENC"
2767 if [ "$ID3TAGV" = "1" ]; then
2769 TAGGEROPTS
="$ID3OPTS"
2772 TAGGEROPTS
="$ID3V2OPTS"
2776 case "$CUEREADERSYNTAX" in
2778 CUEREADEROPTS
="${CDROM}"
2783 # Check if both OGGEOUTPUTCONTAINER and FLACOUTPUTCONTAINER are the same, and differentiante them
2784 if [ X
"$OGGOUTPUTCONTAINER" = "Xogg" ] && [ X
"$FLACOUTPUTCONTAINER" = "Xogg" ]; then
2785 echo "abcde error: FLAC on an Ogg container is not yet supported" >&2
2786 echo " due to problem with adding comments to such files" >&2
2788 OGGOUTPUTCONTAINER
=ogg.ogg
2789 FLACOUTPUTCONTAINER
=flac.ogg
2790 vecho
"abcde warning: modified file endings due to conflicting transport layers in Ogg/Vorbis and Ogg/FLAC"
2793 # Clean up nice options (either use '-n NICELEVEL or -NICELEVEL')
2795 if [ "$ENCNICE" ]; then
2796 ENCNICE
="-n $ENCNICE"
2798 if [ "$READNICE" ]; then
2799 READNICE
="-n $READNICE"
2801 if [ "$DISTMP3NICE" ]; then
2802 DISTMP3NICE
="-n $DISTMP3NICE"
2805 # Don't check for stuff if it's not needed
2806 if [ "$REMOTEHOSTS" ]; then
2809 if [ "$DONORMALIZE" = "y" ]; then
2812 if [ "$EJECTCD" = "y" ]; then
2815 if [ ! "$CDDBAVAIL" = "n" ] && [ "$DOCDDB" = "y" ]; then
2818 if [ "$MAKECUEFILE" = "y" ]; then
2822 if [ X
"$CDSPEEDVALUE" != "X" ]; then
2823 case "$CDROMREADERSYNTAX" in
2824 cdparanoia|debug
) CDROMREADEROPTS
="$CDPARANOIAOPTS -S $CDSPEEDVALUE" ;;
2829 # Rippers with USEPIPE support
2830 # FIXME # Include here all the rippers we can figure out support pipes
2833 # Encoders with USEPIPE support
2834 # FIXME # Include here all the encoders we can figure out support pipes
2839 # Figure out if we can use pipes with the ripper/encoder combination
2841 if [ "$USEPIPES" = "y" ]; then
2842 PIPERIPPERSVARCHECK
="PIPE_${CDROMREADER}"
2845 PIPEENCODERSVARCHECK
="PIPE_$MP3ENCODERSYNTAX" ;;
2847 PIPEENCODERSVARCHECK
="PIPE_$OGGENCODERSYNTAX" ;;
2849 PIPEENCODERSVARCHECK
="PIPE_$FLACENCODERSYNTAX" ;;
2851 PIPEENCODERSVARCHECK
="PIPE_$SPEEXENCODER" ;;
2853 PIPEENCODERSVARCHECK
="PIPE_$MPPENCODER" ;;
2855 if [ ! -n "$( eval echo "\$
$PIPERIPPERSVARCHECK" )" ] ; then
2856 echo "abcde error: no support for pipes with given ripper" >&2
2857 echo "read the USEPIPES file from the source tarball to get help." >&2
2858 echo "On a Debian system, it is under /usr/share/doc/abcde/USEPIPES.gz" >&2
2861 if [ ! -n "$( eval echo "\$
$PIPEENCODERSVARCHECK" )" ] ; then
2862 echo "abcde error: no support for pipes with given encoder" >&2
2863 echo "read the USEPIPES file from the source tarball to help" >&2
2864 echo "on a Debian system, read /usr/share/doc/abcde/USEPIPES.gz" >&2
2869 # Make sure a buncha things exist
2870 for X
in $CDROMREADER $CDDISCID ${NEEDTAGGER+$TAGGER} $MP3ENCODER \
2871 $OGGENCODER $FLACENCODER $SPEEXENCODER $MPPENCODER \
2872 ${NEEDHTTPGET+$HTTPGET} ${NEEDDISTMP3+$DISTMP3} \
2873 ${NEEDCOMMENTER+$VORBISCOMMENT} ${NEEDMETAFLAC+$METAFLAC} \
2874 ${NEEDNORMALIZER+$NORMALIZER} ${NEEDEJECT+$EJECT} \
2875 ${NEEDDISKTOOL+disktool} ${NEEDCDSPEED+$CDSPEED} \
2876 ${NEEDVORBISGAIN+$VORBISGAIN} ${NEEDCUEREADER+$CUEREADER}
2878 # Cut off the command-line options we just added in
2879 X
=$
(echo $X | cut
-d' ' -f2)
2880 if [ "$(which $X)" = "" ]; then
2881 echo "abcde error: $X is not in your path." >&2
2883 elif [ ! -x $
(which $X) ]; then
2884 echo "abcde error: $X is not executable." >&2
2889 CDROMREADER
="$CDROMREADER $CDROMREADEROPTS"
2890 CDDBTOOL
="$CDDBTOOL $CDDBTOOLOPTS"
2891 HTTPGET
="$HTTPGET $HTTPGETOPTS"
2893 # And last but not least, check if we can diff between files
2894 if [ -x $
(which $DIFF) ]; then :; else
2895 vecho
"[WAR] Disabling diff since we cannot find it in the \$PATH..."
2899 # Here it used to say:
2900 # One thousand lines in, we can start doing stuff with things
2901 # Well, right now we are at line 2736 ;)
2903 # Export needed things so they can be read in this subshell
2904 export CDDBTOOL ABCDETEMPDIR TRACKQUEUE LOWDISK EJECTCD EJECT EJECTOPTS
2905 export CDROM CDDBDATA REMOTEHOSTS MAXPROCS HTTPGET MD5SUM
2907 # User-definable function to set some things. Use it for
2908 # - closing the CD tray with eject -t
2909 # - set the CD speed value with eject -x
2910 vecho
-n "Executing customizable pre-read function... "
2912 pre_read
# Execute the user-defined pre-read funtion. Close the CD with it.
2916 do_discid
# Get ABCDETEMPDIR created and status file initialized
2918 if [ "$DOCDDB" = "y" ]; then
2919 if [ $CDDBUSELOCAL = "y" ]; then
2922 if checkstatus cddb-choice
> /dev
/null
; then
2925 if [ ! "$CDDBLOCALSUCCESS" = "y" ] ; then
2933 eval "$($CDDBTOOL parse "$CDDBDATA")"
2936 # Before reading tracks, we set the speed of the device
2938 if [ X
"$CDSPEEDVALUE" != "X" ]; then
2939 case "$CDROMREADERSYNTAX" in
2940 cdparanoia|debug
) : ;;
2945 # Define the first and last track, since we might need them later in several places
2946 FIRSTTRACK
=$
( get_first
$TRACKQUEUE )
2947 LASTTRACK
=$
( get_last
$TRACKQUEUE )
2949 if [ -f "$ABCDETEMPDIR/status" ] && [ X
"$ERASEENCODEDSTATUS" = "Xy" ]; then
2950 mv "$ABCDETEMPDIR/status" "$ABCDETEMPDIR/status.old"
2951 grep -v ^encodetracklocation-
< "$ABCDETEMPDIR/status.old" \
2952 |
grep -v ^encode-output
> "$ABCDETEMPDIR/status"
2955 # Create playlist if needed (backgroundable) and start reading in tracks
2959 if [ ! "$ONETRACK" = "y" ]; then
2960 if [ "$DOPLAYLIST" = "y" ]; then
2961 echo Creating playlist...
>&2
2966 # For the lowdisk option, only one program is running at once so the encoder
2967 # can be unsilenced right away.
2968 if [ "$LOWDISK" = "y" ] ||
[ "$ONETRACK" = "y" ]; then
2969 echo "encode-output=loud" >> "$ABCDETEMPDIR/status"
2972 if [ "$ONETRACK" = "y" ]; then
2973 TRACKS
="$FIRSTTRACK"
2974 if checkstatus readtrack-
$FIRSTTRACK; then :; else
2975 do_cdread onetrack
$FIRSTTRACK $LASTTRACK
2978 for UTRACKNUM
in $TRACKQUEUE
2980 if [ "$DOREAD" = "y" ]; then
2981 if [ "$USEPIPES" = "y" ]; then
2982 if checkstatus readencodetrack-
$UTRACKNUM; then :; else
2983 # Read, pipe, shut up!
2984 do_cdread
$UTRACKNUM | do_encode
$UTRACKNUM %local0
% > /dev
/null
2>&1
2987 if checkstatus readtrack-
$UTRACKNUM; then :; else
2988 do_cdread
$UTRACKNUM
2990 if [ "$?" != "0" ]; then
2991 # CD read failed - don't give the goahead to
2998 if [ "$BATCH" = "y" ]; then
3001 echo NEXTTRACK
# Get the encoder machine churning again
3002 if [ "$DOREAD" = "y" ]; then
3003 if [ "$LOWDISK" = "y" ] && [ "$DOENCODE" = "y" ]; then
3004 until checkstatus encodetrack-
$UTRACKNUM
3006 if checkerrors encodetrack-
$UTRACKNUM; then
3017 # Now that we're done the encoding can be loud again -
3018 # if we're not using SMP.
3019 if [ "$MAXPROCS" = "1" ]; then
3020 echo "encode-output=loud" >> "$ABCDETEMPDIR/status"
3023 # All tracks read, start encoding.
3024 if [ "$BATCH" = "y" ] ||
[ "$ONETRACK" = "y" ]; then
3028 # Execute the user-defined post_read funtion before ejecting CD
3031 # We are now finished with the cdrom - it can be safely ejected. Note that
3032 # abcde will not have completed yet.
3033 if [ "$EJECTCD" = "y" ] && [ -x $
(which $EJECT) ]; then
3034 # We check if the disk we are processing is actually the disk inside the
3035 # CD tray. If not, we do not eject the CD, since it might be so that the
3036 # user ejected it manually.
3037 #CURRENTTRACKINFO=$($CDDISCID $CDROM)
3038 #if if [ "$?" != "1" ] && [ "$CURRENTTRACKINFO" = "$TRACKINFO" ] ; then
3039 # More FreeBSD bits.
3040 if [ X
"$(uname)" = X
"FreeBSD" ] ; then
3041 # FreeBSD eject uses the EJECT environment variable to name the CDROM
3042 # but in this script EJECT is in the envionment and names the program
3045 # The FreeBSD eject needs "adc0" not "/dev/adc0c"
3046 cd="$(echo $CDROM | sed -e 's=.*/==;s=[a-h]$==;')"
3047 $eject $EJECTOPTS $cd
3048 elif [ X
"$(uname)" = X
"Darwin" ] ; then
3049 disktool
-e ${CDROM#/dev/} 0
3051 $EJECT $EJECTOPTS $CDROM
3058 ## Do we need to pre-process
3059 #if [ x"$PREPROCESS" = "x" ] ; then
3062 # for PRETRACKNUM in $TRACKQUEUE
3065 # if [ "$GOAHEAD" = "NO" ]; then break; fi
3067 # until [ $PREPROCEED ]
3069 # if checkstatus readtrack-$PRETRACKNUM; then PREPROCEED=y; break; fi
3070 # # all locations are working, wait and try again later
3071 # if [ ! $PREPROCEED ]; then sleep 3; fi
3073 # ( do_preprocess $PRETRACKNUM
3081 # In batch mode, we want all tracks to be read first.
3082 if [ "$BATCH" = "y" ]; then
3083 read GOAHEAD
# For blocking - will contain either "NO" or "NEXTTRACK"
3084 if [ "$GOAHEAD" = "NO" ]; then break; fi
3085 for LASTTRACK
in $TRACKQUEUE; do :; done
3086 if checkstatus readtrack-
$LASTTRACK; then
3087 if [ "$DONORMALIZE" = "y" ]; then
3088 if checkstatus normalizetrack-
$LASTTRACK; then :; else do_batch_normalize
; fi
3089 if checkerrors batch-normalize
; then exit; fi
3091 if [ "$DOENCODE" = "y" ]; then
3092 if checkstatus encodetrack-
$LASTTRACK; then :; else do_batch_encode
; fi
3093 if checkerrors batch-encode
; then exit; fi
3098 # If we are using ONETRACK, we can proceed with the normal encoding using just the $FIRSTTRACK as TRACKQUEUE
3099 if [ "$ONETRACK" = "y" ] ; then
3100 TRACKQUEUE
="$FIRSTTRACK"
3101 TRACKS
="$FIRSTTRACK"
3104 # Do the encoding, including parallelization of remote encoding
3105 # Figure out where each track is going to be encoded
3106 ENCODELOCATIONS
="$(echo $REMOTEHOSTS | tr , ' ')"
3107 if [ "$MAXPROCS" != "0" ]; then
3108 for NUM
in $
(f_seq_row
1 "$MAXPROCS")
3110 ENCODELOCATIONS
="$ENCODELOCATIONS %local$NUM%"
3114 ENCODELOCATIONS
=$
(echo $ENCODELOCATIONS)
3115 for UTRACKNUM
in $TRACKQUEUE
3118 read GOAHEAD
# For blocking - will contain either "NO" or "NEXTTRACK"
3119 if [ "$GOAHEAD" = "NO" ]; then break; fi
3120 # find out where this track is to be encoded
3121 if [ "$DOENCODE" = "y" -a "$USEPIPES" != "y" ]; then
3122 # Make sure we have a place to encode this, if not, exit stage right
3123 if [ -z "$ENCODELOCATIONS" ]; then
3129 for LOCATION
in $ENCODELOCATIONS
3131 PREVIOUSTRACK
="$(checkstatus encodetracklocation-$LOCATION)"
3132 # check first if a track has ever been assigned to this location
3133 if [ -z "$PREVIOUSTRACK" ]; then PROCEED
=y
; break; fi
3134 # If it errored out, rebuild $ENCODELOCATIONS without this location in it
3135 if checkerrors encodetrack-
$PREVIOUSTRACK; then
3136 for TEMPLOCATION
in $ENCODELOCATIONS
3138 if [ "$TEMPLOCATION" != "$LOCATION" ]; then
3139 TEMPENCODELOCATIONS
="$TEMPENCODELOCATIONS $TEMPLOCATION"
3142 ENCODELOCATIONS
=$
(echo $TEMPENCODELOCATIONS)
3147 # We're still here, this location must have been previously assigned,
3148 # and last completed without error - check if it's done with the
3149 # previous track yet
3150 if checkstatus encodetrack-
$PREVIOUSTRACK; then PROCEED
=y
; break; fi
3152 # all locations are working, wait and try again later
3153 if [ ! $PROCEED ]; then sleep 3; fi
3155 # Record the location we're about to encode the next track at
3156 echo "encodetracklocation-$LOCATION=$UTRACKNUM" >> "$ABCDETEMPDIR/status"
3158 # Don't proceed with the rest of the loop if we can't encode
3159 if [ "$ABORT" ]; then continue; fi
3160 # Set TRACKNUM, TRACKNAME
3161 if [ -e "$CDDBDATA" ]; then
3162 if [ "$ONETRACK" = "y" ]; then
3164 TRACKNUM
="$FIRSTTRACK"
3167 # TRACKNUM=$(printf %0.${TRACKNUMPADDING}d $(expr ${UTRACKNUM} + 0))
3169 CDDBTRACKNUM
=$
(expr $UTRACKNUM - 1)
3170 #TRACKNAME="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
3171 do_getcddbinfo TRACKNAME
3175 # You can't encode a file which needs to be normalized before finishing
3176 # You can't tag a file before it's finished encoding -
3177 # thus all of this is backgrounded together
3179 if [ "$DONORMALIZE" = "y" ]; then
3180 if checkstatus readtrack-
$UTRACKNUM; then
3181 if checkstatus normalizetrack-
$UTRACKNUM; then :; else do_normalize
$UTRACKNUM; fi
3184 if [ "$DOENCODE" = "y" -a "$USEPIPES" != "y" ]; then
3185 if checkstatus readtrack-
$UTRACKNUM; then
3186 #if checkstatus encodetrack-$UTRACKNUM; then :; else do_encode $UTRACKNUM $LOCATION; fi
3187 if [ "$DONORMALIZE" = "y" ]; then
3188 if checkstatus normalizetrack-
$UTRACKNUM; then
3189 if checkstatus encodetrack-
$UTRACKNUM; then :; else do_encode
$UTRACKNUM $LOCATION $OUTPUT; fi
3192 if checkstatus encodetrack-
$UTRACKNUM; then :; else do_encode
$UTRACKNUM $LOCATION $OUTPUT; fi
3196 if [ "$DOTAG" = "y" ]; then
3197 if checkstatus encodetrack-
$UTRACKNUM; then
3198 if checkstatus tagtrack-
$UTRACKNUM; then :; else do_tag
$UTRACKNUM; fi
3200 # Lets tag the cue file
3201 if checkstatus cleancuefile
>/dev
/null
; then :; else
3202 if checkstatus cuefile
>/dev
/null
; then
3207 if [ "$DOMOVE" = "y" ]; then
3208 if checkstatus tagtrack-
$UTRACKNUM; then
3209 if checkstatus movetrack-
$UTRACKNUM; then :; else do_move
$UTRACKNUM; fi
3216 # Go through it again and make sure there's no distmp3 stragglers, otherwise
3217 # we'll delete the files they're working on
3218 ## FIXME ## Check also for files which are encoded using PIPEs.
3219 if [ "$DOENCODE" = "y" -a "$USEPIPES" != "y" ]; then
3224 for LOCATION
in $ENCODELOCATIONS
3226 CHECKTRACK
="$(checkstatus encodetracklocation-$LOCATION)"
3227 # "How can he give us a status update, if he's DEAD?"
3228 if checkstatus encodetrack-
$CHECKTRACK; then
3231 # Nothing to see here please go quietly back to your homes
3232 if [ -z "$CHECKTRACK" ]; then continue; fi
3233 # You're still here? Maybe there is something...
3234 if checkstatus encodetrack-
$CHECKTRACK; then :; else PROCEED
= ; break; fi
3237 if [ ! $PROCEED ]; then sleep 5; fi
3240 # If the above didn't catch the stragglers, this will
3242 if [ "$DOREPLAYGAIN" = "y" ]; then
3245 # Check to see if run_command logged any errors
3246 if [ -f "$ABCDETEMPDIR/errors" ]; then
3247 echo "The following commands failed to run:"
3248 cat "$ABCDETEMPDIR/errors"
3252 if [ "$KEEPWAVS" = "y" ];then
3256 if [ "$DOCLEAN" = "y" ]; then
3257 # Wipe all the evidence
3258 # Gimme gimme gimme some more time!
3260 rm -rf "$ABCDETEMPDIR"
3263 echo "Finished. Not cleaning $ABCDETEMPDIR."