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.
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 while [ $i -ne `expr $2 + 1` ]
94 # Functions to replace the need of awk {print $1} and {print $NF}
97 if [ X
"$1" = "X" ]; then
98 for first
in `cat`; do
109 if [ X
"$1" = "X" ]; then
110 for stdin
in `cat`; do
114 for last
in $@
; do :; done
119 # checkstatus [blurb]
120 # Returns "0" if the blurb was found, returns 1 if it wasn't
121 # Puts the blurb content, if available, on stdout.
122 # Otherwise, returns "".
125 # Take the last line in the status file if there's multiple matches
127 BLURB
=$
(egrep $PATTERN "$ABCDETEMPDIR/status" |
tail -n 1)
129 if [ -z "$BLURB" ]; then
134 # See if there's a = in it
135 if [ "$(echo $BLURB | grep -c =)" != "0" ]; then
136 echo "$(echo $BLURB | cut -f2- -d=)"
142 # checkerrors [blurb]
143 # Returns "0" if the blurb was found (meaning there was an error),
144 # returns 1 if it wasn't (yes this is a little backwards).
145 # Does not print the blurb on stdout.
146 # Otherwise, returns "".
149 if [ -e "$ABCDETEMPDIR/errors" ]; then :; else
152 # Take the last line in the status file if there's multiple matches
154 BLURB
="$(egrep $PATTERN "$ABCDETEMPDIR/errors
" | tail -n 1)"
156 if [ -z "$BLURB" ]; then
157 # negative, we did not have a negative...
160 # affirmative, we had a negative...
166 # Finds the right pager in the system to display a file
170 # Use the debian sensible-pager wrapper to pick the pager
171 # user has requested via their $PAGER environment variable
172 if [ -x "/usr/bin/sensible-pager" ]; then
173 /usr
/bin
/sensible-pager
"$PAGEFILE"
174 elif [ -x "$PAGER" ]; then
175 # That failed, try to load the preferred editor, starting
176 # with their PAGER variable
178 # If that fails, check for less
179 elif [ -x /usr
/bin
/less ]; then
180 /usr
/bin
/less -f "$PAGEFILE"
181 # more should be on all UNIX systems
182 elif [ -x /bin
/more ]; then
183 /bin
/more "$PAGEFILE"
185 # No bananas, just cat the thing
190 # run_command [blurb] [command...]
191 # Runs a command, silently if necessary, and updates the status file
196 # See if this is supposed to be silent
197 if [ "$(checkstatus encode-output)" = "loud" ]; then
201 # Special case for SMP, since
202 # encoder output is never displayed, don't mute echos
203 if [ -z "$BLURB" -a "$MAXPROCS" != "1" ]; then
212 normalize|normalize-audio
)
213 if [ "$RETURN" = "2" ]; then
214 # File was already normalized.
219 if [ "$RETURN" != "0" ]; then
220 # Put an error in the errors file. For various reasons we
221 # can't capture a copy of the program's output but we can
222 # log what we attempted to execute and the error code
223 # returned by the program.
224 if [ "$BLURB" ]; then
227 echo "${TWEAK}returned code $RETURN: $@" >> "$ABCDETEMPDIR/errors"
228 return $RETURN # Do not pass go, do not update the status file
230 if [ "$BLURB" ]; then
231 echo $BLURB >> "$ABCDETEMPDIR/status"
235 # relpath() and slash() are Copyright (c) 1999 Stuart Ballard and
236 # distributed under the terms of the GNU GPL v2 or later, at your option
238 # Function to determine if a word contains a slash.
247 # Function to give the relative path from one file to another.
248 # Usage: relpath fromfile tofile
249 # eg relpath music/Artist/Album.m3u music/Artist/Album/Song.mp3
250 # (the result would be Album/Song.mp3)
251 # Output is relative path to $2 from $1 on stdout
253 # This code has the following restrictions:
254 # Multiple ////s are not collapsed into single /s, with strange effects.
255 # Absolute paths and ../s are handled wrong in FR (but they work in TO)
256 # If FR is a directory it must have a trailing /
264 /*) ;; # No processing is needed for absolute paths
266 # Loop through common prefixes, ignoring them.
267 while slash
"$FR" && [ "$(echo "$FR" | cut -d/ -f1)" = "$(echo "$TO" | cut -d/ -f1)" ]
269 FR
="$(echo "$FR" | cut -d/ -f2-)"
270 TO
="$(echo "$TO" | cut -d/ -f2-)"
272 # Loop through directory portions left in FR, adding appropriate ../s.
275 FR
="$(echo "$FR" | cut -d/ -f2-)"
285 # Finds an specific field from cddbinfo
287 # TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2 -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')
288 # TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2 -d= | tr -d \[:cntrl:\])
289 # TRACKNAME="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
295 TRACKNAME
="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
298 TRACKNAME
="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
304 # Get the track number we are going to use for different actions
307 if [ -n "$STARTTRACKNUMBER" ] ; then
308 # Get the trackpadding from the current track
309 CURRENTTRACKPADDING
=$
(echo -n $UTRACKNUM |
wc -c)
310 TRACKNUM
=$
( printf %0.
${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
312 TRACKNUM
=${UTRACKNUM}
318 run_command
"" echo "Adding reply-gain information..."
319 for OUTPUT
in $
( echo $OUTPUTTYPE |
tr , \
)
322 for UTRACKNUM
in $TRACKQUEUE
324 CDDBTRACKNUM
=$
(expr $UTRACKNUM - 1)
325 do_getcddbinfo TRACKNAME
327 TRACKFILE
=$
(mungefilename
"$TRACKNAME")
328 ARTISTFILE
=$
(mungefilename
"$TRACKARTIST")
329 ALBUMFILE
=$
(mungefilename
"$DALBUM")
331 if [ "$VARIOUSARTISTS" = "y" ]; then
332 OUTPUTFILE
=$
(eval echo $VAOUTPUTFORMAT)
334 OUTPUTFILE
=$
(eval echo $OUTPUTFORMAT)
336 OUTPUTFILES
="$OUTPUTDIR/$OUTPUTFILE.$OUTPUT $OUTPUTFILES"
343 echo vorbisgain-
$OUTPUT >> "$ABCDETEMPDIR/status"
345 echo vorbisgain
>> "$ABCDETEMPDIR/status"
348 # This code splits the a Various Artist track name from one of the following
351 # forward: Artist / Track
352 # forward-dash: Artist - Track
353 # reverse: Track / Artist
354 # reverse-dash: Track - Artist
355 # colon: Artist: Track
356 # trailing-paren: Artist (Track)
359 # VARIOUSARTISTS, VARIOUSARTISTSTYLE, TRACKNAME, TRACKARTIST
362 if [ "$VARIOUSARTISTS" = "y" ] && [ ! "$ONETRACK" = "y" ]; then
363 case "$VARIOUSARTISTSTYLE" in
365 DTITLEARTIST
=$
(echo "$TRACKNAME" |
sed 's- / -~-g')
366 TRACKARTIST
=$
(echo "$DTITLEARTIST" | cut
-f1 -d~
)
367 TRACKNAME
=$
(echo "$DTITLEARTIST" | cut
-f2 -d~
)
370 DTITLEARTIST
=$
(echo "$TRACKNAME" |
sed 's, - ,~,g')
371 TRACKARTIST
=$
(echo "$DTITLEARTIST" | cut
-f1 -d~
)
372 TRACKNAME
=$
(echo "$DTITLEARTIST" | cut
-f2 -d~
)
375 DTITLEARTIST
=$
(echo "$TRACKNAME" |
sed 's- / -~-g')
376 TRACKARTIST
=$
(echo "$DTITLEARTIST" | cut
-f2 -d~
)
377 TRACKNAME
=$
(echo "$DTITLEARTIST" | cut
-f1 -d~
)
380 DTITLEARTIST
=$
(echo "$TRACKNAME" |
sed 's, - ,~,g')
381 TRACKARTIST
=$
(echo "$DTITLEARTIST" | cut
-f2 -d~
)
382 TRACKNAME
=$
(echo "$DTITLEARTIST" | cut
-f1 -d~
)
385 DTITLEARTIST
=$
(echo "$TRACKNAME" |
sed 's-: -~-g')
386 TRACKARTIST
=$
(echo "$DTITLEARTIST" | cut
-f1 -d~
)
387 TRACKNAME
=$
(echo "$DTITLEARTIST" | cut
-f2 -d~
)
390 DTITLEARTIST
=$
(echo "$TRACKNAME" |
sed 's,^\(.*\) (\(.*\)),\1~\2,')
391 TRACKARTIST
=$
(echo "$DTITLEARTIST" | cut
-f2 -d~
)
392 TRACKNAME
=$
(echo "$DTITLEARTIST" | cut
-f1 -d~
)
395 elif [ "$VARIOUSARTISTS" = "y" ] && [ "$ONETRACK" = "y" ]; then
396 TRACKARTIST
="Various"
398 TRACKARTIST
="$DARTIST"
403 local genre
=$
(echo "${@}" |
tr '[A-Z]' '[a-z]')
407 "classic rock") id
=1 ;;
425 "industrial") id
=19 ;;
426 "alternative") id
=20 ;;
428 "death metal") id
=22 ;;
430 "soundtrack") id
=24 ;;
431 "euro-techno") id
=25 ;;
435 "jazz+funk") id
=29 ;;
438 "classical") id
=32 ;;
439 "instrumental") id
=33 ;;
443 "sound clip") id
=37 ;;
446 "alt. rock") id
=40 ;;
451 "meditative") id
=45 ;;
452 "instrum. pop") id
=46 ;;
453 "instrum. rock") id
=47 ;;
457 "techno-indust.") id
=51 ;;
458 "electronic") id
=52 ;;
460 "eurodance") id
=54 ;;
462 "southern rock") id
=56 ;;
467 "christian rap") id
=61 ;;
468 "pop/funk"|
"pop / funk") id
=62 ;;
470 "native american") id
=64 ;;
473 "psychadelic") id
=67 ;;
475 "showtunes") id
=69 ;;
479 "acid punk") id
=73 ;;
480 "acid jazz") id
=74 ;;
484 "rock & roll") id
=78 ;;
485 "hard rock") id
=79 ;;
487 "folk/rock") id
=81 ;;
488 "national folk") id
=82 ;;
495 "bluegrass") id
=89 ;;
496 "avantgarde") id
=90 ;;
497 "gothic rock") id
=91 ;;
498 "progress. rock") id
=92 ;;
499 "psychadel. rock") id
=93 ;;
500 "symphonic rock") id
=94 ;;
501 "slow rock") id
=95 ;;
504 "easy listening") id
=98 ;;
510 "chamber music") id
=104 ;;
512 "symphony") id
=106 ;;
513 "booty bass") id
=107 ;;
515 "porn groove") id
=109 ;;
517 "slow jam") id
=111 ;;
521 "folklore") id
=115 ;;
523 "power ballad") id
=117 ;;
524 "rhythmic soul") id
=118 ;;
525 "freestyle") id
=119 ;;
527 "punk rock") id
=121 ;;
528 "drum solo") id
=122 ;;
529 "a capella") id
=123 ;;
530 "euro-house") id
=124 ;;
531 "dance hall") id
=125 ;;
533 "drum & bass") id
=127 ;;
534 "club-house") id
=128 ;;
535 "hardcore") id
=129 ;;
539 "negerpunk") id
=133 ;;
540 "polsk punk") id
=134 ;;
542 "christian gangsta rap") id
=136 ;;
543 "heavy metal") id
=137 ;;
544 "black metal") id
=138 ;;
545 "crossover") id
=139 ;;
546 "contemporary christian")id
=140 ;;
547 "christian rock") id
=141 ;;
548 "merengue") id
=142 ;;
550 "thrash metal") id
=144 ;;
553 "synthpop") id
=147 ;;
554 "rock/pop"|
"rock / pop") id
=148 ;;
561 # do_tag [tracknumber]
562 # id3 tags a filename
564 # TRACKS, TRACKNAME, TRACKARTIST, TAGGER, TAGGEROPTS, VORBISCOMMENT, METAFLAC,
565 # COMMENT, DALBUM, DARTIST, CDYEAR, CDGENRE (and temporarily) ID3TAGV
568 COMMENTOUTPUT
="$(eval echo ${COMMENT})"
569 run_command
'' echo "Tagging track $1 of $TRACKS: $TRACKNAME..."
570 # If we want to start the tracks with a given number, we need to modify the
571 # TRACKNUM value before evaluation
572 # if [ -n "$STARTTRACKNUMBER" -a -n "$STARTTRACKNUMBERTAG" ] ; then
573 # # Get the trackpadding from the current track
574 # CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c)
575 # TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
577 if [ -n "$STARTTRACKNUMBERTAG" ] ; then
580 for OUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
584 # id3v2 v0.1.9 claims to have solved the -c bug, so we merge both id3 and id3v2
585 GENREID
=$
(do_getgenreid
"${CDGENRE}")
590 # FIXME # track numbers in mp3 come with 1/10, so we cannot happily substitute them with $TRACKNUM
591 run_command tagtrack-
$OUTPUT-$1 $TAGGER $TAGGEROPTS --commen=::"$COMMENTOUTPUT" \
592 -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" -Y "$CDYEAR" \
593 -G "$GENREID" -n "${TRACKNUM:-$1}" "${TRACKNUM:+-N $TRACKS}" \
594 "${ENCODING:+--set-encoding=$ENCODING}"
595 "$ABCDETEMPDIR/track$1.$OUTPUT"
598 # FIXME # track numbers in mp3 come with 1/10, so we cannot happily substitute them with $TRACKNUM
599 run_command tagtrack-
$OUTPUT-$1 $TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \
600 -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" -y "$CDYEAR" \
601 -g "$GENREID" -T "${TRACKNUM:-$1/$TRACKS}" \
602 "$ABCDETEMPDIR/track$1.$OUTPUT"
607 case "$OGGENCODERSYNTAX" in
609 # vorbiscomment can't do in-place modification, mv the file first
610 if [ -f "$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER" -a ! -f "$ABCDETEMPDIR/track$1.uncommented.$OGGOUTPUTCONTAINER" ]; then
611 mv "$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER" "$ABCDETEMPDIR/track$1.uncommented.$OGGOUTPUTCONTAINER"
614 # These are from http://www.xiph.org/ogg/vorbis/doc/v-comment.html
615 echo ARTIST
="$TRACKARTIST"
617 echo TITLE
="$TRACKNAME"
618 if [ -n "$CDYEAR" ]; then
621 if [ -n "$CDGENRE" ]; then
622 echo GENRE
="$CDGENRE"
624 echo TRACKNUMBER
=${TRACKNUM:-$1}
625 echo CDDB
=$CDDBDISCID
626 if [ "$(eval echo ${COMMENT})" != "" ]; then
627 case "$COMMENTOUTPUT" in
628 *=*) echo "$COMMENTOUTPUT";;
629 *) echo COMMENT
="$COMMENTOUTPUT";;
632 ) | run_command tagtrack-
$OUTPUT-$1 $VORBISCOMMENT $VORBISCOMMENTOPTS -w \
633 "$ABCDETEMPDIR/track$1.uncommented.$OGGOUTPUTCONTAINER" "$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER"
634 # Doublecheck that the commented file was created successfully before wiping the original
635 if [ -f "$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER" ]; then
636 rm -f "$ABCDETEMPDIR/track$1.uncommented.$OGGOUTPUTCONTAINER"
638 mv "$ABCDETEMPDIR/track$1.uncommented.$OGGOUTPUTCONTAINER" "$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER"
645 echo ARTIST
="$TRACKARTIST"
647 echo TITLE
="$TRACKNAME"
648 if [ -n "$CDYEAR" ]; then
651 if [ -n "$CDGENRE" ]; then
652 echo GENRE
="$CDGENRE"
654 echo TRACKNUMBER
="${TRACKNUM:-$1}"
655 echo CDDB
="$CDDBDISCID"
656 if [ "$(eval echo ${COMMENT})" != "" ]; then
657 case "$COMMENTOUTPUT" in
658 *=*) echo "$COMMENTOUTPUT";;
659 *) echo COMMENT
="$COMMENTOUTPUT";;
662 ) | run_command tagtrack-
$OUTPUT-$1 $METAFLAC $METAFLACOPTS --import-tags-from=- "$ABCDETEMPDIR/track$1.$FLACOUTPUTCONTAINER"
665 run_command tagtrack-
$OUTPUT-$1 true
668 run_command tagtrack-
$OUTPUT-$1 true
672 if checkerrors
"tagtrack-(.{3,4})-$1"; then
673 run_command tagtrack-
$1 false
675 run_command tagtrack-
$1 true
682 # OUTPUTTYPE, {FOO}ENCODERSYNTAX, ENCNICE, ENCODER, ENCODEROPTS
685 # The commands here don't go through run_command because they're never supposed to be silenced
686 echo "Batch encoding tracks: $TRACKQUEUE"
687 OUTPUT
=$
(echo $OUTPUTTYPE |
grep "mp3" )
690 case "$MP3ENCODERSYNTAX" in
695 for UTRACKNUM
in $TRACKQUEUE
697 TRACKFILES
="$TRACKFILES track$UTRACKNUM.wav"
699 nice
$ENCNICE $MP3ENCODER $MP3ENCODEROPTS `[ "$MP3ENCODER" = "lame" ] && echo "--nogap"` $TRACKFILES
701 if [ "$RETURN" != "0" ]; then
702 echo "batch-encode: $ENCODER returned code $RETURN" >> errors
704 for UTRACKNUM
in $TRACKQUEUE
706 echo encodetrack-
$UTRACKNUM >> status
714 # Other encoders fall through to normal encoding as the tracks
715 # have not been entered in the status file.
718 # do_encode [tracknumber] [hostname]
719 # If no hostname is specified, encode locally
721 # TRACKS, TRACKNAME, TRACKARTIST, DISTMP3, DISTMP3OPTS, {FOO}ENCODERSYNTAX, OUTPUTTYPE, ENCODEROPTS, DALBUM, DARTIST, ENCNICE, CDYEAR, CDGENRE, COMMENT
724 if [ "$USEPIPES" = "y" ]; then
727 TEMPARG
="PIPE_$MP3ENCODERSYNTAX"
730 TEMPARG
="PIPE_$OGGENCODERSYNTAX"
733 TEMPARG
="PIPE_$FLACENCODERSYNTAX"
736 TEMPARG
="PIPE_$SPEEXENCODER"
739 TEMPARG
="PIPE_$MPPENCODER"
742 IN
="$( eval echo "\$
$TEMPARG" )"
744 IN
="$ABCDETEMPDIR/track$1.wav"
747 case "$MP3ENCODERSYNTAX" in
748 # FIXME # check if mp3enc needs -if for pipes
762 # We need IN to proceed, if we are not using pipes.
763 if [ -s "$IN" -o X
"$USEPIPES" = "Xy" ] ; then
764 for OUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
768 OUT
="$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER"
771 OUT
="$ABCDETEMPDIR/track$1.$FLACOUTPUTCONTAINER"
774 OUT
="$ABCDETEMPDIR/track$1.$OUTPUT"
777 if [ X
"$USEPIPES" = "Xy" ]; then
780 run_command
'' echo "Encoding track $1 of $TRACKS: $TRACKNAME..."
781 RUN_COMMAND
="run_command encodetrack-$OUTPUT-$1"
787 case "$MP3ENCODERSYNTAX" in
788 lame|gogo
) $RUN_COMMAND nice
$ENCNICE $MP3ENCODER $MP3ENCODEROPTS "$IN" "$OUT" ;;
789 bladeenc
) $RUN_COMMAND nice
$ENCNICE $MP3ENCODER $MP3ENCODEROPTS -quit "$IN" ;;
790 l3enc|xingmp3enc
) $RUN_COMMAND nice
$ENCNICE $MP3ENCODER "$IN" "$OUT" $MP3ENCODEROPTS ;;
791 # FIXME # Relates to the previous FIXME since it might need the "-if" removed.
792 mp3enc
) $RUN_COMMAND nice
$ENCNICE $MP3ENCODER -if "$IN" -of "$OUT" $MP3ENCODEROPTS ;;
796 $RUN_COMMAND nice
$DISTMP3NICE $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" >/dev
/null
2>&1
803 case "$OGGENCODERSYNTAX" in
804 vorbize
) $RUN_COMMAND nice
$ENCNICE $OGGENCODER $OGGENCODEROPTS -w "$OUT" "$IN" ;;
805 oggenc
) $RUN_COMMAND nice
$ENCNICE $OGGENCODER $OGGENCODEROPTS -o "$OUT" "$IN" ;;
809 $RUN_COMMAND nice
$DISTMP3NICE $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" >/dev
/null
2>&1
816 case "$FLACENCODERSYNTAX" in
817 flac
) $RUN_COMMAND nice
$ENCNICE $FLACENCODER $FLACENCODEROPTS -o "$OUT" "$IN" ;;
823 echo "$DISTMP3 $DISTMP3OPTS $2 $IN $OUT >/dev/null 2>&1"
824 $RUN_COMMAND nice
$DISTMP3NICE $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" > /dev
/null
2>&1
829 if [ "$(eval echo ${COMMENT})" != "" ]; then
832 *) COMMENT
="COMMENT=$COMMENT" ;;
834 COMMENT
="--comment \"$COMMENT\""
836 # Quick hack to avoid tagging Ogg/Speex, since there is no other way to tag than inline tagging
837 if [ ! "$DOTAG" = "y" ]; then
838 $RUN_COMMAND nice
$ENCNICE $SPEEXENCODER $SPEEXENCODEROPTS --author "$TRACKARTIST" --title "$TRACKNAME" "$COMMENT" "$IN" "$OUT"
840 $RUN_COMMAND nice
$ENCNICE $SPEEXENCODER $SPEEXENCODEROPTS "$IN" "$OUT"
844 # MPP/MP+(Musepack) format (.mpc) is done locally, with inline
846 # I tried compiling the mppenc from corecodecs.org and got some
847 # errors, so I have not tried it myself.
848 ## FIXME ## Needs some cleanup to determine if an empty tag sent
849 ## FIXME ## to the encoder ends up empty.
850 $RUN_COMMAND nice
$ENCNICE $MPPENCODER $MPPENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" "$IN" "$OUT"
854 # Only remove .wav if the encoding succeeded
855 if checkerrors
"encodetrack-(.{3,4})-$1"; then
856 run_command encodetrack-
$1 false
858 run_command encodetrack-
$1 true
859 if [ ! "$KEEPWAVS" = "y" ] ; then
864 run_command
"" echo "HEH! The file we were about to encode disappeared:"
865 run_command
"" echo ">> $IN"
866 run_command encodetrack-
$1 false
870 # do_preprocess [tracknumber]
872 # TRACKS, TRACKNAME, TRACKARTIST, DISTMP3, DISTMP3OPTS, {FOO}ENCODERSYNTAX, OUTPUTTYPE, ENCODEROPTS, DALBUM, DARTIST, ENCNICE, CDYEAR, CDGENRE, COMMENT
875 # IN="$ABCDETEMPDIR/track$1.wav"
876 # # We need IN to proceed.
877 # if [ -s "$IN" ] ; then
878 # for OUTPUT in $(echo $OUTPUTTYPE | tr , \ )
880 # #OUT="$ABCDETEMPDIR/track$1.$OUTPUT"
881 # run_command '' echo "Pre-processing track $1 of $TRACKS..."
882 # case "$POSTPROCESSFORMAT" in
884 # run_command preprocess-$OUTPUT-$1 nice $PRENICE $WAV_PRE $IF $OF ;;
886 # run_command preprocess-$OUTPUT-$1 nice $PRENICE $MP3_PRE $IF $OF ;;
888 # run_command preprocess-$OUTPUT-$1 nice $PRENICE $OGG_PRE $IF $OF ;;
890 # run_command preprocess-$OUTPUT-$1 nice $PRENICE $FLAC_PRE $IF $OF ;;
892 # run_command preprocess-$OUTPUT-$1 nice $PRENICE $SPX_PRE $IF $OF ;;
895 # # Only remove .wav if the encoding succeeded
896 # if checkerrors "preprocess-(.{3,4})-$1"; then
897 # run_command preprocess-$1 false
899 # run_command preprocess-$1 true
902 # if [ "$(checkstatus encode-output)" = "loud" ]; then
903 # echo "HEH! The file we were about to pre-process disappeared:"
906 # run_command preprocess-$1 false
911 # do_postprocess [tracknumber]
913 # TRACKS, TRACKNAME, TRACKARTIST, DISTMP3, DISTMP3OPTS, {FOO}ENCODERSYNTAX, OUTPUTTYPE, ENCODEROPTS, DALBUM, DARTIST, ENCNICE, CDYEAR, CDGENRE, COMMENT
916 # for POSTPROCESSFORMAT in $(echo $POSTPROCESSFORMATS | tr , \ )
918 # IN="$ABCDETEMPDIR/track$1.$POSTPROCESSFORMAT"
919 # # We need IN to proceed.
920 # if [ -s "$IN" ] ; then
921 # #OUT="$ABCDETEMPDIR/track$1.$OUTPUT"
922 # run_command '' echo "Post-processing track $1 of $TRACKS..."
923 # case "$POSTPROCESSFORMAT" in
925 # run_command postprocess-$OUTPUT-$1 nice $POSTNICE $MP3_POST $IF $OF ;;
927 # run_command postprocess-$OUTPUT-$1 nice $POSTNICE $OGG_POST $IF $OF ;;
929 # run_command postprocess-$OUTPUT-$1 nice $POSTNICE $FLAC_POST $IF $OF ;;
931 # run_command postprocess-$OUTPUT-$1 nice $POSTNICE $SPX_POST $IF $OF ;;
933 # # Only remove .wav if the encoding succeeded
934 # if checkerrors "postprocess-(.{3,4})-$1"; then
935 # run_command postprocess-$1 false
937 # run_command postprocess-$1 true
940 # if [ "$(checkstatus encode-output)" = "loud" ]; then
941 # echo "HEH! The file we were about to post-process disappeared:"
944 # run_command postprocess-$1 false
959 # MP3GAIN, MP3GAINOPTS, VORBISGAIN, VORBISGAINOPTS
963 # The commands here don't go through run_command because they're never supposed to be silenced
964 echo "Batch analizing gain in tracks: $TRACKQUEUE"
969 for UTRACKNUM
in $TRACKQUEUE
971 MP3FILES
="$TRACKFILES track$UTRACKNUM.mp3"
973 # XXX: Hard-coded batch option!
974 $NORMALIZER -b $NORMALIZEROPTS $TRACKFILES
976 if [ "$RETURN" != "0" ]; then
977 echo "batch-normalize: $NORMALIZER returned code $RETURN" >> errors
979 for UTRACKNUM
in $TRACKQUEUE
981 echo normalizetrack-
$UTRACKNUM >> status
989 # NORMALIZER, NORMALIZEROPTS
990 do_batch_normalize
()
992 # The commands here don't go through run_command because they're never supposed to be silenced
993 echo "Batch normalizing tracks: $TRACKQUEUE"
998 for UTRACKNUM
in $TRACKQUEUE
1000 TRACKFILES
="$TRACKFILES track$UTRACKNUM.wav"
1002 # XXX: Hard-coded batch option!
1003 $NORMALIZER -b $NORMALIZEROPTS $TRACKFILES
1005 if [ "$RETURN" != "0" ]; then
1006 echo "batch-normalize: $NORMALIZER returned code $RETURN" >> errors
1008 for UTRACKNUM
in $TRACKQUEUE
1010 echo normalizetrack-
$UTRACKNUM >> status
1016 # do_normalize [tracknumber]
1018 # TRACKS, TRACKNAME, NORMALIZER, NORMALIZEROPTS
1021 IN
="$ABCDETEMPDIR/track$1.wav"
1022 if [ -e "$IN" ] ; then
1023 run_command
'' echo "Normalizing track $1 of $TRACKS: $TRACKNAME..."
1024 run_command normalizetrack-
$1 $NORMALIZER $NORMALIZEROPTS "$IN"
1026 if [ "$(checkstatus encode-output)" = "loud" ]; then
1027 echo "HEH! The file we were about to normalize disappeared:"
1030 run_command normalizetrack-
$1 false
"File $IN was not found"
1034 # do_move [tracknumber]
1035 # Deduces the outfile from environment variables
1036 # Creates directory if necessary
1038 # TRACKNUM, TRACKNAME, TRACKARTIST, DALBUM, OUTPUTFORMAT, CDGENRE, CDYEAR
1041 for OUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
1043 # Create ALBUMFILE, ARTISTFILE, TRACKFILE
1044 # Munge filenames as follows:
1049 # Eat control characters
1050 ALBUMFILE
=$
(mungefilename
"$DALBUM")
1051 ARTISTFILE
=$
(mungefilename
"$TRACKARTIST")
1052 TRACKFILE
=$
(mungefilename
"$TRACKNAME")
1053 GENRE
=$
(mungegenre
"$GENRE")
1054 YEAR
=$
(echo $CDYEAR)
1055 # If we want to start the tracks with a given number, we need to modify the
1056 # TRACKNUM value before evaluation
1057 # if [ -n "$STARTTRACKNUMBER" ] ; then
1058 # # Get the trackpadding from the current track
1059 # CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c)
1060 # TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
1062 # TRACKNUM=${UTRACKNUM}
1065 # Supported variables for OUTPUTFORMAT are GENRE, ALBUMFILE, ARTISTFILE,
1066 # TRACKFILE, and TRACKNUM.
1067 if [ "$VARIOUSARTISTS" = "y" ]; then
1068 OUTPUTFILE
=$
(eval echo $VAOUTPUTFORMAT)
1070 OUTPUTFILE
=$
(eval echo $OUTPUTFORMAT)
1072 if checkerrors
"tagtrack-$OUTPUT-$1"; then :; else
1073 # Once we know the specific output was successful, we can change the OUTPUT to the value containing the container
1076 OUTPUT
=$OGGOUTPUTCONTAINER
1079 OUTPUT
=$FLACOUTPUTCONTAINER
1082 # Check that the directory for OUTPUTFILE exists, if it doesn't, create it
1083 OUTPUTFILEDIR
=$
(dirname "$OUTPUTDIR/$OUTPUTFILE")
1084 # mkdir -p shouldn't return an error if the directory already exists
1085 mkdir
-p "$OUTPUTFILEDIR"
1086 run_command movetrack-
$1 mv "$ABCDETEMPDIR/track$1.$OUTPUT" "$OUTPUTDIR/$OUTPUTFILE.$OUTPUT"
1087 # Lets move the cue file
1088 if CUEFILE
=$
(checkstatus cuefile
) >/dev
/null
; then
1089 if [ -r "$ABCDETEMPDIR/$CUEFILE" ]; then
1090 if checkstatus movecue-
$OUTPUT; then :; else
1091 # Silence the Copying output since it overlaps with encoding processes...
1092 #run_command '' vecho "Copying cue file to its destination directory..."
1093 if checkstatus onetrack
>/dev
/null
; then
1095 # NOTE: Creating a cue file with the 3-char-extension files is to comply with
1096 # http://brianvictor.tripod.com/mp3cue.htm#details
1097 [a-z0-9
][a-z0-9
][a-z0-9
])
1098 run_command movecue-
$OUTPUT cp "$ABCDETEMPDIR/$CUEFILE" "$OUTPUTDIR/$OUTPUTFILE.cue"
1101 run_command movecue-
$OUTPUT cp "$ABCDETEMPDIR/$CUEFILE" "$OUTPUTDIR/$OUTPUTFILE.$OUTPUT.cue"
1105 run_command movecue-
$OUTPUT cp "$ABCDETEMPDIR/$CUEFILE" "$OUTPUTFILEDIR/$CUEFILE"
1107 echo movecue-
$OUTPUT >> "$ABCDETEMPDIR/status"
1116 # Create the playlist if wanted
1118 # PLAYLISTFORMAT, PLAYLISTDATAPREFIX, VAPLAYLISTFORMAT, VAPLAYLISTDATAPREFIX,
1119 # VARIOUSARTISTS, OUTPUTDIR
1122 for OUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
1124 # Create a playlist file for the playlist data to go into.
1125 # We used to wipe it out if it existed. Now we request permision if interactive.
1126 for LASTTRACK
in $TRACKQUEUE; do :; done
1127 ALBUMFILE
=$
(mungefilename
"$DALBUM")
1128 ARTISTFILE
=$
(mungefilename
"$DARTIST")
1129 GENRE
=$
(mungegenre
"$GENRE")
1130 YEAR
=${CDYEAR:-$CDYEAR}
1131 if [ "$VARIOUSARTISTS" = "y" ] ; then
1132 PLAYLISTFILE
=$
(eval echo $VAPLAYLISTFORMAT)
1134 PLAYLISTFILE
=$
(eval echo $PLAYLISTFORMAT)
1136 FINALPLAYLISTDIR
=$
(dirname "$OUTPUTDIR/$PLAYLISTFILE")
1137 mkdir
-p "$FINALPLAYLISTDIR"
1138 if [ -s "$OUTPUTDIR/$PLAYLISTFILE" ]; then
1139 echo -n "Erase, Append to, or Keep the existing playlist file? [e/a/k] (e): " >&2
1140 if [ "$INTERACTIVE" = "y" ]; then
1141 while [ "$DONE" != "y" ]; do
1143 case $ERASEPLAYLIST in
1144 e|E|a|A|k|K
) DONE
=y
;;
1152 # Once we erase the playlist, we use append to create the new one.
1153 [ "$ERASEPLAYLIST" = "e" -o "$ERASEPLAYLIST" = "E" ] && rm -f "$OUTPUTDIR/$PLAYLISTFILE" && ERASEPLAYLIST
=a
1155 # The playlist does not exist, so we can safelly use append to create the new list
1158 if [ "$ERASEPLAYLIST" = "a" -o "$ERASEPLAYLIST" = "A" ]; then
1159 touch "$OUTPUTDIR/$PLAYLISTFILE"
1160 for UTRACKNUM
in $TRACKQUEUE
1162 # Shares some code with do_move since the filenames have to match
1163 CDDBTRACKNUM
=$
(expr $UTRACKNUM - 1)
1164 #TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2 -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')
1165 do_getcddbinfo TRACKNAME
1167 TRACKFILE
=$
(mungefilename
"$TRACKNAME")
1168 ARTISTFILE
=$
(mungefilename
"$TRACKARTIST")
1169 ALBUMFILE
=$
(mungefilename
"$DALBUM")
1170 # If we want to start the tracks with a given number, we need to modify the
1171 # TRACKNUM value before evaluation
1172 # if [ -n "$STARTTRACKNUMBER" ] ; then
1173 # # Get the trackpadding from the current track
1174 # CURRENTTRACKPADDING=$(echo -n $UTRACKNUM | wc -c)
1175 # TRACKNUM=$( printf %0.${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
1177 # TRACKNUM=${UTRACKNUM}
1180 if [ "$VARIOUSARTISTS" = "y" ]; then
1181 OUTPUTFILE
=$
(eval echo $VAOUTPUTFORMAT)
1183 OUTPUTFILE
=$
(eval echo $OUTPUTFORMAT)
1185 if [ "$VARIOUSARTISTS" = "y" ]; then
1186 if [ "$VAPLAYLISTDATAPREFIX" ] ; then
1187 echo ${VAPLAYLISTDATAPREFIX}$OUTPUTFILE.
$OUTPUT >> "$OUTPUTDIR/$PLAYLISTFILE"
1189 relpath
"$PLAYLISTFILE", "$OUTPUTFILE.$OUTPUT" >> "$OUTPUTDIR/$PLAYLISTFILE"
1192 if [ "$PLAYLISTDATAPREFIX" ]; then
1193 echo ${PLAYLISTDATAPREFIX}$OUTPUTFILE.
$OUTPUT >> "$OUTPUTDIR/$PLAYLISTFILE"
1195 relpath
"$PLAYLISTFILE", "$OUTPUTFILE.$OUTPUT" >> "$OUTPUTDIR/$PLAYLISTFILE"
1200 ## this will convert the playlist to have CRLF line-endings, if specified
1201 ## (some hardware players insist on CRLF endings)
1202 if [ "$DOSPLAYLIST" = "y" ]; then
1203 awk '{substr("\r",""); printf "%s\r\n", $0}' "$OUTPUTDIR/$PLAYLISTFILE" > "$ABCDETEMPDIR/PLAYLISTFILE.tmp"
1204 # mv -f "$ABCDETEMPDIR/PLAYLISTFILE.tmp" "$OUTPUTDIR/$PLAYLISTFILE"
1205 cat "$ABCDETEMPDIR/PLAYLISTFILE.tmp" |
sed 's/\//\\/' > "$OUTPUTDIR/$PLAYLISTFILE"
1207 echo "playlistcomplete" >> "$ABCDETEMPDIR/status"
1212 # This essentially the start of things
1215 # Query the CD to get the track info, unless the user specified -C
1216 # or we are using some actions which do not need the CDDB data at all
1217 #if [ ! X"$EXPACTIONS" = "X" ]; then
1219 #elif [ -z "$DISCID" ]; then
1220 if [ -z "$DISCID" ]; then
1221 vecho
-n "Getting CD track info... "
1222 # In OSX, unmount the disc before a query
1223 if [ "$OSFLAVOUR" = "OSX" ]; then
1224 disktool
-u ${CDROM#/dev/}
1226 TRACKINFO
=$
($CDDISCID $CDROM)
1227 # Make sure there's a CD in there by checking cd-discid's return code
1228 if [ "$?" = "1" ]; then
1229 echo "abcde error: CD could not be read. Perhaps there's no CD in the drive?" >&2
1232 # In OSX, remount the disc again
1233 if [ "$OSFLAVOUR" = "OSX" ]; then
1234 disktool
-m ${CDROM#/dev/}
1238 TRACKINFO
=$
(cat "$WAVOUTPUTDIR/abcde.$DISCID/discid")
1241 # Get a full enumeration of tracks, sort it, and put it in the TRACKQUEUE.
1242 # This needs to be done now because a section of the resuming code will need
1245 # get the number of digits to pad TRACKNUM with - we'll use this later
1246 # a CD can only hold 99 tracks, but since we support a feature for starting
1247 # numbering the tracks from a given number, we might need to set it as a
1248 # variable for the user to define... or obtain it somehow.
1249 if [ "$PADTRACKS" = "y" ] ; then
1253 ABCDETEMPDIR
="$WAVOUTPUTDIR/abcde.$(echo $TRACKINFO | cut -f1 -d' ')"
1254 if [ -z "$TRACKQUEUE" ]; then
1255 if [ ! "$STRIPDATATRACKS" = "y" ]; then
1256 case "$CDROMREADERSYNTAX" in
1258 if [ "$WEHAVEACD" = "y" ]; then
1259 vecho
"Querying the CD for audio tracks..."
1260 CDPARANOIAOUTPUT
="$( $CDROMREADER -$CDPARANOIACDROMBUS $CDROM -Q --verbose 2>&1 )"
1262 if [ ! "$RET" = "0" ];then
1263 echo "Warning: Something went wrong while querying the CD... Maybe a DATA CD?"
1265 TRACKS
="$( echo "$CDPARANOIAOUTPUT" | egrep '^[[:space:]]+[[:digit:]]' | tail -n 1 | get_first | tr -d ".
" | tr '\n' ' ' )"
1266 CDPARANOIAAUDIOTRACKS
="$TRACKS"
1268 if [ -f "$ABCDETEMPDIR/status" ] && checkstatus cdparanoia-audio-tracks
; then
1269 TRACKS
=$
( cat "$ABCDETEMPDIR/cdparanoia-audio-tracks" )
1271 TRACKS
=$
(echo $TRACKINFO | cut
-f2 -d' ')
1275 *) TRACKS
=$
(echo $TRACKINFO | cut
-f2 -d' ') ;;
1278 TRACKS
=$
(echo $TRACKINFO | cut
-f2 -d' ')
1280 if echo "$TRACKS" |
grep "[[:digit:]]" > /dev
/null
2>&1 ;then :;else
1281 echo "The disc does not contain any tracks. Giving up..."
1284 echo -n "Grabbing entire CD - tracks: "
1285 if [ ! "$PADTRACKS" = "y" ] ; then
1286 TRACKNUMPADDING
=$
(echo -n $TRACKS |
wc -c |
tr -d ' ')
1288 TRACKS
=$
(printf "%0.${TRACKNUMPADDING}d" $TRACKS)
1290 while [ "$X" -ne "$TRACKS" ]
1292 X
=$
(printf "%0.${TRACKNUMPADDING}d" $
(expr $X + 1))
1293 TRACKQUEUE
=$
(echo "$TRACKQUEUE" $X)
1297 TRACKS
=$
(echo $TRACKINFO | cut
-f2 -d' ')
1298 # User-supplied track queue.
1299 # Weed out non-numbers, whitespace, then sort and weed out duplicates
1300 TRACKQUEUE
=$
(echo $TRACKQUEUE |
sed 's-[^0-9 ]--g' |
tr ' ' '\n' |
grep -v ^$ |
sort -n |
uniq |
tr '\n' ' ' |
sed 's- $--g')
1301 # Once cleaned, obtain the highest value in the trackqueue for number padding
1302 for LASTTRACK
in $TRACKQUEUE; do :; done
1303 if [ ! "$PADTRACKS" = "y" ] ; then
1304 TRACKNUMPADDING
=$
(echo -n $LASTTRACK |
wc -c |
tr -d ' ')
1306 # Now we normalize the trackqueue
1307 for TRACK
in $TRACKQUEUE ; do
1308 TRACKNUM
=$
(printf %0.
${TRACKNUMPADDING}d $
(expr ${TRACK} + 0 ))
1309 PADTRACKQUEUE
=$
(echo $PADTRACKQUEUE $TRACKNUM)
1311 TRACKQUEUE
=$PADTRACKQUEUE
1312 echo Grabbing tracks
: "$TRACKQUEUE"
1315 QUEUEDTRACKS
=$
(echo $TRACKQUEUE |
wc -w |
tr -d ' ')
1317 # We have the discid, create a temp directory after it to store all the temp
1320 if [ -e "$ABCDETEMPDIR" ]; then
1321 echo -n "abcde: attempting to resume from $ABCDETEMPDIR"
1322 # It already exists, see if it's a directory
1323 if [ ! -d "$ABCDETEMPDIR" ]; then
1324 # This is a file/socket/fifo/device/etc, not a directory
1327 echo "abcde: file $ABCDETEMPDIR already exists and does not belong to abcde." >&2
1328 echo "Please investigate, remove it, and rerun abcde." >&2
1332 # It's a directory, let's see if it's owned by us
1333 if [ ! -O "$ABCDETEMPDIR" ]; then
1334 # Nope, complain and exit
1336 echo "abcde: directory $ABCDETEMPDIR already exists and is not owned by you." >&2
1337 echo "Please investigate, remove it, and rerun abcde." >&2
1341 # See if it's populated
1342 if [ ! -f "$ABCDETEMPDIR/discid" ]; then
1343 # Wipe and start fresh
1344 echo "abcde: $ABCDETEMPDIR/discid not found. Abcde must remove and recreate" >&2
1345 echo -n "this directory to continue. Continue? [y/n] (n)" >&2
1346 if [ "$INTERACTIVE" = "y" ]; then
1352 if [ "$ANSWER" != "y" ]; then
1355 rm -rf "$ABCDETEMPDIR" ||
exit 1
1356 mkdir
"$ABCDETEMPDIR"
1357 if [ "$?" -gt "0" ]; then
1358 # Directory already exists or could not be created
1359 echo "abcde: Temp directory $ABCDETEMPDIR could not be created." >&2
1363 # Everything is fine. Check for ^encodetracklocation-
1364 # and encode-output entries in the status file and
1365 # remove them. These are not relevant across sessions.
1366 if [ -f "$ABCDETEMPDIR/status" ]; then
1367 mv "$ABCDETEMPDIR/status" "$ABCDETEMPDIR/status.old"
1368 grep -v ^encodetracklocation-
< "$ABCDETEMPDIR/status.old" \
1369 |
grep -v ^encode-output
> "$ABCDETEMPDIR/status"
1371 # Remove old error messages
1372 if [ -f "$ABCDETEMPDIR/errors" ]; then
1373 rm -f "$ABCDETEMPDIR/errors"
1377 # We are starting from scratch
1378 mkdir
"$ABCDETEMPDIR"
1379 if [ "$?" -gt "0" ]; then
1380 # Directory already exists or could not be created
1381 echo "abcde: Temp directory $ABCDETEMPDIR could not be created." >&2
1384 cat /dev
/null
> "$ABCDETEMPDIR/status"
1386 if [ X
"$MAKECUEFILE" = "Xy" -a X
"$WEHAVEACD" = "Xy" ]; then
1387 if checkstatus cuefile
> /dev
/null
2>&1 ; then :; else
1388 CUEFILE
=cue-$
(echo "$TRACKINFO" | cut
-f1 -d' ').txt
1389 vecho
"Creating cue file..."
1390 if $CUEREADER $CUEREADEROPTS > "$ABCDETEMPDIR/$CUEFILE"; then
1391 echo cuefile
=$CUEFILE >> "$ABCDETEMPDIR/status"
1393 echo "abcde: reading the CUE sheet with mkcue is still considered experimental"
1394 echo "abcde: and there was a problem with the CD reading. abcde will continue,"
1395 echo "abcde: but consider reporting the problem to the abcde author"
1399 # If we got the CDPARANOIA status and it is not recorded, save it now
1400 if [ -n "$CDPARANOIAAUDIOTRACKS" ]; then
1401 if checkstatus cdparanoia-audio-tracks
; then :; else
1402 if echo "$CDPARANOIAAUDIOTRACKS" >> "$ABCDETEMPDIR/cdparanoia-audio-tracks"; then
1403 echo "cdparanoia-audio-tracks" >> "$ABCDETEMPDIR/status"
1408 # Create the discid file
1409 echo "$TRACKINFO" > "$ABCDETEMPDIR/discid"
1413 # Create a proper CUE file based on the CUE file we created before.
1416 # FIXME # we can get the name of the cuefile from the status file
1417 if CUEFILE_IN
="$ABCDETEMPDIR"/$
(checkstatus cuefile
); then
1418 CUEFILE_OUT
=$CUEFILE_IN.out
1419 ### FIXME ### checkstatus cddb
1420 if [ -e "$CDDBDATA" ]; then
1421 vecho
"Adding metadata to the cue file..."
1422 # FIXME It doesn't preserve spaces! Why?
1423 # FIXME parse $track into PERFORMER and TITLE - abcde already has code for this?
1425 echo "PERFORMER \"$DARTIST\"" >> "$CUEFILE_OUT"
1426 echo "TITLE \"$DALBUM\"" >> "$CUEFILE_OUT"
1427 cat "$CUEFILE_IN" |
while read line
1429 if echo "$line" |
grep -q "INDEX"
1431 eval track
="\$TRACK$n"
1433 echo "TITLE \"$track\"" >> "$CUEFILE_OUT"
1435 echo "$line" >> "$CUEFILE_OUT"
1437 mv "$CUEFILE_OUT" "$CUEFILE_IN"
1438 echo "cleancuefile" >> "$ABCDETEMPDIR/status"
1444 # Parses a CDDB file and outputs the title and the track names.
1445 # Variables: CDDBFILE
1449 # List out disc title/author and contents
1450 if [ "$ONETRACK" = "y" ]; then
1451 vecho
"ONETRACK mode selected: displaying only the title of the CD..."
1453 echo "---- $(grep DTITLE "${CDDBPARSEFILE}" | cut '-d=' -f2- | tr -d \\r\\n ) ----"
1454 if [ X
"$SHOWCDDBYEAR" = "Xy" ]; then
1455 PARSEDYEAR
=$
(grep DYEAR
"${CDDBPARSEFILE}" | cut
'-d=' -f2-)
1456 if [ ! X
"$PARSEDYEAR" = "X" ]; then
1457 echo "Year: $PARSEDYEAR"
1460 if [ X
"$SHOWCDDBGENRE" = "Xy" ]; then
1461 PARSEDGENRE
=$
(grep DGENRE
"${CDDBPARSEFILE}" | cut
'-d=' -f2-)
1462 if [ ! X
"$PARSEDGENRE" = "X" ]; then
1463 echo "Genre: $PARSEDGENRE"
1466 if [ ! "$ONETRACK" = "y" ]; then
1467 for TRACK
in $
(f_seq_row
1 $TRACKS)
1469 echo $TRACK: "$(grep ^TTITLE$(expr $TRACK - 1)= "${CDDBPARSEFILE}" | cut -f2- -d= | tr -d \\r\\n)"
1475 # Check for a local CDDB file, and report success
1478 if checkstatus cddb-readcomplete
&& checkstatus cddb-choice
>/dev
/null
; then :; else
1480 CDDBLOCALSUCCESS
="n"
1481 CDDBDISCID
=$
(echo $TRACKINFO | cut
-d' ' -f1)
1482 CDDBLOCALFILE
="${CDDBLOCALDIR}/${CDDBDISCID}"
1485 # If the user has selected to check a local CDDB repo, we proceed with it
1486 if [ -r "${CDDBLOCALFILE}" ]; then
1487 # List out disc title/author and contents
1488 do_cddbparse
"${CDDBLOCALFILE}"
1489 echo -n "Locally cached CDDB entry found, use it? [y/n] (y): "
1490 if [ "$INTERACTIVE" = "y" ]; then
1492 while [ "$USELOCALRESP" != "y" ] && [ "$USELOCALRESP" != "n" ] && [ "$USELOCALRESP" != "" ] ; do
1493 echo -n 'Invalid selection. Please answer "y" or "n": '
1496 [ x
"$USELOCALRESP" = "x" ] && USELOCALRESP
="y"
1500 if [ "$USELOCALRESP" = "y" ]; then
1501 #echo "Using local copy of CDDB data"
1502 cp "${CDDBLOCALFILE}" "$ABCDETEMPDIR/cddbread.1"
1503 echo 999 > "$ABCDETEMPDIR/cddbquery" # Assuming 999 isn't used by CDDB
1504 echo cddb-readcomplete
>> "$ABCDETEMPDIR/status"
1505 do_cddbparse
"${CDDBLOCALFILE}" > "$ABCDETEMPDIR/cddbchoices"
1506 echo cddb-choice
=1 >> "$ABCDETEMPDIR/status"
1507 CDDBLOCALSUCCESS
="y"
1509 #echo "Not using local copy of CDDB data"
1510 CDDBLOCALSUCCESS
="n"
1513 CDDBLOCALSUCCESS
="n"
1521 # Perform CDDB protocol version check if it hasn't already been done
1522 if checkstatus cddb-statcomplete
; then :; else
1523 if [ "$CDDBAVAIL" = "n" ]; then
1525 echo 503 > "$ABCDETEMPDIR/cddbstat"
1528 CDDBUSER
=$
(echo $HELLOINFO | cut
-f1 -d'@')
1529 CDDBHOST
=$
(echo $HELLOINFO | cut
-f2- -d'@')
1530 while test $rc -eq 1 -a $CDDBPROTO -ge 3; do
1531 vecho
"Checking CDDB server status..."
1532 $CDDBTOOL stat
$CDDBURL $CDDBUSER $CDDBHOST $CDDBPROTO > "$ABCDETEMPDIR/cddbstat"
1533 RESPONSECODE
=$
(head -n 1 "$ABCDETEMPDIR/cddbstat" | cut
-f1 -d' ')
1534 case "$RESPONSECODE" in
1535 210) # 210 OK, status information follows (until terminating `.')
1538 501|
*) # 501 Illegal CDDB protocol level: <n>.
1539 CDDBPROTO
=`expr $CDDBPROTO - 1`
1543 if test $rc -eq 1; then
1547 echo cddb-statcomplete
>> "$ABCDETEMPDIR/status"
1555 CDDBDISCID
=$
(echo $TRACKINFO | cut
-d' ' -f1)
1556 CDDBLOCALFILE
="${CDDBLOCALDIR}/${CDDBDISCID}"
1558 # Perform CDDB query if it hasn't already been done
1559 if checkstatus cddb-querycomplete
; then :; else
1560 if [ "$CDDBAVAIL" = "n" ]; then
1562 echo 503 > "$ABCDETEMPDIR/cddbquery"
1563 # The default CDDBLOCALSUCCESS is "n"
1564 # This part will be triggered if the user CDDB repo does not
1565 # contain the entry, or if we are not trying to use the repo.
1567 vecho
"Querying the CDDB server..."
1568 CDDBUSER
=$
(echo $HELLOINFO | cut
-f1 -d'@')
1569 CDDBHOST
=$
(echo $HELLOINFO | cut
-f2- -d'@')
1570 $CDDBTOOL query
$CDDBURL $CDDBPROTO $CDDBUSER $CDDBHOST $TRACKINFO > "$ABCDETEMPDIR/cddbquery"
1576 # no match found in database,
1577 # wget/fetch error, or user requested not to use CDDB
1578 # Make up an error code (503) that abcde
1579 # will recognize in do_cddbread
1580 # and compensate by making a template
1581 echo 503 > "$ABCDETEMPDIR/cddbquery"
1583 *) # strange and unknown error
1584 echo ERRORCODE
=$ERRORCODE
1585 echo "abcde: $CDDBTOOL returned unknown error code"
1589 echo cddb-querycomplete
>> "$ABCDETEMPDIR/status"
1596 # If it's not to be used, generate a template.
1597 # Then, display it (or them) and let the user choose/edit it
1598 if checkstatus cddb-readcomplete
; then :; else
1599 vecho
"Obtaining CDDB results..."
1600 # If CDDB is to be used, interpret the query results and read all
1601 # the available entries.
1602 rm -f "$ABCDETEMPDIR/cddbchoices"
1603 CDDBCHOICES
=1 # Overridden by multiple matches
1604 RESPONSECODE
=$
(head -n 1 "$ABCDETEMPDIR/cddbquery" | cut
-f1 -d' ')
1605 case "$RESPONSECODE" in
1607 # One exact match, retrieve it
1608 # 200 [section] [discid] [artist] / [title]
1609 if checkstatus cddb-read-1-complete
; then :; else
1610 echo -n "Retrieving 1 CDDB match..." >> "$ABCDETEMPDIR/cddbchoices"
1611 $CDDBTOOL read $CDDBURL $CDDBPROTO $CDDBUSER $CDDBHOST $
(cut
-f2,3 -d' ' "$ABCDETEMPDIR/cddbquery") > "$ABCDETEMPDIR/cddbread.1"
1612 echo "done." >> "$ABCDETEMPDIR/cddbchoices"
1613 echo cddb-read-1-complete
>> "$ABCDETEMPDIR/status"
1614 echo cddb-choice
=1 >> "$ABCDETEMPDIR/status"
1616 # List out disc title/author and contents
1617 echo ---- "$(cut '-d ' -f4- "$ABCDETEMPDIR/cddbquery
")" ---- >> "$ABCDETEMPDIR/cddbchoices"
1618 for TRACK
in $
(f_seq_row
1 $TRACKS)
1620 echo $TRACK: "$(grep ^TTITLE$(expr $TRACK - 1)= "$ABCDETEMPDIR/cddbread
.1" | cut -f2- -d= | tr -d \\r\\n)" >> "$ABCDETEMPDIR/cddbchoices"
1622 echo >> "$ABCDETEMPDIR/cddbchoices"
1626 case "$RESPONSECODE" in
1627 202) echo "No CDDB match." >> "$ABCDETEMPDIR/cddbchoices" ;;
1628 403|
409) echo "CDDB entry is corrupt, or the handshake failed." >> "$ABCDETEMPDIR/cddbchoices" ;;
1629 503) echo "CDDB unavailable." >> "$ABCDETEMPDIR/cddbchoices" ;;
1631 $CDDBTOOL template $
(cat "$ABCDETEMPDIR/discid") > "$ABCDETEMPDIR/cddbread.0"
1632 # List out disc title/author and contents of template
1633 echo ---- Unknown Artist
/ Unknown Album
---- >> "$ABCDETEMPDIR/cddbchoices"
1635 for TRACK
in $
(f_seq_row
1 $TRACKS)
1637 echo $TRACK: "$(grep ^TTITLE$(expr $TRACK - 1)= "$ABCDETEMPDIR/cddbread
.0" | cut -f2- -d= | tr -d \\r\\n)" >> "$ABCDETEMPDIR/cddbchoices"
1639 echo >> "$ABCDETEMPDIR/cddbchoices"
1640 echo cddb-read-0-complete
>> "$ABCDETEMPDIR/status"
1641 echo cddb-choice
=0 >> "$ABCDETEMPDIR/status"
1644 # Multiple exact, (possibly multiple) inexact matches
1646 if [ "$RESPONSECODE" = "211" ]; then IN
=in; fi
1647 if [ "$(wc -l < "$ABCDETEMPDIR/cddbquery
" | tr -d ' ')" -eq 3 ]; then
1648 echo "One ${IN}exact match:" >> "$ABCDETEMPDIR/cddbchoices"
1649 tail -n +2 "$ABCDETEMPDIR/cddbquery" |
head -n 1 >> "$ABCDETEMPDIR/cddbchoices"
1650 echo cddb-choice
=1 >> "$ABCDETEMPDIR/status"
1652 echo "Multiple ${IN}exact matches:" >> "$ABCDETEMPDIR/cddbchoices"
1654 vecho
-n "Retrieving multiple matches... "
1655 grep -v ^
[.
]$
"$ABCDETEMPDIR/cddbquery" |
( X
=0
1656 read DISCINFO
# eat top line
1660 if checkstatus cddb-read-
$X-complete; then :; else
1661 $CDDBTOOL read $CDDBURL $CDDBPROTO $CDDBUSER $CDDBHOST $
(echo $DISCINFO | cut
-f1,2 -d' ') > "$ABCDETEMPDIR/cddbread.$X"
1662 echo cddb-read-
$X-complete >> "$ABCDETEMPDIR/status"
1664 # List out disc title/author and contents
1665 echo \
#$X: ---- "$DISCINFO" ---- >> "$ABCDETEMPDIR/cddbchoices"
1666 for TRACK
in $
(f_seq_row
1 $TRACKS)
1668 echo $TRACK: "$(grep ^TTITLE$(expr $TRACK - 1)= "$ABCDETEMPDIR/cddbread.
$X" | cut -f2- -d= | tr -d \\r\\n)" >> "$ABCDETEMPDIR/cddbchoices"
1670 echo >> "$ABCDETEMPDIR/cddbchoices"
1673 CDDBCHOICES
=$
(expr $
(cat "$ABCDETEMPDIR/cddbquery" |
wc -l) - 2)
1677 for TRACK
in $
(f_seq_row
1 $TRACKS)
1679 echo $TRACK: "$(grep ^TTITLE$(expr $TRACK - 1)= "$ABCDETEMPDIR/cddbread
.1" | cut -f2- -d= | tr -d \\r\\n)" >> "$ABCDETEMPDIR/cddbchoices"
1681 echo >> "$ABCDETEMPDIR/cddbchoices"
1682 echo cddb-read-1-complete
>> "$ABCDETEMPDIR/status"
1683 echo cddb-choice
=1 >> "$ABCDETEMPDIR/status"
1686 echo "cddb-readcomplete" >> "$ABCDETEMPDIR/status"
1693 if checkstatus cddb-edit
>/dev
/null
; then
1694 CDDBDATA
="$ABCDETEMPDIR/cddbread.$(checkstatus cddb-choice)"
1695 VARIOUSARTISTS
="$(checkstatus variousartists)"
1696 VARIOUSARTISTSTYLE
="$(checkstatus variousartiststyle)"
1699 if [ "$INTERACTIVE" = "y" ]; then
1700 # We should show the CDDB results both when we are not using the local CDDB repo
1701 # or when we are using it but we could not find a proper match
1702 if [ "$CDDBUSELOCAL" = "y" ] && [ ! "$CDDBLOCALSUCCESS" = "y" ] ||
[ ! "$CDDBUSELOCAL" = "y" ]; then
1703 # Display the $ABCDETEMPDIR/cddbchoices file created above
1704 # Pick a pager so that if the tracks overflow the screen the user can still view everything
1705 if [ -r "$ABCDETEMPDIR/cddbchoices" ]; then
1706 CDDBCHOICES
=$
(expr $
(cat "$ABCDETEMPDIR/cddbquery" |
wc -l) - 2)
1707 CHOICE
=$
(checkstatus cddb-choice
)
1708 if [ -n "$CHOICE" ] ; then
1709 case $CDDBCHOICES in
1710 1) cat "$ABCDETEMPDIR/cddbchoices" ;;
1712 echo "Selected: #$CHOICE"
1713 do_cddbparse
"$ABCDETEMPDIR/cddbread.$CHOICE"
1717 # The user has a choice to make, display the info in a pager if necessary
1718 if [ $
(cat "$ABCDETEMPDIR/cddbchoices" |
wc -l) -ge 24 ]; then
1719 page
"$ABCDETEMPDIR/cddbchoices"
1721 # It's all going to fit in one page, cat it
1722 cat "$ABCDETEMPDIR/cddbchoices" >&2
1726 # Setting the choice to an impossible integer to avoid errors in the numeric comparisons
1728 # I'll take CDDB read #3 for $400, Alex
1729 while [ $CDCHOICENUM -lt 0 ] ||
[ $CDCHOICENUM -gt $CDDBCHOICES ]; do
1730 echo -n "Which entry would you like abcde to use (0 for none)? [0-$CDDBCHOICES]: " >&2
1732 [ X
"$CDDBCHOICE" = "X" ] && CDDBCHOICE
=1
1733 if echo $CDDBCHOICE |
egrep -q "[[:digit:]]+,[[:digit:]]+" ; then
1734 if [ ! X
"$DIFF" = "X" ]; then
1735 PARSECHOICE1
=$
(echo $CDDBCHOICE | cut
-d"," -f1)
1736 PARSECHOICE2
=$
(echo $CDDBCHOICE | cut
-d"," -f2)
1737 if [ $PARSECHOICE1 -lt 1 ] ||
[ $PARSECHOICE1 -gt $CDDBCHOICES ] || \
1738 [ $PARSECHOICE2 -lt 1 ] ||
[ $PARSECHOICE2 -gt $CDDBCHOICES ] || \
1739 [ $PARSECHOICE1 -eq $PARSECHOICE2 ]; then
1740 echo "Invalid diff range. Please select two coma-separated numbers between 1 and $CDDBCHOICES" >&2
1743 # We parse the 2 choices to diff, store them in temporary files and diff them.
1744 for PARSECHOICE
in $
(echo $CDDBCHOICE |
tr , \
); do
1745 do_cddbparse
"$ABCDETEMPDIR/cddbread.$PARSECHOICE" > "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE"
1747 echo "Showing diff between choices $PARSECHOICE1 and $PARSECHOICE2..." > "$ABCDETEMPDIR/cddbread.diff"
1748 $DIFF $DIFFOPTS "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE1" "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE2" >> "$ABCDETEMPDIR/cddbread.diff"
1749 if [ $
(cat "$ABCDETEMPDIR/cddbread.diff" |
wc -l) -ge 24 ]; then
1750 page
"$ABCDETEMPDIR/cddbread.diff"
1752 cat "$ABCDETEMPDIR/cddbread.diff" >&2
1756 echo "The diff program was not found in your path. Please choose a number between 0 and $CDDBCHOICES." >&2
1759 if [ $CDCHOICENUM -lt 0 ] ||
[ $CDCHOICENUM -gt $CDDBCHOICES ]; then
1760 # Make sure we get a valid choice
1761 CDCHOICENUM
=$
(echo $CDDBCHOICE |
xargs printf %d
2>/dev
/null
)
1762 echo "Invalid selection. Please choose a number between 0 and $CDDBCHOICES." >&2
1766 if [ "$CDCHOICENUM" = "0" ]; then
1767 vecho
"Creating empty CDDB template..."
1769 $CDDBTOOL template $
(cat "$ABCDETEMPDIR/discid") > "$ABCDETEMPDIR/cddbread.0"
1771 echo "Selected: #$CDCHOICENUM ($(grep ^DTITLE= "$ABCDETEMPDIR/cddbread.
$CDCHOICENUM" | cut -f2- -d= | tr -d \\r\\n))" >&2
1772 do_cddbparse
"$ABCDETEMPDIR/cddbread.$CDCHOICENUM"
1774 echo "cddb-choice=$CDCHOICENUM" >> "$ABCDETEMPDIR/status"
1778 # We need some code to show the selected option when local repository is selected and we have found a match
1779 vecho
"Using cached CDDB match..." >&2
1780 # Display the $ABCDETEMPDIR/cddbchoices file created above
1781 # Pick a pager so that if the tracks overflow the screen the user can still view everything
1782 if [ -r "$ABCDETEMPDIR/cddbchoices" ]; then
1783 CDDBCHOICES
=$
(expr $
(cat "$ABCDETEMPDIR/cddbquery" |
wc -l) - 2)
1784 CHOICE
=$
(checkstatus cddb-choice
)
1785 if [ "$USELOCALRESP" = "y" ]; then :; else
1786 if [ -n "$CHOICE" ] ; then
1787 case $CDDBCHOICES in
1790 echo "Selected template."
1792 1) cat "$ABCDETEMPDIR/cddbchoices" ;;
1794 echo "Selected: #$CHOICE"
1795 do_cddbparse
"$ABCDETEMPDIR/cddbread.$CHOICE"
1803 # We're noninteractive - pick the first choice.
1804 # But in case we run a previous instance and selected a choice, use it.
1805 if [ -r "$ABCDETEMPDIR/cddbchoices" ]; then
1806 # Show the choice if we are not using the locally stored one
1807 # or when the local search failed to find a match.
1808 PREVIOUSCHOICE
=$
(checkstatus cddb-choice
)
1809 if [ "$CDDBUSELOCAL" = "y" ] && [ "$CDDBLOCALSUCCESS" = "n" ] ||
[ ! "$CDDBUSELOCAL" = "y" ]; then
1810 #if [ "$PREVIOUSCHOICE" ]; then
1811 cat "$ABCDETEMPDIR/cddbchoices"
1814 if [ ! -z "$PREVIOUSCHOICE" ] ; then
1815 CDCHOICENUM
=$PREVIOUSCHOICE
1818 echo "cddb-choice=$CDCHOICENUM" >> "$ABCDETEMPDIR/status"
1820 echo "Selected: #$CDCHOICENUM ($(grep ^DTITLE= "$ABCDETEMPDIR/cddbread.
$CDCHOICENUM" | cut -f2- -d= | tr -d \\r\\n))" >&2
1825 if checkstatus cddb-choice
>/dev
/null
; then :; else
1826 echo "abcde: internal error: cddb-choice not recorded." >&2
1829 CDDBDATA
="$ABCDETEMPDIR/cddbread.$(checkstatus cddb-choice)"
1830 echo -n "Edit selected CDDB data? [y/n] (" >&2
1831 if [ "$INTERACTIVE" = "y" ]; then
1832 if [ "$UNKNOWNDISK" = "y" ]; then
1835 [ "$EDITCDDB" != "n" ] && EDITCDDB
=y
1844 if [ "$EDITCDDB" = "y" ]; then
1845 CDDBDATAMD5SUM
=$
($MD5SUM "$CDDBDATA" | cut
-d " " -f 1);
1847 # Use the debian sensible-editor wrapper to pick the editor that the
1848 # user has requested via their $EDITOR environment variable
1849 if [ -x "/usr/bin/sensible-editor" ]; then
1850 /usr
/bin
/sensible-editor
"$CDDBDATA"
1851 elif [ -n "$EDITOR" ]; then
1852 if [ -x $
(which "${EDITOR%%\ *}") ]; then
1853 # That failed, try to load the preferred editor, starting
1854 # with their EDITOR variable
1855 eval $
(echo "$EDITOR") \"$CDDBDATA\"
1857 # If that fails, check for a vi
1858 elif which vi
>/dev
/null
2>&1; then
1860 elif [ -x /usr
/bin
/vim
]; then
1861 /usr
/bin
/vim
"$CDDBDATA"
1862 elif [ -x /usr
/bin
/vi
]; then
1863 /usr
/bin
/vi
"$CDDBDATA"
1864 elif [ -x /bin
/vi
]; then
1866 # nano should be on all (modern, i.e., sarge) debian systems
1867 elif which nano
>/dev
/null
2>&1 ; then
1869 elif [ -x /usr
/bin
/nano
]; then
1870 /usr
/bin
/nano
"$CDDBDATA"
1871 # mg should be on all OpenBSD systems
1872 elif which mg
>/dev
/null
2>&1 ; then
1874 elif [ -x /usr
/bin
/mg
]; then
1875 /usr
/bin
/mg
"$CDDBDATA"
1878 echo "No editor available. Check your EDITOR environment variable." >&2
1880 # delete editor backup file if it exists
1881 if [ -w "$CDDBDATA~" ]; then
1886 # Some heuristics first. Look at Disc Title, and if it starts with
1887 # "Various", then we'll assume Various Artists
1888 if [ "$(grep ^DTITLE= "$CDDBDATA" | cut -f2- -d= | egrep -ci '^(various|soundtrack|varios|sonora|ost)')" != "0" ]; then
1889 echo "Looks like a Multi-Artist CD" >&2
1892 echo -n "Is the CD multi-artist? [y/n] (n): " >&2
1893 if [ "$INTERACTIVE" = "y" ]; then
1900 if [ "$VARIOUSARTISTS" = "y" ] && [ ! "$ONETRACK" = "y" ]; then
1903 # Need NUMTRACKS before cddb-tool will return it:
1904 NUMTRACKS
=$
(egrep '^TTITLE[0-9]+=' "$CDDBDATA" |
wc -l)
1905 if [ "$(grep -c "^TTITLE.
*\
/" "$CDDBDATA")" -gt "$(expr $NUMTRACKS / 2 )" ]; then
1906 # More than 1/2 tracks contain a "/", so guess forward
1908 elif [ "$(grep -c "^TTITLE.
*\
-" "$CDDBDATA")" -gt "$(expr $NUMTRACKS / 2 )" ]; then
1909 # More than 1/2 contain a "-", so guess forward-dash
1911 elif [ "$(grep -c "^TTITLE.
*(.
*)" "$CDDBDATA")" -gt "$(expr $NUMTRACKS / 2 )" ]; then
1912 # More than 1/2 contain something in parens, so guess trailing-paren
1916 echo "1) Artist / Title" >&2
1917 echo "2) Artist - Title" >&2
1918 echo "3) Title / Artist" >&2
1919 echo "4) Title - Artist" >&2
1920 echo "5) Artist: Title" >&2
1921 echo "6) Title (Artist)" >&2
1922 echo "7) This is a single-artist CD" >&2
1923 echo -n "Which style of multiple artist entries is it? [1-7] ($DEFAULTSTYLE): " >&2
1924 if [ "$INTERACTIVE" = "y" ]; then
1925 read VARIOUSARTISTSTYLE
1927 echo $DEFAULTSTYLE >&2
1928 VARIOUSARTISTSTYLE
=$DEFAULTSTYLE
1930 VARIOUSARTISTSTYLE
=$
(echo 0$VARIOUSARTISTSTYLE |
xargs printf %d
)
1931 # If they press Enter, then the default style (0) was chosen
1932 while [ $VARIOUSARTISTSTYLE -lt 0 ] ||
[ $VARIOUSARTISTSTYLE -gt 7 ]; do
1933 echo "Invalid selection. Please choose a number between 1 and 7."
1934 echo -n "Selection [1-7]: "
1935 read VARIOUSARTISTSTYLE
1936 VARIOUSARTISTSTYLE
=$
(echo 0$VARIOUSARTISTSTYLE |
xargs printf %d
)
1938 if [ "$VARIOUSARTISTSTYLE" = "0" ]; then
1939 VARIOUSARTISTSTYLE
=$DEFAULTSTYLE
1941 vecho
"Selected: $VARIOUSARTISTSTYLE"
1942 case "$VARIOUSARTISTSTYLE" in
1944 VARIOUSARTISTSTYLE
=forward
1947 VARIOUSARTISTSTYLE
=forward-dash
1950 VARIOUSARTISTSTYLE
=reverse
1953 VARIOUSARTISTSTYLE
=reverse-dash
1956 VARIOUSARTISTSTYLE
=colon
1959 VARIOUSARTISTSTYLE
=trailing-paren
1967 echo "variousartists=$VARIOUSARTISTS" >> "$ABCDETEMPDIR/status"
1968 echo "variousartiststyle=$VARIOUSARTISTSTYLE" >> "$ABCDETEMPDIR/status"
1970 if [ "$EDITCDDB" = "y" ] && [ "$UNINTENTIONALLY_ANGER_THE_FREEDB_PEOPLE" = "y" ]; then
1971 if [ "$CDDBDATAMD5SUM" != "" ] && [ "$CDDBDATAMD5SUM" != "$($MD5SUM "$CDDBDATA" | cut -d " " -f 1)" ]; then
1972 # This works but does not have the necessary error checking
1973 # yet. If you are familiar with the CDDB spec
1974 # (see http://www.freedb.org/src/latest/DBFORMAT)
1975 # and can create an error-free entry on your own, then put
1976 # UNINTENTIONALLY_ANGER_THE_FREEDB_PEOPLE=y in your
1977 # abcde.conf to enable it. Put CDDBSUBMIT=email@address in
1978 # your abcde.conf to change the email address submissions are
1981 # submit the modified file, if they want
1982 if [ "$NOSUBMIT" != "y" ]; then
1983 echo -n "Do you want to submit this entry to $CDDBSUBMIT? [y/n] (n): "
1985 while [ "$YESNO" != "y" ] && [ "$YESNO" != "n" ] && [ "$YESNO" != "Y" ] && \
1986 [ "$YESNO" != "N" ] && [ "$YESNO" != "" ]
1988 echo -n 'Invalid selection. Please answer "y" or "n": '
1991 if [ "$YESNO" = "y" ] ||
[ "$YESNO" = "Y" ]; then
1992 echo -n "Sending..."
1993 $CDDBTOOL send
"$CDDBDATA" $CDDBSUBMIT
1999 # Make sure the cache directory exists
2000 mkdir
-p $CDDBLOCALDIR
2001 # Cache edited CDDB entry in the user's cddb dir
2002 if [ "$CDDBCOPYLOCAL" = "y" ] ||
[ "$COPYCDDBLOCAL" = "Y" ]; then
2003 cat "$CDDBDATA" |
tail -n $
(expr $
(cat "$CDDBDATA" |
wc -l ) - 1 ) > ${CDDBLOCALDIR}/$
(echo "$TRACKINFO" | cut
-d' ' -f1)
2006 echo "cddb-edit" >> "$ABCDETEMPDIR/status"
2009 # do_cdread [tracknumber]
2010 # do_cdread onetrack [firsttrack] [lasttrack]
2014 # The commands here don't go through run_command because they're never supposed to be silenced
2015 # return codes need to be doublechecked anyway, however
2016 if [ "$1" = "onetrack" ]; then
2017 # FIXME # Add the possibility of grabbing ranges of tracks in onetrack
2018 # FIXME # Until then, we grab the whole CD in one track, no matter what
2020 # We need the first and last track for cdda2wav
2023 UTRACKNUM
=$FIRSTTRACK
2024 case "$CDROMREADERSYNTAX" in
2025 cdparanoia
) READTRACKNUMS
="$FIRSTTRACK-$LASTTRACK" ;;
2026 cdda2wav
) READTRACKNUMS
="$FIRSTTRACK+$LASTRACK" ;;
2027 *) echo "abcde error: $CDROMREADERSYNTAX does not support ONETRACK mode"
2033 CDDBTRACKNUM
=$
(expr $UTRACKNUM - 1)
2034 if [ "$USEPIPES" = "y" ]; then
2035 TEMPARG
="PIPE_$CDROMREADERSYNTAX"
2036 FILEARG
="$( eval echo "\$
$TEMPARG" )"
2038 PIPE_MESSAGE
="and encoding "
2040 WAVDATA
="$ABCDETEMPDIR/track$UTRACKNUM.wav"
2041 case "$CDROMREADERSYNTAX" in
2042 ## FIXME ## Find the case for dagrab, to avoid exceptions
2044 FILEARG
="-f $WAVDATA"
2052 if [ "$1" = "onetrack" ]; then
2053 echo "Grabbing ${PIPE_MESSAGE}tracks $UTRACKNUM - $LASTTRACK as one track ..." >&2
2055 if [ -r "$CDDBDATA" ]; then
2056 #TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2 -d= | tr -d \[:cntrl:\])
2057 do_getcddbinfo TRACKNAME
2058 echo "Grabbing ${PIPE_MESSAGE}track $UTRACKNUM: $TRACKNAME..." >&2
2060 echo "Grabbing ${PIPE_MESSAGE}track $UTRACKNUM..." >&2
2063 case "$CDROMREADERSYNTAX" in
2065 nice
$READNICE $CDROMREADER -$CDPARANOIACDROMBUS $CDROM ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" $REDIR ;;
2067 if [ "$OSFLAVOUR" = "OSX" ] ; then
2068 # Hei, we have to unmount the device before running anything like cdda2wav in OSX
2069 disktool
-u ${CDROM#/dev/} 0
2070 # Also, in OSX the cdrom device for cdda2wav changes...
2071 CDDA2WAVCDROM
="IODVDServices"
2072 elif [ "$OSFLAVOUR" = "FBSD" ] ; then
2073 CDDA2WAVCDROM
="$CDROMID"
2075 if [ "$CDROMID" = "" ]; then
2076 CDDA2WAVCDROM
="$CDROM"
2078 CDDA2WAVCDROM
="$CDROMID"
2081 nice
$READNICE $CDROMREADER -D $CDDA2WAVCDROM -t ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" $REDIR
2083 ## FIXME ## We have an exception for dagrab, since it uses -f
2084 ## FIXME ## Shall we just use -f $FILEARG ??
2085 dagrab
) nice
$READNICE $CDROMREADER -d $CDROM -v $UTRACKNUM "$FILEARG" $REDIR
2088 # Find the track's mounted path
2089 REALTRACKNUM
=$
(expr $UTRACKNUM + 0)
2090 FILEPATH
=$
(mount |
grep "$CDROM on" |
sed 's/^[^ ]* on \(.*\) (.*/\1/')
2091 FILEPATH
=$
(find "$FILEPATH" |
grep "/$REALTRACKNUM ");
2092 # If the file exists, copy it
2093 if [ -e "$FILEPATH" ] ; then
2094 nice
$READNICE $CDROMREADER "$FILEPATH" "$FILEARG" $REDIR
2098 debug
) nice
$READNICE $CDROMREADER -$CDPARANOIACDROMBUS $CDROM -w $UTRACKNUM-[:1] "$FILEARG" $REDIR
2102 # If we get some error or we get some missing wav
2103 # (as long as we dont use pipes)
2104 if [ "$RETURN" != "0" -o \
( ! -s "$WAVDATA" -a X
"$USEPIPES" != "Xy" \
) ]; then
2105 # Thank goodness errors is only machine-parseable up to the
2106 # first colon, otherwise this woulda sucked
2107 if [ "$RETURN" = "0" -a ! -s "$WAVDATA" ]; then
2108 RETURN
=73 # fake a return code as cdparanoia return 0 also on aborted reads
2110 if [ "$USEPIPES" = "y" ]; then
2111 echo "readencodetrack-$UTRACKNUM: $CDROMREADER returned code $RETURN" >> "$ABCDETEMPDIR/errors"
2113 echo "readtrack-$UTRACKNUM: $CDROMREADER returned code $RETURN" >> "$ABCDETEMPDIR/errors"
2117 if [ "$USEPIPES" = "y" ]; then
2118 echo readencodetrack-
$UTRACKNUM >> "$ABCDETEMPDIR/status"
2120 echo readtrack-
$UTRACKNUM >> "$ABCDETEMPDIR/status"
2121 if [ "$1" = "onetrack" ]; then
2122 echo onetrack
>> "$ABCDETEMPDIR/status"
2129 # No values accepted, only uses env variables
2132 if "$CDSPEED" "$CDSPEEDOPTS" "$CDSPEEDVALUE" >/dev
/null
; then
2133 vecho
"Setting CD speed to ${CDSPEEDVALUE}x"
2135 echo "abcde: unable to set the device speed" >&2
2141 # vecho outputs a message if EXTRAVERBOSE is selected
2144 if [ x
"$EXTRAVERBOSE" != "x" ]; then
2149 # User-redefinable functions
2150 # Custom filename munging:
2153 #echo "$@" | sed s,:,\ -,g | tr \ /\* __+ | tr -d \'\"\?\[:cntrl:\]
2154 echo "$@" |
sed s
,:,\
-,g |
tr \
/ __ |
tr -d \'\"\?\
[:cntrl
:\
]
2157 # Custom genre munging:
2160 echo $CDGENRE |
tr "[:upper:]" "[:lower:]"
2164 # Empty pre_read function, to be defined in the configuration file.
2171 # Empty post_read function, to be defined in the configuration file.
2177 ###############################################################################
2180 # Start of execution
2181 ###############################################################################
2184 CDDBURL
="http://freedb.freedb.org/~cddb/cddb.cgi"
2185 CDDBSUBMIT
=freedb-submit@freedb.org
2187 HELLOINFO
="$(whoami)@$(hostname)"
2189 CDDBLOCALDIR
="$HOME/.cddb"
2192 # List of fields we parse and show during the CDDB parsing...
2193 SHOWCDDBFIELDS
="year,genre"
2196 CDROMREADERSYNTAX
=cdparanoia
2197 ENCODERSYNTAX
=default
2199 MP3ENCODERSYNTAX
=default
2200 OGGENCODERSYNTAX
=default
2201 FLACENCODERSYNTAX
=default
2202 SPEEXENCODERSYNTAX
=default
2203 MPPENCODERSYNTAX
=default
2204 NORMALIZERSYNTAX
=default
2205 CUEREADERSYNTAX
=default
2207 OUTPUTFORMAT
='${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
2208 # Use the following VAOUTPUTFORMAT to revert to 2.0.x VA format:
2209 #VAOUTPUTFORMAT=${OUTPUTFORMAT}
2210 VAOUTPUTFORMAT
='Various-${ALBUMFILE}/${TRACKNUM}.${ARTISTFILE}-${TRACKFILE}'
2211 ONETRACKOUTPUTFORMAT
='${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}'
2212 VAONETRACKOUTPUTFORMAT
='Various-${ALBUMFILE}/${ALBUMFILE}'
2213 PLAYLISTFORMAT
='${ARTISTFILE}-${ALBUMFILE}.${OUTPUT}.m3u'
2214 PLAYLISTDATAPREFIX
=''
2215 VAPLAYLISTFORMAT
='${ARTISTFILE}-${ALBUMFILE}.${OUTPUT}.m3u'
2216 VAPLAYLISTDATAPREFIX
=''
2224 VARIOUSARTISTSTYLE
=forward
2228 # If using scsi devices, cdda2wav needs a CDROMID, instead of a device node
2229 # i.e. CDROMID="1,0,0"
2231 # If we are using the IDE bus, we need CDPARANOIACDROMBUS defined as "d"
2232 # If we are using the ide-scsi emulation layer, we need to define a "g"
2233 CDPARANOIACDROMBUS
="d"
2235 # program paths - defaults to checking your $PATH
2241 XINGMP3ENC
=xingmp3enc
2256 CDPARANOIA
=cdparanoia
2265 VORBISCOMMENT
=vorbiscomment
2267 NORMALIZE
=normalize-audio
2269 VORBISGAIN
=vorbisgain
2274 # Options for programs called from abcde
2306 VORBISCOMMENTOPTS
="-R"
2307 METAFLACOPTS
="--no-utf8-convert"
2309 # Default to one process if -j isn't specified
2312 # List of actions to perform - by default, run to completion
2313 ACTIONS
=cddb
,read,encode
,tag
,move
,clean
2315 # List of prefered outputs - by default, run with whatever we have in the path
2316 # This option is basicaly for Debian package dependencies
2317 DEFAULT_OUTPUT_BINARIES
=vorbis
:oggenc
,flac
:flac
,mp3
:lame
,mp3
:bladeenc
,spx
:speex
2319 # Asume fetch if under FreeBSD. curl is used for Mac OS X. wget is used for Linux/OpenBSD/NetBSD.
2320 # Let's use these checkings to determine the OS flavour, which will be used later
2321 if [ X$
(uname
) = "XFreeBSD" ] ; then
2326 elif [ X$
(uname
) = "XDarwin" ] ; then
2329 # We should have disktool in OSX, but let's be sure...
2331 CDROMREADERSYNTAX
=cddafs
2332 elif [ X$
(uname
) = "XOpenBSD" ] ; then
2335 elif [ X$
(uname
) = "XNetBSD" ] ; then
2342 # If CDDBAVAIL is set to n, no CDDB read is done
2343 # If USEID3 is set to n, no ID3 tagging is done
2348 if [ -z "$OUTPUTDIR" ]; then
2352 if [ -z "$WAVOUTPUTDIR" ]; then
2353 WAVOUTPUTDIR
="$OUTPUTDIR"
2356 # Load system defaults
2357 if [ -r /etc
/abcde.conf
]; then
2360 # Load user preference defaults
2361 if [ -r $HOME/.abcde.conf
]; then
2365 # By this time, we need some HTTPGETOPTS already defined.
2366 # If the user has defined a non-default HTTPGET method, we should not be empty.
2368 if [ "$HTTPGETOPTS" = "" ] ; then
2370 wget
) HTTPGETOPTS
="-q -O -";;
2371 curl
) HTTPGETOPTS
="-f -s";;
2372 fetch
)HTTPGETOPTS
="-q -o -";;
2373 ftp) HTTPGETOPTS
="-q -o -";;
2374 *) echo "abcde warning: HTTPGET in non-standard and HTTPGETOPTS are not defined." >&2 ;;
2378 # If the CDROM has not been set yet, find a suitable one.
2379 # If this is a devfs system, default to /dev/cdroms/cdrom0
2380 # instead of /dev/cdrom
2381 if [ "$CDROM" = "" ] ; then
2382 if [ -e /dev
/cdroms
/cdrom0
]; then
2383 CDROM
=/dev
/cdroms
/cdrom0
2384 elif [ -e /dev
/cdrom
]; then
2386 elif [ -e /dev
/cd0c
]; then
2388 elif [ -e /dev
/acd0c
]; then
2390 elif [ -e /dev
/disk1
]; then
2395 # Parse command line options
2396 #while getopts 1a:A:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do
2397 while getopts 1a
:bc:C
:d
:Dehj
:klLmMnNo
:pPr
:Rs
:S
:t
:T
:vVxw
:W
: opt
; do
2400 a
) ACTIONS
="$OPTARG" ;;
2401 A
) EXPACTIONS
="$OPTARG" ;;
2403 c
) if [ -e "$OPTARG" ] ; then .
"$OPTARG" ; else echo "abcde error: config file \"$OPTARG\" cannot be found." >&2 ; exit 1 ; fi ;;
2404 C
) DISCID
="${OPTARG#abcde.}" ;;
2405 d
) CDROM
="$OPTARG" ;;
2407 e
) ERASEENCODEDSTATUS
=y
;;
2409 e
) ERASEENCODEDSTATUS
=y
;;
2410 E
) ENCODING
="$OPTARG" ;;
2411 # f) FORCECDDBUSELOCAL=y ;;
2413 j
) MAXPROCS
="$OPTARG" ;;
2416 L
) CDDBUSELOCAL
=y
;;
2421 o
) OUTPUTTYPE
="$OPTARG" ;;
2424 r
) REMOTEHOSTS
="$OPTARG" ;;
2426 s
) SHOWCDDBFIELDS
="$OPTARG" ;;
2427 S
) CDSPEEDVALUE
="$OPTARG" ;;
2428 # t) PREPROCESSFORMATS="$OPTARG"
2430 # T) POSTPROCESSFORMATS="$OPTARG" ;;
2431 t
) STARTTRACKNUMBER
="$OPTARG" ;;
2432 T
) STARTTRACKNUMBER
="$OPTARG" ; STARTTRACKNUMBERTAG
="y" ;;
2434 echo "This is abcde v$VERSION."
2435 echo "Usage: abcde [options] [tracks]"
2436 echo "abcde -h for extra help"
2439 V
) EXTRAVERBOSE
="y" ;;
2441 w
) COMMENT
="$OPTARG" ;;
2442 W
) if echo $OPTARG |
grep -q "[[:digit:]]" ; then
2443 STARTTRACKNUMBER
="${OPTARG}01" ; STARTTRACKNUMBERTAG
="y" ; COMMENT
="CD${OPTARG}"
2445 echo "abcde error: argument of -W must be integer"
2453 shift $
(($OPTIND - 1))
2455 # Decide if we can continue.
2456 if [ "$ONETRACK" = "y" ]; then
2457 # FIXME # remove check as soon as we find out about the other readers
2458 case "$CDROMREADERSYNTAX" in
2461 *) echo "abcde error: $CDROMREADERSYNTAX does not support ONETRACK mode"
2464 if [ "$BATCH" = "y" ]; then
2465 echo "abcde error: BATCH mode is not compatible with ONETRACK mode"
2468 # It does not matter how many tracks we want. In ONETRACK mode we grab them all
2469 # FIXME # allow ranges of tracks to be selected for onetrack ripping
2470 if [ $# -gt 0 ]; then
2471 vecho
"abcde warning: ONETRACK mode selected, grabbing all tracks..."
2474 while [ $# -gt 0 ]; do
2475 # Range parsing code courtesy of Vincent Ho
2476 RSTART
=$
(echo $1 | cut
-f1 -d-)
2477 REND
=$
(echo $1 | cut
-f2 -d-)
2478 if [ "$RSTART" = "$REND" ]; then
2481 NEWTRACKS
=$
(f_seq_line
$RSTART $REND)
2483 TRACKQUEUE
=$
(echo "$TRACKQUEUE" "$NEWTRACKS")
2488 # List of valid actions: cddb,read,normalize,encode,tag,move,playlist,clean
2489 # List of experimental actions: retag,transcode
2491 # Determine what actions are to be done from $ACTIONS and set the
2492 # following environment variables for them:
2504 for ACTION
in $
(echo $ACTIONS |
tr , \
)
2509 normalize
) DONORMALIZE
=y
; DOREAD
=y
;;
2510 # preprocess) DOPREPROCESS=y; DOREAD=y;;
2511 encode
) DOENCODE
=y
; DOREAD
=y
;;
2512 # postprocess) DOPREPROCESS=y; DOENCODE=y; DOREAD=y;;
2513 tag
) DOTAG
=y
; DOREAD
=y
; DOENCODE
=y
; DOCDDB
=y
;;
2514 move
) DOMOVE
=y
; DOTAG
=y
; DOREAD
=y
; DOENCODE
=y
; DOCDDB
=y
;;
2515 playlist
) DOCDDB
=y
; DOPLAYLIST
=y
;;
2520 for SHOWCDDBFIELD
in $
(echo $SHOWCDDBFIELDS |
tr , \
); do
2521 case $SHOWCDDBFIELD in
2522 y
*|Y
*) SHOWCDDBYEAR
="y";;
2523 g
*|G
*) SHOWCDDBGENRE
="y";;
2530 # At this point a CDROM has to be defined, so we check it exists.
2531 if [ X
"$CDROM" != "X" ] ; then
2532 if [ "$CDROMREADERSYNTAX" = "cdda2wav" ] && [ "$NEEDCDROMID" = "y" ] ; then
2533 if [ "$OSFLAVOUR" = "FBSD" ]; then
2534 if ! echo "$CDROMID" |
grep "^[0-9],[0-9],[0-9]$" >/dev
/null
2>&1 ; then
2535 echo "abcde error: CDROMID not in the right format for $CDROMREADERSYNTAX"
2536 echo "Use \"cdrecord -scanbus\" to obtain a adecuate ID an set CDROMID accordingly"
2540 elif [ ! -e "$CDROM" -a X
"$DOREAD" = "Xy" ]; then
2541 echo "abcde error: CDROM device cannot be found." >&2
2544 # avoid processing if we are not going to hit the CDROM.
2545 elif [ X
"$DOREAD" = "Xy" ]; then
2546 echo "abcde error: CDROM has not been defined or cannot be found" >&2
2550 # USEPIPES pre-tests, before we get into more serious stuff
2551 # Not compatible with:
2552 # - multiple outputs
2554 # - lowdisk algorithm
2556 if [ X
"$USEPIPES" = "Xy" ]; then
2557 if [ $
(echo "$OUTPUTTYPE" |
tr , \ |
wc -w ) -gt 1 ]; then
2558 echo "abcde error: Unix pipes not compatible with multiple outputs" >&2
2561 if [ X
"$DONORMALIZE" = "Xy" ]; then
2562 echo "abcde error: Unix pipes not compatible with normalizer"
2563 # FIXME # Do we need to exit or shall we just disable the mode?
2566 if [ X
"$DOENCODE" = "Xn" ]; then
2567 vecho
"Disabling Unix pipes since we are not encoding!"
2570 if [ X
"$LOWDISK" = "Xy" ]; then
2571 vecho
"abcde error: Unix pipes not compatible with lowdisk algorithm"
2576 # Check the encoding format from the ones available in the system, if nothing has been configured in the system.
2577 if [ X
"$OUTPUTTYPE" = "X" ]; then
2578 for DEFAULT_OUTPUT
in $
( echo "$DEFAULT_OUTPUT_BINARIES" |
tr , \
); do
2579 DEFAULT_OUTPUT_FORMAT
="$(echo $DEFAULT_OUTPUT | cut -d ":" -f 1)"
2580 DEFAULT_OUTPUT_BINARY
="$(echo $DEFAULT_OUTPUT | cut -d ":" -f 2)"
2581 if [ -x $
(which $DEFAULT_OUTPUT_BINARY) ] ; then
2582 OUTPUTTYPE
=$DEFAULT_OUTPUT_FORMAT
2583 vecho
"No default output type defined. Autoselecting $OUTPUTTYPE..." >&2
2587 if [ X
"$OUTPUTTYPE" = "X" ]; then
2588 echo "abcde error: no encoder found in the PATH" >&2
2589 echo "hits: are all dependencies installed? has the \$PATH been modified?" >&2
2594 # Decide which CDROM reader we're gonna use
2595 case "$CDROMREADERSYNTAX" in
2597 CDROMREADER
="$CDPARANOIA"
2598 CDROMREADEROPTS
="$CDPARANOIAOPTS"
2601 CDROMREADER
="$CDDA2WAV"
2602 CDROMREADEROPTS
="$CDDA2WAVOPTS"
2605 CDROMREADER
="$DAGRAB"
2606 CDROMREADEROPTS
="$DAGRABOPTS"
2609 CDROMREADER
="$CDDAFS"
2610 CDROMREADEROPTS
="$CDDAFSOPTS"
2614 # There's only one normalize...
2615 case "$NORMALIZERSYNTAX" in
2617 NORMALIZER
="$NORMALIZE"
2618 NORMALIZEROPTS
="$NORMALIZEOPTS"
2622 # Allow -o OUTPUT(1):OPTIONS(1),...,OUTPUT(N):OPTIONS(N) mode of operation
2623 if echo "$OUTPUTTYPE" |
grep ":" > /dev
/null
2>&1 ; then
2624 for OUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
); do
2626 vorbis
:*|ogg
:*) OGGENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
2627 mp3
:*) MP3ENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
2628 flac
:*) FLACENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
2629 spx
:*) SPEEXENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
2630 mpc
:*) MPPENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
2633 for OUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
); do
2634 TEMPOUTPUT
=$
( echo "$OUTPUT" | cut
-d: -f1 )
2635 TEMPOUTPUTTYPE
="${TEMPOUTPUTTYPE:+$TEMPOUTPUTTYPE,}$TEMPOUTPUT"
2637 OUTPUTTYPE
="$TEMPOUTPUTTYPE"
2640 # 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
2642 # Getting ready for multiple output changes
2643 for OUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
2647 [ "$OGGENCODERSYNTAX" = "default" ] && OGGENCODERSYNTAX
=oggenc
2648 [ "$DOTAG" = "y" ] && NEEDCOMMENTER
=y
2649 [ "$REPLAYGAIN" = "y" ] && NEEDVORBISGAIN
=y
2650 OGGOUTPUTCONTAINER
=ogg
2653 [ "$MP3ENCODERSYNTAX" = "default" ] && MP3ENCODERSYNTAX
=lame
2654 [ "$DOTAG" = "y" ] && NEEDTAGGER
=y
2657 [ "$FLACENCODERSYNTAX" = "default" ] && FLACENCODERSYNTAX
=flac
2658 [ "$DOTAG" = "y" ] && NEEDMETAFLAC
=y
2661 [ "$SPEEXENCODERSYNTAX" = "default" ] && SPEEXENCODERSYNTAX
=speexenc
2664 [ "$MPPENCODERSYNTAX" = "default" ] && MPPENCODERSYNTAX
=mppenc
2666 *) echo "abcde error: Invalid OUTPUTTYPE defined" >&2
2672 # decide which encoder
2673 case "$MP3ENCODERSYNTAX" in
2675 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$LAMEOPTS}"
2679 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$GOGOOPTS}"
2683 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$BLADEENCOPTS}"
2684 MP3ENCODER
="$BLADEENC"
2687 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$L3ENCOPTS}"
2691 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$XINGMP3ENCOPTS}"
2692 MP3ENCODER
="$XINGMP3ENC"
2695 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$MP3ENCOPTS}"
2696 MP3ENCODER
="$MP3ENC"
2699 case "$OGGENCODERSYNTAX" in
2701 OGGENCODEROPTS
="${OGGENCODEROPTSCLI:-$VORBIZEOPTS}"
2702 OGGENCODER
="$VORBIZE"
2705 OGGENCODEROPTS
="${OGGENCODEROPTSCLI:-$OGGENCOPTS}"
2706 OGGENCODER
="$OGGENC"
2709 case "$FLACENCODERSYNTAX" in
2711 FLACENCODEROPTS
="${FLACENCODEROPTSCLI:-$FLACOPTS}"
2713 # FLAC streams can be encapsulated on a Ogg transport layer
2714 if echo "$FLACENCODEROPTS" |
egrep -q -- "(^| )--ogg($| )" ;then
2715 echo "abcde error: FLAC on an Ogg container is not yet supported" >&2
2716 echo " due to problem with adding comments to such files" >&2
2718 FLACOUTPUTCONTAINER
=ogg
2720 FLACOUTPUTCONTAINER
=flac
2724 case "$SPEEXENCODERSYNTAX" in
2726 SPEEXENCODEROPTS
="${SPEEXENCODEROPTSCLI:-$SPEEXENCOPTS}"
2727 SPEEXENCODER
="$SPEEXENC"
2730 case "$MPPENCODERSYNTAX" in
2732 MPPENCODEROPTS
="${MPPENCODEROPTSCLI:-$MPPENCOPTS}"
2733 MPPENCODER
="$MPPENC"
2739 if [ "$ID3TAGV" = "1" ]; then
2741 TAGGEROPTS
="$ID3OPTS"
2744 TAGGEROPTS
="$ID3V2OPTS"
2748 case "$CUEREADERSYNTAX" in
2750 CUEREADEROPTS
="${CDROM}"
2755 # Check if both OGGEOUTPUTCONTAINER and FLACOUTPUTCONTAINER are the same, and differentiante them
2756 if [ X
"$OGGOUTPUTCONTAINER" = "Xogg" ] && [ X
"$FLACOUTPUTCONTAINER" = "Xogg" ]; then
2757 echo "abcde error: FLAC on an Ogg container is not yet supported" >&2
2758 echo " due to problem with adding comments to such files" >&2
2760 OGGOUTPUTCONTAINER
=ogg.ogg
2761 FLACOUTPUTCONTAINER
=flac.ogg
2762 vecho
"abcde warning: modified file endings due to conflicting transport layers in Ogg/Vorbis and Ogg/FLAC"
2765 # Clean up nice options (either use '-n NICELEVEL or -NICELEVEL')
2767 if [ "$ENCNICE" ]; then
2768 ENCNICE
="-n $ENCNICE"
2770 if [ "$READNICE" ]; then
2771 READNICE
="-n $READNICE"
2773 if [ "$DISTMP3NICE" ]; then
2774 DISTMP3NICE
="-n $DISTMP3NICE"
2777 # Don't check for stuff if it's not needed
2778 if [ "$REMOTEHOSTS" ]; then
2781 if [ "$DONORMALIZE" = "y" ]; then
2784 if [ "$EJECTCD" = "y" ]; then
2787 if [ ! "$CDDBAVAIL" = "n" ] && [ "$DOCDDB" = "y" ]; then
2790 if [ "$MAKECUEFILE" = "y" ]; then
2794 if [ X
"$CDSPEEDVALUE" != "X" ]; then
2795 case "$CDROMREADERSYNTAX" in
2796 cdparanoia|debug
) CDROMREADEROPTS
="$CDPARANOIAOPTS -S $CDSPEEDVALUE" ;;
2801 # Rippers with USEPIPE support
2802 # FIXME # Include here all the rippers we can figure out support pipes
2805 # Encoders with USEPIPE support
2806 # FIXME # Include here all the encoders we can figure out support pipes
2811 # Figure out if we can use pipes with the ripper/encoder combination
2813 if [ "$USEPIPES" = "y" ]; then
2814 PIPERIPPERSVARCHECK
="PIPE_${CDROMREADER}"
2817 PIPEENCODERSVARCHECK
="PIPE_$MP3ENCODERSYNTAX" ;;
2819 PIPEENCODERSVARCHECK
="PIPE_$OGGENCODERSYNTAX" ;;
2821 PIPEENCODERSVARCHECK
="PIPE_$FLACENCODERSYNTAX" ;;
2823 PIPEENCODERSVARCHECK
="PIPE_$SPEEXENCODER" ;;
2825 PIPEENCODERSVARCHECK
="PIPE_$MPPENCODER" ;;
2827 if [ ! -n "$( eval echo "\$
$PIPERIPPERSVARCHECK" )" ] ; then
2828 echo "abcde error: no support for pipes with given ripper" >&2
2829 echo "read the USEPIPES file from the source tarball to help" >&2
2830 echo "on a Debian system, read /usr/share/doc/abcde/USEPIPES.gz" >&2
2833 if [ ! -n "$( eval echo "\$
$PIPEENCODERSVARCHECK" )" ] ; then
2834 echo "abcde error: no support for pipes with given encoder" >&2
2835 echo "read the USEPIPES file from the source tarball to help" >&2
2836 echo "on a Debian system, read /usr/share/doc/abcde/USEPIPES.gz" >&2
2841 # Make sure a buncha things exist
2842 for X
in $CDROMREADER $CDDISCID ${NEEDTAGGER+$TAGGER} $MP3ENCODER \
2843 $OGGENCODER $FLACENCODER $SPEEXENCODER $MPPENCODER \
2844 ${NEEDHTTPGET+$HTTPGET} ${NEEDDISTMP3+$DISTMP3} \
2845 ${NEEDCOMMENTER+$VORBISCOMMENT} ${NEEDMETAFLAC+$METAFLAC} \
2846 ${NEEDNORMALIZER+$NORMALIZER} ${NEEDEJECT+$EJECT} \
2847 ${NEEDDISKTOOL+disktool} ${NEEDCDSPEED+$CDSPEED} \
2848 ${NEEDVORBISGAIN+$VORBISGAIN} ${NEEDCUEREADER+$CUEREADER}
2850 # Cut off the command-line options we just added in
2851 X
=$
(echo $X | cut
-d' ' -f2)
2852 if [ "$(which $X)" = "" ]; then
2853 echo "abcde error: $X is not in your path." >&2
2855 elif [ ! -x $
(which $X) ]; then
2856 echo "abcde error: $X is not executable." >&2
2861 CDROMREADER
="$CDROMREADER $CDROMREADEROPTS"
2862 CDDBTOOL
="$CDDBTOOL $CDDBTOOLOPTS"
2863 HTTPGET
="$HTTPGET $HTTPGETOPTS"
2865 # And last but not least, check if we can diff between files
2866 if [ -x $
(which $DIFF) ]; then :; else
2867 vecho
"[WAR] Disabling diff since we cannot find it in the \$PATH..."
2871 # Here it used to say:
2872 # One thousand lines in, we can start doing stuff with things
2873 # Well, right now we are at line 2736 ;)
2875 # Export needed things so they can be read in this subshell
2876 export CDDBTOOL ABCDETEMPDIR TRACKQUEUE LOWDISK EJECTCD EJECT EJECTOPTS
2877 export CDROM CDDBDATA REMOTEHOSTS MAXPROCS HTTPGET MD5SUM
2879 # User-definable function to set some things. Use it for
2880 # - closing the CD tray with eject -t
2881 # - set the CD speed value with eject -x
2882 vecho
-n "Executing customizable pre-read function... "
2884 pre_read
# Execute the user-defined pre-read funtion. Close the CD with it.
2888 do_discid
# Get ABCDETEMPDIR created and status file initialized
2890 if [ "$DOCDDB" = "y" ]; then
2891 if [ $CDDBUSELOCAL = "y" ]; then
2894 if checkstatus cddb-choice
> /dev
/null
; then
2897 if [ ! "$CDDBLOCALSUCCESS" = "y" ] ; then
2905 eval $
($CDDBTOOL parse
"$CDDBDATA")
2908 # Before reading tracks, we set the speed of the device
2910 if [ X
"$CDSPEEDVALUE" != "X" ]; then
2911 case "$CDROMREADERSYNTAX" in
2912 cdparanoia|debug
) : ;;
2917 # Define the first and last track, since we might need them later in several places
2918 FIRSTTRACK
=$
( get_first
$TRACKQUEUE )
2919 LASTTRACK
=$
( get_last
$TRACKQUEUE )
2921 if [ -f "$ABCDETEMPDIR/status" ] && [ X
"$ERASEENCODEDSTATUS" = "Xy" ]; then
2922 mv "$ABCDETEMPDIR/status" "$ABCDETEMPDIR/status.old"
2923 grep -v ^encodetracklocation-
< "$ABCDETEMPDIR/status.old" \
2924 |
grep -v ^encode-output
> "$ABCDETEMPDIR/status"
2927 # Create playlist if needed (backgroundable) and start reading in tracks
2931 if [ ! "$ONETRACK" = "y" ]; then
2932 if [ "$DOPLAYLIST" = "y" ]; then
2933 echo Creating playlist...
>&2
2938 # For the lowdisk option, only one program is running at once so the encoder
2939 # can be unsilenced right away.
2940 if [ "$LOWDISK" = "y" ] ||
[ "$ONETRACK" = "y" ]; then
2941 echo "encode-output=loud" >> "$ABCDETEMPDIR/status"
2944 if [ "$ONETRACK" = "y" ]; then
2945 TRACKS
="$FIRSTTRACK"
2946 if checkstatus readtrack-
$FIRSTTRACK; then :; else
2947 do_cdread onetrack
$FIRSTTRACK $LASTTRACK
2950 for UTRACKNUM
in $TRACKQUEUE
2952 if [ "$DOREAD" = "y" ]; then
2953 if [ "$USEPIPES" = "y" ]; then
2954 if checkstatus readencodetrack-
$UTRACKNUM; then :; else
2955 # Read, pipe, shut up!
2956 do_cdread
$UTRACKNUM | do_encode
$UTRACKNUM %local0
% > /dev
/null
2>&1
2959 if checkstatus readtrack-
$UTRACKNUM; then :; else
2960 do_cdread
$UTRACKNUM
2962 if [ "$?" != "0" ]; then
2963 # CD read failed - don't give the goahead to
2970 if [ "$BATCH" = "y" ]; then
2973 echo NEXTTRACK
# Get the encoder machine churning again
2974 if [ "$DOREAD" = "y" ]; then
2975 if [ "$LOWDISK" = "y" ] && [ "$DOENCODE" = "y" ]; then
2976 until checkstatus encodetrack-
$UTRACKNUM
2978 if checkerrors encodetrack-
$UTRACKNUM; then
2989 # Now that we're done the encoding can be loud again -
2990 # if we're not using SMP.
2991 if [ "$MAXPROCS" = "1" ]; then
2992 echo "encode-output=loud" >> "$ABCDETEMPDIR/status"
2995 # All tracks read, start encoding.
2996 if [ "$BATCH" = "y" ] ||
[ "$ONETRACK" = "y" ]; then
3000 # Execute the user-defined post_read funtion before ejecting CD
3003 # We are now finished with the cdrom - it can be safely ejected. Note that
3004 # abcde will not have completed yet.
3005 if [ "$EJECTCD" = "y" ] && [ -x $
(which $EJECT) ]; then
3006 # We check if the disk we are processing is actually the disk inside the
3007 # CD tray. If not, we do not eject the CD, since it might be so that the
3008 # user ejected it manually.
3009 #CURRENTTRACKINFO=$($CDDISCID $CDROM)
3010 #if if [ "$?" != "1" ] && [ "$CURRENTTRACKINFO" = "$TRACKINFO" ] ; then
3011 # More FreeBSD bits.
3012 if [ X
"$(uname)" = X
"FreeBSD" ] ; then
3013 # FreeBSD eject uses the EJECT environment variable to name the CDROM
3014 # but in this script EJECT is in the envionment and names the program
3017 # The FreeBSD eject needs "adc0" not "/dev/adc0c"
3018 cd="$(echo $CDROM | sed -e 's=.*/==;s=[a-h]$==;')"
3019 $eject $EJECTOPTS $cd
3020 elif [ X
"$(uname)" = X
"Darwin" ] ; then
3021 disktool
-e ${CDROM#/dev/} 0
3023 $EJECT $EJECTOPTS $CDROM
3030 ## Do we need to pre-process
3031 #if [ x"$PREPROCESS" = "x" ] ; then
3034 # for PRETRACKNUM in $TRACKQUEUE
3037 # if [ "$GOAHEAD" = "NO" ]; then break; fi
3039 # until [ $PREPROCEED ]
3041 # if checkstatus readtrack-$PRETRACKNUM; then PREPROCEED=y; break; fi
3042 # # all locations are working, wait and try again later
3043 # if [ ! $PREPROCEED ]; then sleep 3; fi
3045 # ( do_preprocess $PRETRACKNUM
3053 # In batch mode, we want all tracks to be read first.
3054 if [ "$BATCH" = "y" ]; then
3055 read GOAHEAD
# For blocking - will contain either "NO" or "NEXTTRACK"
3056 if [ "$GOAHEAD" = "NO" ]; then break; fi
3057 for LASTTRACK
in $TRACKQUEUE; do :; done
3058 if checkstatus readtrack-
$LASTTRACK; then
3059 if [ "$DONORMALIZE" = "y" ]; then
3060 if checkstatus normalizetrack-
$LASTTRACK; then :; else do_batch_normalize
; fi
3061 if checkerrors batch-normalize
; then exit; fi
3063 if [ "$DOENCODE" = "y" ]; then
3064 if checkstatus encodetrack-
$LASTTRACK; then :; else do_batch_encode
; fi
3065 if checkerrors batch-encode
; then exit; fi
3070 # If we are using ONETRACK, we can proceed with the normal encoding using just the $FIRSTTRACK as TRACKQUEUE
3071 if [ "$ONETRACK" = "y" ] ; then
3072 TRACKQUEUE
="$FIRSTTRACK"
3073 TRACKS
="$FIRSTTRACK"
3076 # Do the encoding, including parallelization of remote encoding
3077 # Figure out where each track is going to be encoded
3078 ENCODELOCATIONS
="$(echo $REMOTEHOSTS | tr , ' ')"
3079 if [ "$MAXPROCS" != "0" ]; then
3080 for NUM
in $
(f_seq_row
1 "$MAXPROCS")
3082 ENCODELOCATIONS
="$ENCODELOCATIONS %local$NUM%"
3086 ENCODELOCATIONS
=$
(echo $ENCODELOCATIONS)
3087 for UTRACKNUM
in $TRACKQUEUE
3090 read GOAHEAD
# For blocking - will contain either "NO" or "NEXTTRACK"
3091 if [ "$GOAHEAD" = "NO" ]; then break; fi
3092 # find out where this track is to be encoded
3093 if [ "$DOENCODE" = "y" -a "$USEPIPES" != "y" ]; then
3094 # Make sure we have a place to encode this, if not, exit stage right
3095 if [ -z "$ENCODELOCATIONS" ]; then
3101 for LOCATION
in $ENCODELOCATIONS
3103 PREVIOUSTRACK
="$(checkstatus encodetracklocation-$LOCATION)"
3104 # check first if a track has ever been assigned to this location
3105 if [ -z "$PREVIOUSTRACK" ]; then PROCEED
=y
; break; fi
3106 # If it errored out, rebuild $ENCODELOCATIONS without this location in it
3107 if checkerrors encodetrack-
$PREVIOUSTRACK; then
3108 for TEMPLOCATION
in $ENCODELOCATIONS
3110 if [ "$TEMPLOCATION" != "$LOCATION" ]; then
3111 TEMPENCODELOCATIONS
="$TEMPENCODELOCATIONS $TEMPLOCATION"
3114 ENCODELOCATIONS
=$
(echo $TEMPENCODELOCATIONS)
3119 # We're still here, this location must have been previously assigned,
3120 # and last completed without error - check if it's done with the
3121 # previous track yet
3122 if checkstatus encodetrack-
$PREVIOUSTRACK; then PROCEED
=y
; break; fi
3124 # all locations are working, wait and try again later
3125 if [ ! $PROCEED ]; then sleep 3; fi
3127 # Record the location we're about to encode the next track at
3128 echo "encodetracklocation-$LOCATION=$UTRACKNUM" >> "$ABCDETEMPDIR/status"
3130 # Don't proceed with the rest of the loop if we can't encode
3131 if [ "$ABORT" ]; then continue; fi
3132 # Set TRACKNUM, TRACKNAME
3133 if [ -e "$CDDBDATA" ]; then
3134 if [ "$ONETRACK" = "y" ]; then
3136 TRACKNUM
="$FIRSTTRACK"
3139 # TRACKNUM=$(printf %0.${TRACKNUMPADDING}d $(expr ${UTRACKNUM} + 0))
3141 CDDBTRACKNUM
=$
(expr $UTRACKNUM - 1)
3142 #TRACKNAME="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
3143 do_getcddbinfo TRACKNAME
3147 # You can't encode a file which needs to be normalized before finishing
3148 # You can't tag a file before it's finished encoding -
3149 # thus all of this is backgrounded together
3151 if [ "$DONORMALIZE" = "y" ]; then
3152 if checkstatus readtrack-
$UTRACKNUM; then
3153 if checkstatus normalizetrack-
$UTRACKNUM; then :; else do_normalize
$UTRACKNUM; fi
3156 if [ "$DOENCODE" = "y" -a "$USEPIPES" != "y" ]; then
3157 if checkstatus readtrack-
$UTRACKNUM; then
3158 #if checkstatus encodetrack-$UTRACKNUM; then :; else do_encode $UTRACKNUM $LOCATION; fi
3159 if [ "$DONORMALIZE" = "y" ]; then
3160 if checkstatus normalizetrack-
$UTRACKNUM; then
3161 if checkstatus encodetrack-
$UTRACKNUM; then :; else do_encode
$UTRACKNUM $LOCATION $OUTPUT; fi
3164 if checkstatus encodetrack-
$UTRACKNUM; then :; else do_encode
$UTRACKNUM $LOCATION $OUTPUT; fi
3168 if [ "$DOTAG" = "y" ]; then
3169 if checkstatus encodetrack-
$UTRACKNUM; then
3170 if checkstatus tagtrack-
$UTRACKNUM; then :; else do_tag
$UTRACKNUM; fi
3172 # Lets tag the cue file
3173 if checkstatus cleancuefile
>/dev
/null
; then :; else
3174 if checkstatus cuefile
>/dev
/null
; then
3179 if [ "$DOMOVE" = "y" ]; then
3180 if checkstatus tagtrack-
$UTRACKNUM; then
3181 if checkstatus movetrack-
$UTRACKNUM; then :; else do_move
$UTRACKNUM; fi
3188 # Go through it again and make sure there's no distmp3 stragglers, otherwise
3189 # we'll delete the files they're working on
3190 ## FIXME ## Check also for files which are encoded using PIPEs.
3191 if [ "$DOENCODE" = "y" -a "$USEPIPES" != "y" ]; then
3196 for LOCATION
in $ENCODELOCATIONS
3198 CHECKTRACK
="$(checkstatus encodetracklocation-$LOCATION)"
3199 # "How can he give us a status update, if he's DEAD?"
3200 if checkstatus encodetrack-
$CHECKTRACK; then
3203 # Nothing to see here please go quietly back to your homes
3204 if [ -z "$CHECKTRACK" ]; then continue; fi
3205 # You're still here? Maybe there is something...
3206 if checkstatus encodetrack-
$CHECKTRACK; then :; else PROCEED
= ; break; fi
3209 if [ ! $PROCEED ]; then sleep 5; fi
3212 # If the above didn't catch the stragglers, this will
3214 if checkstatus replaygain
; then :; else
3217 # Check to see if run_command logged any errors
3218 if [ -f "$ABCDETEMPDIR/errors" ]; then
3219 echo "The following commands failed to run:"
3220 cat "$ABCDETEMPDIR/errors"
3224 if [ "$KEEPWAVS" = "y" ];then
3228 if [ "$DOCLEAN" = "y" ]; then
3229 # Wipe all the evidence
3230 # Gimme gimme gimme some more time!
3232 rm -rf "$ABCDETEMPDIR"
3235 echo "Finished. Not cleaning $ABCDETEMPDIR."