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.
16 VERSION
='2.3.99-$Revision$'
20 echo "This is abcde v$VERSION."
21 echo "Usage: abcde [options] [tracks]"
23 echo "-1 Encode the whole CD in a single file"
24 echo "-a <action1[,action2]...>"
25 echo " Actions to perform:"
26 echo " cddb,read,normalize,encode,tag,move,replaygain,playlist,clean"
27 #echo "-A Experimental actions (retag, transcode)"
28 echo "-b Enable batch normalization"
29 #echo "-B Disable batch replaygain (do file by file)"
31 echo " Specify a configuration file (overrides system and user config files)"
33 echo " Specify discid to resume from (only needed if you no longer have the cd)"
35 echo " Specify CDROM device to grab (flac uses a single-track flac file)"
36 echo "-D Debugging mode (equivalent to sh -x abcde)"
37 echo "-e Erase encoded track information from status file"
38 echo "-f Force operations that otherwise are considered harmful. Read \"man abcde\""
39 echo "-g Use \"lame --nogap\" for MP3 encoding. Disables low disk and pipes flags"
40 echo "-h This help information"
41 #echo "-i Tag files while encoding, when possible (local only) -NWY-"
42 echo "-j <#> Number of encoder processes to run at once (localhost)"
43 echo "-k Keep the wav tracks for later use"
44 echo "-l Use low disk space algorithm"
45 echo "-L Use local CDDB storage directory"
46 echo "-n No lookup. Don't query CDDB, just create and use template"
47 echo "-N Noninteractive. Never prompt for anything"
48 echo "-m Modify playlist to include CRLF endings, to comply with some players"
49 echo "-M Create a CUE file"
50 echo "-o <type1[,type2]...>"
51 echo " Output file type(s) (vorbis,mp3,flac,spx,mpc,wav,m4a). Defaults to vorbis"
52 echo "-p Pad track numbers with 0's (if less than 10 tracks)"
53 echo "-P Use UNIX pipes to read+encode without wav files"
54 echo "-r <host1[,host2]...>"
55 echo " Also encode on these remote hosts"
56 echo "-R Use local CDDB in recursive mode"
57 #echo "-R Add replaygain values to the tag info (only for vorbis,flac,mp3)"
59 echo " Show dielfs from the CDDB info (year,genre)"
60 echo "-S <#> Set the CD speed"
61 echo "-t <#> Start the track numbering at a given number"
62 echo "-T <#> Same as -t but modifies tag numbering"
63 echo "-u Use UNICODE tags and comments"
64 echo "-v Show version number and exit"
65 echo "-V Be a bit more verbose about what is happening behind the scenes"
66 echo "-x Eject CD after all tracks are read"
68 echo " Add a comment to the CD tracks"
69 echo "-W <#> Contatenate CDs: -T #01 -w \"CD #\""
70 echo "-z Use debug CDROMREADERSYNTAX option (needs cdparanoia)"
72 echo "Tracks is a space-delimited list of tracks to grab."
73 echo "Ranges specified with hyphens are allowed (i.e., 1-5)."
75 #echo "Double hyphens are used to concatenate tracks"
80 echo "$@" >> "$ABCDETEMPDIR/status"
83 # log [level] [message]
85 # log outputs the right message in a common format
91 error
) echo "[ERROR] abcde: $@" >&2 ;;
92 warning
) echo "[WARNING] $@" >&2 ;;
93 info
) echo "[INFO] $@" ;;
97 # Funtions to replace the need of seq, which is too distribution dependant.
101 while [ $i -ne `expr $2 + 1` ]
111 if echo $i |
grep "[[:digit:]]" > /dev
/null
2>&1 ; then
112 while [ $i -ne `expr $2 + 1` ]
119 log error
"syntax error while processing track numbers"
124 # Functions to replace the need of awk {print $1} and {print $NF}
127 if [ X
"$1" = "X" ]; then
128 for first
in `cat`; do
139 if [ X
"$1" = "X" ]; then
140 for stdin
in `cat`; do
144 for last
in $@
; do :; done
149 # checkstatus [blurb]
150 # Returns "0" if the blurb was found, returns 1 if it wasn't
151 # Puts the blurb content, if available, on stdout.
152 # Otherwise, returns "".
155 # Take the last line in the status file if there's multiple matches
157 BLURB
=$
(egrep $PATTERN "$ABCDETEMPDIR/status" |
tail -n 1)
159 if [ -z "$BLURB" ]; then
164 # See if there's a = in it
165 if [ "$(echo $BLURB | grep -c =)" != "0" ]; then
166 echo "$(echo $BLURB | cut -f2- -d=)"
172 # chechwarnings [blurb]
173 # Returns "0" if the blurb was found (meaning there was an warning),
174 # returns 1 if it wasn't (yes this is a little backwards).
175 # Does not print the blurb on stdout.
176 # Otherwise, returns "".
179 if [ -e "$ABCDETEMPDIR/warnings" ]; then :; else
182 # Take the last line in the status file if there's multiple matches
184 BLURB
="$(egrep $PATTERN "$ABCDETEMPDIR/warnings
" | tail -n 1)"
186 if [ -z "$BLURB" ]; then
187 # negative, we did not have a negative...
190 # affirmative, we had a negative...
195 # checkerrors [blurb]
196 # Returns "0" if the blurb was found (meaning there was an error),
197 # returns 1 if it wasn't (yes this is a little backwards).
198 # Does not print the blurb on stdout.
199 # Otherwise, returns "".
202 if [ -e "$ABCDETEMPDIR/errors" ]; then :; else
205 # Take the last line in the status file if there's multiple matches
207 BLURB
="$(egrep $PATTERN "$ABCDETEMPDIR/errors
" | tail -n 1)"
209 if [ -z "$BLURB" ]; then
210 # negative, we did not have a negative...
213 # affirmative, we had a negative...
219 # Finds the right pager in the system to display a file
223 # Use the debian sensible-pager wrapper to pick the pager
224 # user has requested via their $PAGER environment variable
225 if [ -x "/usr/bin/sensible-pager" ]; then
226 /usr
/bin
/sensible-pager
"$PAGEFILE"
227 elif [ -x "$PAGER" ]; then
228 # That failed, try to load the preferred editor, starting
229 # with their PAGER variable
231 # If that fails, check for less
232 elif [ -x /usr
/bin
/less ]; then
233 /usr
/bin
/less -f "$PAGEFILE"
234 # more should be on all UNIX systems
235 elif [ -x /bin
/more ]; then
236 /bin
/more "$PAGEFILE"
238 # No bananas, just cat the thing
243 # run_command [blurb] [command...]
244 # Runs a command, silently if necessary, and updates the status file
249 # See if this is supposed to be silent
250 if [ "$(checkstatus encode-output)" = "loud" ]; then
254 # Special case for SMP, since
255 # encoder output is never displayed, don't mute echos
256 if [ -z "$BLURB" -a "$MAXPROCS" != "1" ]; then
265 normalize|normalize-audio
)
266 if [ "$RETURN" = "2" ]; then
267 # File was already normalized.
272 if [ "$RETURN" != "0" ]; then
273 # Put an error in the errors file. For various reasons we
274 # can't capture a copy of the program's output but we can
275 # log what we attempted to execute and the error code
276 # returned by the program.
277 if [ "$BLURB" ]; then
280 echo "${TWEAK}returned code $RETURN: $@" >> "$ABCDETEMPDIR/errors"
281 return $RETURN # Do not pass go, do not update the status file
283 if [ "$BLURB" ]; then
284 echo $BLURB >> "$ABCDETEMPDIR/status"
288 # relpath() and slash() are Copyright (c) 1999 Stuart Ballard and
289 # distributed under the terms of the GNU GPL v2 or later, at your option
291 # Function to determine if a word contains a slash.
300 # Function to give the relative path from one file to another.
301 # Usage: relpath fromfile tofile
302 # eg relpath music/Artist/Album.m3u music/Artist/Album/Song.mp3
303 # (the result would be Album/Song.mp3)
304 # Output is relative path to $2 from $1 on stdout
306 # This code has the following restrictions:
307 # Multiple ////s are not collapsed into single /s, with strange effects.
308 # Absolute paths and ../s are handled wrong in FR (but they work in TO)
309 # If FR is a directory it must have a trailing /
317 /*) ;; # No processing is needed for absolute paths
319 # Loop through common prefixes, ignoring them.
320 while slash
"$FR" && [ "$(echo "$FR" | cut -d/ -f1)" = "$(echo "$TO" | cut -d/ -f1)" ]
322 FR
="$(echo "$FR" | cut -d/ -f2-)"
323 TO
="$(echo "$TO" | cut -d/ -f2-)"
325 # Loop through directory portions left in FR, adding appropriate ../s.
328 FR
="$(echo "$FR" | cut -d/ -f2-)"
339 if [ ! "$@" = "" ]; then
340 # Cut off any command-line option we added in
341 X
=$
(echo $@ | cut
-d' ' -f2)
342 if [ "$(which $X)" = "" ]; then
344 elif [ ! -x $
(which $X) ]; then
353 if [ ! "$@" = "" ]; then
354 # Cut off any command-line option we added in
355 X
=$
(echo $@ | cut
-d' ' -f2)
356 if [ "$(which $X)" = "" ]; then
357 log error
"$X is not in your path." >&2
358 log info
"Define the full path to the executable if it exists on your system." >&2
360 elif [ ! -x $
(which $X) ]; then
361 log error
"$X is not executable." >&2
367 # diffentries <filename> <max_value> <entry1>,<entry2>
368 # max_value: the range of entries goes from 1 to <max_value>
373 local CDDBDIFFCHOICES
=$1
375 local CDDBDIFFCHOICE
="$@"
376 if [ ! X
"$DIFF" = "X" ]; then
377 PARSECHOICE1
=$
(echo $CDDBDIFFCHOICE | cut
-d"," -f1 |
xargs printf %d
2>/dev
/null
)
378 PARSECHOICE2
=$
(echo $CDDBDIFFCHOICE | cut
-d"," -f2 |
xargs printf %d
2>/dev
/null
)
379 if [ $PARSECHOICE1 -lt 1 ] ||
[ $PARSECHOICE1 -gt $CDDBDIFFCHOICES ] || \
380 [ $PARSECHOICE2 -lt 1 ] ||
[ $PARSECHOICE2 -gt $CDDBDIFFCHOICES ] || \
381 [ $PARSECHOICE1 -eq $PARSECHOICE2 ]; then
382 echo "Invalid diff range. Please select two coma-separated numbers between 1 and $CDDBDIFFCHOICES" >&2
384 # We parse the 2 choices to diff, store them in temporary files and diff them.
385 for PARSECHOICE
in $
(echo $CDDBDIFFCHOICE |
tr , \
); do
386 do_cddbparse
"$ABCDETEMPDIR/$FILENAME.$PARSECHOICE" > "$ABCDETEMPDIR/$FILENAME.parsechoice.$PARSECHOICE"
388 echo "Showing diff between choices $PARSECHOICE1 and $PARSECHOICE2..." > "$ABCDETEMPDIR/$FILENAME.diff"
389 $DIFF $DIFFOPTS "$ABCDETEMPDIR/$FILENAME.parsechoice.$PARSECHOICE1" "$ABCDETEMPDIR/$FILENAME.parsechoice.$PARSECHOICE2" >> "$ABCDETEMPDIR/$FILENAME.diff"
390 if [ $
(cat "$ABCDETEMPDIR/$FILENAME.diff" |
wc -l) -ge 24 ]; then
391 page
"$ABCDETEMPDIR/$FILENAME.diff"
393 cat "$ABCDETEMPDIR/$FILENAME.diff" >&2
397 echo "The diff program was not found in your path. Please choose a number between 0 and $CDDBDIFFCHOICES." >&2
402 # Finds an specific field from cddbinfo
407 TRACKNAME
="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
410 TRACKNAME
="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
416 # Get the track number we are going to use for different actions
419 if [ -n "$STARTTRACKNUMBER" ] ; then
420 # Get the trackpadding from the current track
421 CURRENTTRACKPADDING
=$
(echo -n $UTRACKNUM |
wc -c)
422 TRACKNUM
=$
( printf %0.
${CURRENTTRACKPADDING}d $(expr ${UTRACKNUM} + ${STARTTRACKNUMBER} - $FIRSTTRACK ))
424 TRACKNUM
=${UTRACKNUM}
430 if checkstatus replaygain
; then :; else
431 run_command
"" echo "Adding replygain information..."
432 for TMPOUTPUT
in $
( echo $OUTPUTTYPE |
tr , \
)
436 OUTPUT
=$OGGOUTPUTCONTAINER
439 OUTPUT
=$FLACOUTPUTCONTAINER
447 for UTRACKNUM
in $TRACKQUEUE
449 CDDBTRACKNUM
=$
(expr $UTRACKNUM - 1)
450 getcddbinfo TRACKNAME
452 TRACKFILE
="$(mungefilename "$TRACKNAME")"
453 ARTISTFILE
="$(mungefilename "$TRACKARTIST")"
454 ALBUMFILE
="$(mungefilename "$DALBUM")"
456 if [ "$VARIOUSARTISTS" = "y" ]; then
457 OUTPUTFILE
="$(eval echo "$VAOUTPUTFORMAT")"
459 OUTPUTFILE
="$(eval echo "$OUTPUTFORMAT")"
461 OUTPUTFILES
[$REPLAYINDEX]="$OUTPUTDIR/$OUTPUTFILE.$OUTPUT"
462 (( REPLAYINDEX
= $REPLAYINDEX + 1 ))
466 run_command replaygain-flac
$METAFLAC --add-replay-gain "${OUTPUTFILES[@]}"
469 run_command replaygain-vorbis
$VORBISGAIN --album "${OUTPUTFILES[@]}"
472 run_command replaygain-mp3
$MP3GAIN -a "${OUTPUTFILES[@]}"
475 run_command replaygain-mpc
$MPPGAIN --auto "${OUTPUTFILES[@]}"
480 if checkerrors
"replaygain-.{3,6}"; then :; else
481 run_command replaygain true
486 # This code splits the a Various Artist track name from one of the following
489 # forward: Artist / Track
490 # forward-dash: Artist - Track
491 # reverse: Track / Artist
492 # reverse-dash: Track - Artist
493 # colon: Artist: Track
494 # trailing-paren: Artist (Track)
497 # VARIOUSARTISTS, VARIOUSARTISTSTYLE, TRACKNAME, TRACKARTIST
500 if [ "$VARIOUSARTISTS" = "y" ] && [ ! "$ONETRACK" = "y" ]; then
501 case "$VARIOUSARTISTSTYLE" in
503 DTITLEARTIST
="$(echo "$TRACKNAME" | sed 's- / -~-g')"
504 TRACKARTIST
="$(echo "$DTITLEARTIST" | cut -f1 -d~)"
505 TRACKNAME
="$(echo "$DTITLEARTIST" | cut -f2 -d~)"
508 DTITLEARTIST
="$(echo "$TRACKNAME" | sed 's, - ,~,g')"
509 TRACKARTIST
="$(echo "$DTITLEARTIST" | cut -f1 -d~)"
510 TRACKNAME
="$(echo "$DTITLEARTIST" | cut -f2 -d~)"
513 DTITLEARTIST
="$(echo "$TRACKNAME" | sed 's- / -~-g')"
514 TRACKARTIST
="$(echo "$DTITLEARTIST" | cut -f2 -d~)"
515 TRACKNAME
="$(echo "$DTITLEARTIST" | cut -f1 -d~)"
518 DTITLEARTIST
="$(echo "$TRACKNAME" | sed 's, - ,~,g')"
519 TRACKARTIST
="$(echo "$DTITLEARTIST" | cut -f2 -d~)"
520 TRACKNAME
="$(echo "$DTITLEARTIST" | cut -f1 -d~)"
523 DTITLEARTIST
="$(echo "$TRACKNAME" | sed 's-: -~-g')"
524 TRACKARTIST
="$(echo "$DTITLEARTIST" | cut -f1 -d~)"
525 TRACKNAME
="$(echo "$DTITLEARTIST" | cut -f2 -d~)"
528 DTITLEARTIST
="$(echo "$TRACKNAME" | sed 's,^\(.*\) (\(.*\)),\1~\2,')"
529 TRACKARTIST
="$(echo "$DTITLEARTIST" | cut -f2 -d~)"
530 TRACKNAME
="$(echo "$DTITLEARTIST" | cut -f1 -d~)"
533 elif [ "$VARIOUSARTISTS" = "y" ] && [ "$ONETRACK" = "y" ]; then
534 TRACKARTIST
="Various"
536 TRACKARTIST
="$DARTIST"
541 local genre
=$
(echo "${@}" |
tr '[A-Z]' '[a-z]')
545 "classic rock") id
=1 ;;
563 "industrial") id
=19 ;;
564 "alternative") id
=20 ;;
566 "death metal") id
=22 ;;
568 "soundtrack") id
=24 ;;
569 "euro-techno") id
=25 ;;
573 "jazz+funk") id
=29 ;;
576 "classical") id
=32 ;;
577 "instrumental") id
=33 ;;
581 "sound clip") id
=37 ;;
584 "alt. rock") id
=40 ;;
589 "meditative") id
=45 ;;
590 "instrum. pop") id
=46 ;;
591 "instrum. rock") id
=47 ;;
595 "techno-indust.") id
=51 ;;
596 "electronic") id
=52 ;;
598 "eurodance") id
=54 ;;
600 "southern rock") id
=56 ;;
605 "christian rap") id
=61 ;;
606 "pop/funk"|
"pop / funk") id
=62 ;;
608 "native american") id
=64 ;;
611 "psychadelic") id
=67 ;;
613 "showtunes") id
=69 ;;
617 "acid punk") id
=73 ;;
618 "acid jazz") id
=74 ;;
622 "rock & roll") id
=78 ;;
623 "hard rock") id
=79 ;;
625 "folk/rock") id
=81 ;;
626 "national folk") id
=82 ;;
633 "bluegrass") id
=89 ;;
634 "avantgarde") id
=90 ;;
635 "gothic rock") id
=91 ;;
636 "progress. rock") id
=92 ;;
637 "psychadel. rock") id
=93 ;;
638 "symphonic rock") id
=94 ;;
639 "slow rock") id
=95 ;;
642 "easy listening") id
=98 ;;
648 "chamber music") id
=104 ;;
650 "symphony") id
=106 ;;
651 "booty bass") id
=107 ;;
653 "porn groove") id
=109 ;;
655 "slow jam") id
=111 ;;
659 "folklore") id
=115 ;;
661 "power ballad") id
=117 ;;
662 "rhythmic soul") id
=118 ;;
663 "freestyle") id
=119 ;;
665 "punk rock") id
=121 ;;
666 "drum solo") id
=122 ;;
667 "a capella") id
=123 ;;
668 "euro-house") id
=124 ;;
669 "dance hall") id
=125 ;;
671 "drum & bass") id
=127 ;;
672 "club-house") id
=128 ;;
673 "hardcore") id
=129 ;;
677 "negerpunk") id
=133 ;;
678 "polsk punk") id
=134 ;;
680 "christian gangsta rap") id
=136 ;;
681 "heavy metal") id
=137 ;;
682 "black metal") id
=138 ;;
683 "crossover") id
=139 ;;
684 "contemporary christian")id
=140 ;;
685 "christian rock") id
=141 ;;
686 "merengue") id
=142 ;;
688 "thrash metal") id
=144 ;;
691 "synthpop") id
=147 ;;
692 "rock/pop"|
"rock / pop") id
=148 ;;
699 # do_tag [tracknumber]
700 # id3 tags a filename
702 # TRACKS, TRACKNAME, TRACKARTIST, TAGGER, TAGGEROPTS, VORBISCOMMENT, METAFLAC,
703 # COMMENT, DALBUM, DARTIST, CDYEAR, CDGENRE (and temporarily) ID3TAGV
706 COMMENTOUTPUT
="$(eval echo ${COMMENT})"
707 CDDBDISCID
=$
(echo $TRACKINFO | cut
-d' ' -f1)
708 run_command
'' echo "Tagging track $1 of $TRACKS: $TRACKNAME..."
709 # If we want to start the tracks with a given number, we need to modify the
710 # TRACKNUM value before evaluation
711 if [ -n "$STARTTRACKNUMBERTAG" ] ; then
714 for OUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
718 # id3v2 v0.1.9 claims to have solved the -c bug, so we merge both id3 and id3v2
719 GENREID
=$
(do_getgenreid
"${CDGENRE}")
724 # FIXME # track numbers in mp3 come with 1/10, so we cannot happily substitute them with $TRACKNUM
725 run_command tagtrack-
$OUTPUT-$1 $TAGGER $TAGGEROPTS --commen=::"$COMMENTOUTPUT" \
726 -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" -Y "$CDYEAR" \
727 -G "$GENREID" -n "${TRACKNUM:-$1}" "${TRACKNUM:+-N $TRACKS}" \
728 "${ENCODING:+--set-encoding=$ENCODING}"
729 "$ABCDETEMPDIR/track$1.$OUTPUT"
732 # FIXME # track numbers in mp3 come with 1/10, so we cannot happily substitute them with $TRACKNUM
733 run_command tagtrack-
$OUTPUT-$1 $TAGGER $TAGGEROPTS -c "$COMMENTOUTPUT" \
734 -A "$DALBUM" -a "$TRACKARTIST" -t "$TRACKNAME" -y "$CDYEAR" \
735 -g "$GENREID" -T "${TRACKNUM:-$1/$TRACKS}" \
736 "$ABCDETEMPDIR/track$1.$OUTPUT"
741 case "$OGGENCODERSYNTAX" in
743 # vorbiscomment can't do in-place modification, mv the file first
744 if [ -f "$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER" -a ! -f "$ABCDETEMPDIR/track$1.uncommented.$OGGOUTPUTCONTAINER" ]; then
745 mv "$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER" "$ABCDETEMPDIR/track$1.uncommented.$OGGOUTPUTCONTAINER"
748 # These are from http://www.xiph.org/ogg/vorbis/doc/v-comment.html
749 echo ARTIST
="$TRACKARTIST"
751 echo TITLE
="$TRACKNAME"
752 if [ -n "$CDYEAR" ]; then
755 if [ -n "$CDGENRE" ]; then
756 echo GENRE
="$CDGENRE"
758 echo TRACKNUMBER
=${TRACKNUM:-$1}
759 echo CDDB
=$CDDBDISCID
760 if [ "$(eval echo ${COMMENT})" != "" ]; then
761 case "$COMMENTOUTPUT" in
762 *=*) echo "$COMMENTOUTPUT";;
763 *) echo COMMENT
="$COMMENTOUTPUT";;
766 ) | run_command tagtrack-
$OUTPUT-$1 $VORBISCOMMENT $VORBISCOMMENTOPTS -w \
767 "$ABCDETEMPDIR/track$1.uncommented.$OGGOUTPUTCONTAINER" "$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER"
768 # Doublecheck that the commented file was created successfully before wiping the original
769 if [ -f "$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER" ]; then
770 rm -f "$ABCDETEMPDIR/track$1.uncommented.$OGGOUTPUTCONTAINER"
772 mv "$ABCDETEMPDIR/track$1.uncommented.$OGGOUTPUTCONTAINER" "$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER"
779 echo ARTIST
="$TRACKARTIST"
781 echo TITLE
="$TRACKNAME"
782 if [ -n "$CDYEAR" ]; then
785 if [ -n "$CDGENRE" ]; then
786 echo GENRE
="$CDGENRE"
788 echo TRACKNUMBER
="${TRACKNUM:-$1}"
789 echo CDDB
="$CDDBDISCID"
790 if [ "$(eval echo ${COMMENT})" != "" ]; then
791 case "$COMMENTOUTPUT" in
792 *=*) echo "$COMMENTOUTPUT";;
793 *) echo COMMENT
="$COMMENTOUTPUT";;
796 ) | run_command tagtrack-
$OUTPUT-$1 $METAFLAC $METAFLACOPTS ${IMPORTCUESHEET:+--import-cuesheet-from="$ABCDETEMPDIR/$CUEFILE"} --import-tags-from=- "$ABCDETEMPDIR/track$1.$FLACOUTPUTCONTAINER"
799 run_command tagtrack-
$OUTPUT-$1 true
802 run_command tagtrack-
$OUTPUT-$1 true
805 run_command tagtrack-
$OUTPUT-$1 true
808 run_command tagtrack-
$OUTPUT-$1 true
812 if checkerrors
"tagtrack-(.{3,6})-$1"; then :; else
813 run_command tagtrack-
$1 true
820 # OUTPUTTYPE, {FOO}ENCODERSYNTAX, ENCNICE, ENCODER, ENCODEROPTS
823 # The commands here don't go through run_command because they're never supposed to be silenced
824 echo "Encoding gapless MP3 tracks: $TRACKQUEUE"
825 for OUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
829 case "$MP3ENCODERSYNTAX" in
834 for UTRACKNUM
in $TRACKQUEUE
836 TRACKFILES
="$TRACKFILES track$UTRACKNUM.wav"
838 nice
$ENCNICE $MP3ENCODER $MP3ENCODEROPTS --nogap $TRACKFILES
840 if [ "$RETURN" != "0" ]; then
841 echo "nogap-encode: $ENCODER returned code $RETURN" >> errors
843 for UTRACKNUM
in $TRACKQUEUE
845 run_command encodetrack-
$OUTPUT-$UTRACKNUM true
846 #run_command encodetrack-$UTRACKNUM true
855 if checkerrors
"nogap-encode"; then :; else
856 if [ ! "$KEEPWAVS" = "y" ] ; then
857 if [ ! "$KEEPWAVS" = "move" ] ; then
862 # Other encoders fall through to normal encoding as the tracks
863 # have not been entered in the status file.
866 # do_encode [tracknumber] [hostname]
867 # If no hostname is specified, encode locally
869 # TRACKS, TRACKNAME, TRACKARTIST, DISTMP3, DISTMP3OPTS, {FOO}ENCODERSYNTAX, OUTPUTTYPE, ENCODEROPTS, DALBUM, DARTIST, ENCNICE, CDYEAR, CDGENRE, COMMENT
872 if [ "$USEPIPES" = "y" ]; then
875 TEMPARG
="PIPE_$MP3ENCODERSYNTAX"
878 TEMPARG
="PIPE_$OGGENCODERSYNTAX"
881 TEMPARG
="PIPE_$FLACENCODERSYNTAX"
884 TEMPARG
="PIPE_$SPEEXENCODER"
887 TEMPARG
="PIPE_$MPPENCODER"
890 TEMPARG
="PIPE_$MPPENCODER"
893 IN
="$( eval echo "\$
$TEMPARG" )"
895 IN
="$ABCDETEMPDIR/track$1.wav"
898 case "$MP3ENCODERSYNTAX" in
899 # FIXME # check if mp3enc needs -if for pipes
900 # FIXME # I have not been able to find a working mp3enc binary
914 # We need IN to proceed, if we are not using pipes.
915 if [ -s "$IN" -o X
"$USEPIPES" = "Xy" ] ; then
916 for TMPOUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
920 OUT
="$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER"
921 OUTPUT
=$OGGOUTPUTCONTAINER
924 OUT
="$ABCDETEMPDIR/track$1.$FLACOUTPUTCONTAINER"
925 OUTPUT
=$FLACOUTPUTCONTAINER
928 OUT
="$ABCDETEMPDIR/track$1.$OUTPUT"
932 if [ "$NOGAP" = "y" ] && checkstatus encodetrack-
$OUTPUT-$1 ; then
935 if [ X
"$USEPIPES" = "Xy" ]; then
937 # We need a way to store the creation of the files when using PIPES
938 RUN_COMMAND_PIPES
="run_command encodetrack-$OUTPUT-$1 true"
940 run_command
'' echo "Encoding track $1 of $TRACKS: $TRACKNAME..."
941 RUN_COMMAND
="run_command encodetrack-$OUTPUT-$1"
947 case "$MP3ENCODERSYNTAX" in
948 lame|gogo
) $RUN_COMMAND nice
$ENCNICE $MP3ENCODER $MP3ENCODEROPTS "$IN" "$OUT" ;;
949 bladeenc
) $RUN_COMMAND nice
$ENCNICE $MP3ENCODER $MP3ENCODEROPTS -quit "$IN" ;;
950 l3enc|xingmp3enc
) $RUN_COMMAND nice
$ENCNICE $MP3ENCODER "$IN" "$OUT" $MP3ENCODEROPTS ;;
951 # FIXME # Relates to the previous FIXME since it might need the "-if" removed.
952 mp3enc
) $RUN_COMMAND nice
$ENCNICE $MP3ENCODER -if "$IN" -of "$OUT" $MP3ENCODEROPTS ;;
956 $RUN_COMMAND nice
$DISTMP3NICE $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" >/dev
/null
2>&1
963 case "$OGGENCODERSYNTAX" in
964 vorbize
) $RUN_COMMAND nice
$ENCNICE $OGGENCODER $OGGENCODEROPTS -w "$OUT" "$IN" ;;
965 oggenc
) $RUN_COMMAND nice
$ENCNICE $OGGENCODER $OGGENCODEROPTS -o "$OUT" "$IN" ;;
969 $RUN_COMMAND nice
$DISTMP3NICE $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" >/dev
/null
2>&1
976 case "$FLACENCODERSYNTAX" in
977 flac
) $RUN_COMMAND nice
$ENCNICE $FLACENCODER -f $FLACENCODEROPTS -o "$OUT" "$IN" ;;
982 vecho
"$DISTMP3 $DISTMP3OPTS $2 $IN $OUT >/dev/null 2>&1"
983 $RUN_COMMAND nice
$DISTMP3NICE $DISTMP3 $DISTMP3OPTS "$2" "$IN" "$OUT" > /dev
/null
2>&1
988 if [ "$(eval echo ${COMMENT})" != "" ]; then
991 *) COMMENT
="COMMENT=$COMMENT" ;;
993 COMMENT
="--comment \"$COMMENT\""
995 # Quick hack to avoid tagging Ogg/Speex, since there is no other way to tag than inline tagging
996 if [ ! "$DOTAG" = "y" ]; then
997 $RUN_COMMAND nice
$ENCNICE $SPEEXENCODER $SPEEXENCODEROPTS --author "$TRACKARTIST" --title "$TRACKNAME" "$COMMENT" "$IN" "$OUT"
999 $RUN_COMMAND nice
$ENCNICE $SPEEXENCODER $SPEEXENCODEROPTS "$IN" "$OUT"
1003 # MPP/MP+(Musepack) format (.mpc) is done locally, with inline
1005 # I tried compiling the mppenc from corecodecs.org and got some
1006 # errors, so I have not tried it myself.
1007 ## FIXME ## Needs some cleanup to determine if an empty tag sent
1008 ## FIXME ## to the encoder ends up empty.
1009 $RUN_COMMAND nice
$ENCNICE $MPPENCODER $MPPENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" "$IN" "$OUT"
1012 # Quick hack to avoid tagging Ogg/Speex, since there is no other way to tag than inline tagging
1013 if [ ! "$DOTAG" = "y" ]; then
1014 $RUN_COMMAND nice
$ENCNICE $AACENCODER $AACENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" -o "$OUT" "$IN"
1017 $RUN_COMMAND nice
$ENCNICE $AACENCODER $AACENCODEROPTS -o "$OUT" "$IN"
1021 # In case of wav output we need nothing. Just keep the wavs.
1026 # Only remove .wav if the encoding succeeded
1027 if checkerrors
"encodetrack-(.{3,6})-$1"; then :; else
1028 run_command encodetrack-
$1 true
1029 if [ ! "$KEEPWAVS" = "y" ] ; then
1030 if [ ! "$KEEPWAVS" = "move" ] ; then
1036 run_command
"" echo "HEH! The file we were about to encode disappeared:"
1037 run_command
"" echo ">> $IN"
1038 run_command encodetrack-
$1 false
1042 # do_preprocess [tracknumber]
1044 # TRACKS, TRACKNAME, TRACKARTIST, DISTMP3, DISTMP3OPTS, {FOO}ENCODERSYNTAX, OUTPUTTYPE, ENCODEROPTS, DALBUM, DARTIST, ENCNICE, CDYEAR, CDGENRE, COMMENT
1047 # IN="$ABCDETEMPDIR/track$1.wav"
1048 # # We need IN to proceed.
1049 # if [ -s "$IN" ] ; then
1050 # for OUTPUT in $(echo $OUTPUTTYPE | tr , \ )
1052 # #OUT="$ABCDETEMPDIR/track$1.$OUTPUT"
1053 # run_command '' echo "Pre-processing track $1 of $TRACKS..."
1054 # case "$POSTPROCESSFORMAT" in
1056 # run_command preprocess-$OUTPUT-$1 nice $PRENICE $WAV_PRE $IF $OF ;;
1058 # run_command preprocess-$OUTPUT-$1 nice $PRENICE $MP3_PRE $IF $OF ;;
1060 # run_command preprocess-$OUTPUT-$1 nice $PRENICE $OGG_PRE $IF $OF ;;
1062 # run_command preprocess-$OUTPUT-$1 nice $PRENICE $FLAC_PRE $IF $OF ;;
1064 # run_command preprocess-$OUTPUT-$1 nice $PRENICE $SPX_PRE $IF $OF ;;
1067 # # Only remove .wav if the encoding succeeded
1068 # if checkerrors "preprocess-(.{3,4})-$1"; then
1069 # run_command preprocess-$1 false
1071 # run_command preprocess-$1 true
1074 # if [ "$(checkstatus encode-output)" = "loud" ]; then
1075 # echo "HEH! The file we were about to pre-process disappeared:"
1078 # run_command preprocess-$1 false
1083 # do_postprocess [tracknumber]
1085 # TRACKS, TRACKNAME, TRACKARTIST, DISTMP3, DISTMP3OPTS, {FOO}ENCODERSYNTAX, OUTPUTTYPE, ENCODEROPTS, DALBUM, DARTIST, ENCNICE, CDYEAR, CDGENRE, COMMENT
1088 # for POSTPROCESSFORMAT in $(echo $POSTPROCESSFORMATS | tr , \ )
1090 # IN="$ABCDETEMPDIR/track$1.$POSTPROCESSFORMAT"
1091 # # We need IN to proceed.
1092 # if [ -s "$IN" ] ; then
1093 # #OUT="$ABCDETEMPDIR/track$1.$OUTPUT"
1094 # run_command '' echo "Post-processing track $1 of $TRACKS..."
1095 # case "$POSTPROCESSFORMAT" in
1097 # run_command postprocess-$OUTPUT-$1 nice $POSTNICE $MP3_POST $IF $OF ;;
1099 # run_command postprocess-$OUTPUT-$1 nice $POSTNICE $OGG_POST $IF $OF ;;
1101 # run_command postprocess-$OUTPUT-$1 nice $POSTNICE $FLAC_POST $IF $OF ;;
1103 # run_command postprocess-$OUTPUT-$1 nice $POSTNICE $SPX_POST $IF $OF ;;
1105 # # Only remove .wav if the encoding succeeded
1106 # if checkerrors "postprocess-(.{3,4})-$1"; then
1107 # run_command postprocess-$1 false
1109 # run_command postprocess-$1 true
1112 # if [ "$(checkstatus encode-output)" = "loud" ]; then
1113 # echo "HEH! The file we were about to post-process disappeared:"
1116 # run_command postprocess-$1 false
1131 # MP3GAIN, MP3GAINOPTS, VORBISGAIN, VORBISGAINOPTS, MPPGAIN, MPPGAINOPTS
1135 # The commands here don't go through run_command because they're never supposed to be silenced
1136 echo "Batch analizing gain in tracks: $TRACKQUEUE"
1141 for UTRACKNUM
in $TRACKQUEUE
1143 MP3FILES
="$TRACKFILES track$UTRACKNUM.mp3"
1145 # FIXME # Hard-coded batch option!
1146 $NORMALIZER -b $NORMALIZEROPTS $TRACKFILES
1148 if [ "$RETURN" != "0" ]; then
1149 echo "batch-normalize: $NORMALIZER returned code $RETURN" >> errors
1151 for UTRACKNUM
in $TRACKQUEUE
1153 echo normalizetrack-
$UTRACKNUM >> status
1159 # do_batch_normalize
1161 # NORMALIZER, NORMALIZEROPTS
1162 do_batch_normalize
()
1164 # The commands here don't go through run_command because they're never supposed to be silenced
1165 echo "Batch normalizing tracks: $TRACKQUEUE"
1170 for UTRACKNUM
in $TRACKQUEUE
1172 TRACKFILES
="$TRACKFILES track$UTRACKNUM.wav"
1174 # XXX: Hard-coded batch option!
1175 $NORMALIZER -b $NORMALIZEROPTS $TRACKFILES
1177 if [ "$RETURN" != "0" ]; then
1178 echo "batch-normalize: $NORMALIZER returned code $RETURN" >> errors
1180 for UTRACKNUM
in $TRACKQUEUE
1182 echo normalizetrack-
$UTRACKNUM >> status
1188 # do_normalize [tracknumber]
1190 # TRACKS, TRACKNAME, NORMALIZER, NORMALIZEROPTS
1193 IN
="$ABCDETEMPDIR/track$1.wav"
1194 if [ -e "$IN" ] ; then
1195 run_command
'' echo "Normalizing track $1 of $TRACKS: $TRACKNAME..."
1196 run_command normalizetrack-
$1 $NORMALIZER $NORMALIZEROPTS "$IN"
1198 if [ "$(checkstatus encode-output)" = "loud" ]; then
1199 echo "HEH! The file we were about to normalize disappeared:"
1202 run_command normalizetrack-
$1 false
"File $IN was not found"
1206 # do_move [tracknumber]
1207 # Deduces the outfile from environment variables
1208 # Creates directory if necessary
1210 # TRACKNUM, TRACKNAME, TRACKARTIST, DALBUM, OUTPUTFORMAT, CDGENRE, CDYEAR
1213 for TMPOUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
1215 # For now, set OUTPUT as TMPOUTPUT, and then change it once we have
1216 # defined the OUTPUTFILE:
1219 # Create ALBUMFILE, ARTISTFILE, TRACKFILE
1220 # Munge filenames as follows:
1225 # Eat control characters
1226 ALBUMFILE
="$(mungefilename "$DALBUM")"
1227 ARTISTFILE
="$(mungefilename "$TRACKARTIST")"
1228 TRACKFILE
="$(mungefilename "$TRACKNAME")"
1229 GENRE
="$(mungegenre "$GENRE")"
1230 YEAR
=${CDYEAR:-$CDYEAR}
1231 # If we want to start the tracks with a given number, we need to modify
1232 # the TRACKNUM value before evaluation
1234 # Supported variables for OUTPUTFORMAT are GENRE, YEAR, ALBUMFILE,
1235 # ARTISTFILE, TRACKFILE, and TRACKNUM.
1236 if [ "$VARIOUSARTISTS" = "y" ]; then
1237 OUTPUTFILE
="$(eval echo "$VAOUTPUTFORMAT")"
1239 OUTPUTFILE
="$(eval echo "$OUTPUTFORMAT")"
1241 if checkerrors
"tagtrack-$OUTPUT-$1"; then :; else
1242 # Once we know the specific output was successful, we can change
1243 # the OUTPUT to the value containing the container
1246 OUTPUT
=$OGGOUTPUTCONTAINER
1249 OUTPUT
=$FLACOUTPUTCONTAINER
1255 # Check that the directory for OUTPUTFILE exists, if it doesn't, create it
1256 OUTPUTFILEDIR
="$(dirname "$OUTPUTDIR/$OUTPUTFILE")"
1259 if [ "$DOCLEAN" != "y" ] && [ "$FORCE" != "y" ]; then
1260 # FIXME # introduce warnings?
1263 # mkdir -p shouldn't return an error if the directory already exists
1264 mkdir
-p "$OUTPUTFILEDIR"
1265 run_command movetrack-
$1 mv "$ABCDETEMPDIR/track$1.$OUTPUT" "$OUTPUTDIR/$OUTPUTFILE.$OUTPUT"
1266 if checkstatus movetrack-output-
$OUTPUT; then :; else
1267 run_command movetrack-output-
$OUTPUT true
1272 # mkdir -p shouldn't return an error if the directory already exists
1273 mkdir
-p "$OUTPUTFILEDIR"
1274 run_command movetrack-
$1 mv "$ABCDETEMPDIR/track$1.$OUTPUT" "$OUTPUTDIR/$OUTPUTFILE.$OUTPUT"
1275 if checkstatus movetrack-output-
$OUTPUT; then :; else
1276 run_command movetrack-output-
$OUTPUT true
1280 # Lets move the cue file
1281 if CUEFILE
=$
(checkstatus cuefile
) >/dev
/null
; then
1282 if [ -r "$ABCDETEMPDIR/$CUEFILE" ]; then
1283 if checkstatus movecue-
$OUTPUT; then :; else
1284 # Silence the Copying output since it overlaps with encoding processes...
1285 #run_command '' vecho "Copying cue file to its destination directory..."
1286 if checkstatus onetrack
>/dev
/null
; then
1289 if [ "$DOCLEAN" != "y" ] && [ "$FORCE" != "y" ]; then
1290 # We dont have the dir, since it was not created before.
1293 run_command movecue-
$OUTPUT cp "$ABCDETEMPDIR/$CUEFILE" "$OUTPUTDIR/$OUTPUTFILE.cue"
1296 # NOTE: Creating a cue file with the 3-char-extension files is to comply with
1297 # http://brianvictor.tripod.com/mp3cue.htm#details
1298 [a-z0-9
][a-z0-9
][a-z0-9
])
1299 run_command movecue-
$OUTPUT cp "$ABCDETEMPDIR/$CUEFILE" "$OUTPUTDIR/$OUTPUTFILE.cue"
1302 run_command movecue-
$OUTPUT cp "$ABCDETEMPDIR/$CUEFILE" "$OUTPUTDIR/$OUTPUTFILE.$OUTPUT.cue"
1306 run_command movecue-
$OUTPUT cp "$ABCDETEMPDIR/$CUEFILE" "$OUTPUTFILEDIR/$CUEFILE"
1308 echo movecue-
$OUTPUT >> "$ABCDETEMPDIR/status"
1317 # Create the playlist if wanted
1319 # PLAYLISTFORMAT, PLAYLISTDATAPREFIX, VAPLAYLISTFORMAT, VAPLAYLISTDATAPREFIX,
1320 # VARIOUSARTISTS, OUTPUTDIR
1323 for TMPOUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
1327 OUTPUT
=$OGGOUTPUTCONTAINER
1330 OUTPUT
=$FLACOUTPUTCONTAINER
1336 # Create a playlist file for the playlist data to go into.
1337 # We used to wipe it out if it existed. Now we request permision if interactive.
1338 for LASTTRACK
in $TRACKQUEUE; do :; done
1339 ALBUMFILE
="$(mungefilename "$DALBUM")"
1340 ARTISTFILE
="$(mungefilename "$DARTIST")"
1341 GENRE
="$(mungegenre "$GENRE")"
1342 YEAR
=${CDYEAR:-$CDYEAR}
1343 if [ "$VARIOUSARTISTS" = "y" ] ; then
1344 PLAYLISTFILE
="$(eval echo "$VAPLAYLISTFORMAT")"
1346 PLAYLISTFILE
="$(eval echo "$PLAYLISTFORMAT")"
1348 FINALPLAYLISTDIR
="$(dirname "$OUTPUTDIR/$PLAYLISTFILE")"
1349 mkdir
-p "$FINALPLAYLISTDIR"
1350 if [ -s "$OUTPUTDIR/$PLAYLISTFILE" ]; then
1351 echo -n "Erase, Append to, or Keep the existing playlist file? [e/a/k] (e): " >&2
1352 if [ "$INTERACTIVE" = "y" ]; then
1353 while [ "$DONE" != "y" ]; do
1355 case $ERASEPLAYLIST in
1356 e|E|a|A|k|K
) DONE
=y
;;
1364 # Once we erase the playlist, we use append to create the new one.
1365 [ "$ERASEPLAYLIST" = "e" -o "$ERASEPLAYLIST" = "E" ] && rm -f "$OUTPUTDIR/$PLAYLISTFILE" && ERASEPLAYLIST
=a
1367 # The playlist does not exist, so we can safelly use append to create the new list
1370 if [ "$ERASEPLAYLIST" = "a" -o "$ERASEPLAYLIST" = "A" ]; then
1371 touch "$OUTPUTDIR/$PLAYLISTFILE"
1372 for UTRACKNUM
in $TRACKQUEUE
1374 # Shares some code with do_move since the filenames have to match
1375 CDDBTRACKNUM
=$
(expr $UTRACKNUM - 1)
1376 getcddbinfo TRACKNAME
1378 TRACKFILE
="$(mungefilename "$TRACKNAME")"
1379 ARTISTFILE
="$(mungefilename "$TRACKARTIST")"
1380 ALBUMFILE
="$(mungefilename "$DALBUM")"
1381 # If we want to start the tracks with a given number, we need to modify the
1382 # TRACKNUM value before evaluation
1384 if [ "$VARIOUSARTISTS" = "y" ]; then
1385 OUTPUTFILE
="$(eval echo "$VAOUTPUTFORMAT")"
1387 OUTPUTFILE
="$(eval echo "$OUTPUTFORMAT")"
1389 if [ "$VARIOUSARTISTS" = "y" ]; then
1390 if [ "$VAPLAYLISTDATAPREFIX" ] ; then
1391 echo ${VAPLAYLISTDATAPREFIX}$OUTPUTFILE.
$OUTPUT >> "$OUTPUTDIR/$PLAYLISTFILE"
1393 relpath
"$PLAYLISTFILE", "$OUTPUTFILE.$OUTPUT" >> "$OUTPUTDIR/$PLAYLISTFILE"
1396 if [ "$PLAYLISTDATAPREFIX" ]; then
1397 echo ${PLAYLISTDATAPREFIX}$OUTPUTFILE.
$OUTPUT >> "$OUTPUTDIR/$PLAYLISTFILE"
1399 relpath
"$PLAYLISTFILE", "$OUTPUTFILE.$OUTPUT" >> "$OUTPUTDIR/$PLAYLISTFILE"
1404 ## this will convert the playlist to have CRLF line-endings, if specified
1405 ## (some hardware players insist on CRLF endings)
1406 if [ "$DOSPLAYLIST" = "y" ]; then
1407 awk '{substr("\r",""); printf "%s\r\n", $0}' "$OUTPUTDIR/$PLAYLISTFILE" > "$ABCDETEMPDIR/PLAYLISTFILE.tmp"
1408 # mv -f "$ABCDETEMPDIR/PLAYLISTFILE.tmp" "$OUTPUTDIR/$PLAYLISTFILE"
1409 cat "$ABCDETEMPDIR/PLAYLISTFILE.tmp" |
sed 's/\//\\/' > "$OUTPUTDIR/$PLAYLISTFILE"
1411 echo "playlistcomplete" >> "$ABCDETEMPDIR/status"
1416 # This essentially the start of things
1419 # Query the CD to get the track info, unless the user specified -C
1420 # or we are using some actions which do not need the CDDB data at all
1421 #if [ ! X"$EXPACTIONS" = "X" ]; then
1423 #elif [ -z "$DISCID" ]; then
1424 if [ -z "$DISCID" ]; then
1425 vecho
-n "Getting CD track info... "
1426 # In OSX, unmount the disc before a query
1427 if [ "$OSFLAVOUR" = "OSX" ]; then
1428 disktool
-u ${CDROM#/dev/}
1430 if [ "$CDROMREADERSYNTAX" = "flac" ] ; then
1431 if $METAFLAC $METAFLACOPTS --export-cuesheet-to=- $CDROM > /dev
/null
2>&1 ; then
1432 TRACKINFO
=$
($METAFLAC $METAFLACOPTS --export-cuesheet-to=- $CDROM |
$CUE2DISCID)
1434 log error
"the input flac file does not contain a cuesheet."
1438 case "$CDDBMETHOD" in
1439 cddb
) TRACKINFO
=$
($CDDISCID $CDROM) ;;
1440 # FIXME # musicbrainz needs a cleanup
1441 musicbrainz
) TRACKINFO
=$
($MUSICBRAINZ -c $CDROM ) ;;
1444 # Make sure there's a CD in there by checking cd-discid's return code
1445 if [ ! "$?" = "0" ]; then
1446 if [ "$CDROMREADERSYNTAX" = "flac" ] ; then
1447 log error
"cuesheet information from the flac file could not be read."
1448 log error
"Perhaps the flac file does not contain a cuesheet?."
1451 log error
"CD could not be read. Perhaps there's no CD in the drive?"
1455 # In OSX, remount the disc again
1456 if [ "$OSFLAVOUR" = "OSX" ]; then
1457 disktool
-m ${CDROM#/dev/}
1460 DISCID
=$
(echo $TRACKINFO | cut
-f1 -d' ')
1462 TRACKINFO
=$
(cat "$WAVOUTPUTDIR/abcde.$DISCID/discid")
1465 # Get a full enumeration of tracks, sort it, and put it in the TRACKQUEUE.
1466 # This needs to be done now because a section of the resuming code will need
1469 # get the number of digits to pad TRACKNUM with - we'll use this later
1470 # a CD can only hold 99 tracks, but since we support a feature for starting
1471 # numbering the tracks from a given number, we might need to set it as a
1472 # variable for the user to define... or obtain it somehow.
1473 if [ "$PADTRACKS" = "y" ] ; then
1477 ABCDETEMPDIR
="$WAVOUTPUTDIR/abcde.$(echo $TRACKINFO | cut -f1 -d' ')"
1478 if [ -z "$TRACKQUEUE" ]; then
1479 if [ ! "$STRIPDATATRACKS" = "y" ]; then
1480 case "$CDROMREADERSYNTAX" in
1482 if [ "$WEHAVEACD" = "y" ]; then
1483 vecho
"Querying the CD for audio tracks..."
1484 CDPARANOIAOUTPUT
="$( $CDROMREADER -$CDPARANOIACDROMBUS $CDROM -Q --verbose 2>&1 )"
1486 if [ ! "$RET" = "0" ];then
1487 log warning
"something went wrong while querying the CD... Maybe a DATA CD?"
1489 TRACKS
="$(echo "$CDPARANOIAOUTPUT" | egrep '^[[:space:]]+[[:digit:]]' | tail -n 1 | get_first | tr -d ".
" | tr '\n' ' ')"
1490 CDPARANOIAAUDIOTRACKS
="$TRACKS"
1492 # Previous versions of abcde would store the tracks on a file, instead of the status record.
1493 if [ -f "$ABCDETEMPDIR/cdparanoia-audio-tracks" ]; then
1494 echo cdparanoia-audio-tracks
=$
( cat "$ABCDETEMPDIR/cdparanoia-audio-tracks" ) >> "$ABCDETEMPDIR/status"
1495 rm -f "$ABCDETEMPDIR/cdparanoia-audio-tracks"
1497 if [ -f "$ABCDETEMPDIR/status" ] && TRACKS
=$
(checkstatus cdparanoia-audio-tracks
); then :; else
1498 TRACKS
=$
(echo $TRACKINFO | cut
-f2 -d' ')
1502 *) TRACKS
=$
(echo $TRACKINFO | cut
-f2 -d' ') ;;
1505 TRACKS
=$
(echo $TRACKINFO | cut
-f2 -d' ')
1507 if echo "$TRACKS" |
grep "[[:digit:]]" > /dev
/null
2>&1 ;then :;else
1508 log info
"The disc does not contain any tracks. Giving up..."
1511 echo -n "Grabbing entire CD - tracks: "
1512 if [ ! "$PADTRACKS" = "y" ] ; then
1513 TRACKNUMPADDING
=$
(echo -n $TRACKS |
wc -c |
tr -d ' ')
1515 TRACKS
=$
(printf "%0.${TRACKNUMPADDING}d" $TRACKS)
1517 while [ "$X" -ne "$TRACKS" ]
1519 X
=$
(printf "%0.${TRACKNUMPADDING}d" $
(expr $X + 1))
1520 TRACKQUEUE
=$
(echo $TRACKQUEUE $X)
1524 TRACKS
=$
(echo $TRACKINFO | cut
-f2 -d' ')
1525 # User-supplied track queue.
1526 # Weed out non-numbers, whitespace, then sort and weed out duplicates
1527 TRACKQUEUE
=$
(echo $TRACKQUEUE |
sed 's-[^0-9 ]--g' |
tr ' ' '\n' |
grep -v ^$ |
sort -n |
uniq |
tr '\n' ' ' |
sed 's- $--g')
1528 # Once cleaned, obtain the highest value in the trackqueue for number padding
1529 for LASTTRACK
in $TRACKQUEUE; do :; done
1530 if [ ! "$PADTRACKS" = "y" ] ; then
1531 TRACKNUMPADDING
=$
(echo -n $LASTTRACK |
wc -c |
tr -d ' ')
1533 # Now we normalize the trackqueue
1534 for TRACK
in $TRACKQUEUE ; do
1535 TRACKNUM
=$
(printf %0.
${TRACKNUMPADDING}d $
(expr ${TRACK} + 0 ))
1536 PADTRACKQUEUE
=$
(echo $PADTRACKQUEUE $TRACKNUM)
1538 TRACKQUEUE
=$PADTRACKQUEUE
1539 echo Grabbing tracks
: "$TRACKQUEUE"
1542 QUEUEDTRACKS
=$
(echo $TRACKQUEUE |
wc -w |
tr -d ' ')
1544 # We have the discid, create a temp directory after it to store all the temp
1547 if [ -e "$ABCDETEMPDIR" ]; then
1548 echo -n "abcde: attempting to resume from $ABCDETEMPDIR"
1549 # It already exists, see if it's a directory
1550 if [ ! -d "$ABCDETEMPDIR" ]; then
1551 # This is a file/socket/fifo/device/etc, not a directory
1554 echo "abcde: file $ABCDETEMPDIR already exists and does not belong to abcde." >&2
1555 echo "Please investigate, remove it, and rerun abcde." >&2
1559 # It's a directory, let's see if it's owned by us
1560 if [ ! -O "$ABCDETEMPDIR" ]; then
1561 # Nope, complain and exit
1563 echo "abcde: directory $ABCDETEMPDIR already exists and is not owned by you." >&2
1564 echo "Please investigate, remove it, and rerun abcde." >&2
1568 # See if it's populated
1569 if [ ! -f "$ABCDETEMPDIR/discid" ]; then
1570 # Wipe and start fresh
1571 echo "abcde: $ABCDETEMPDIR/discid not found. Abcde must remove and recreate" >&2
1572 echo -n "this directory to continue. Continue? [y/n] (n)" >&2
1573 if [ "$INTERACTIVE" = "y" ]; then
1579 if [ "$ANSWER" != "y" ]; then
1582 rm -rf "$ABCDETEMPDIR" ||
exit 1
1583 mkdir
-p "$ABCDETEMPDIR"
1584 if [ "$?" -gt "0" ]; then
1585 # Directory already exists or could not be created
1586 echo "abcde: Temp directory $ABCDETEMPDIR could not be created." >&2
1590 # Everything is fine. Check for ^encodetracklocation-
1591 # and encode-output entries in the status file and
1592 # remove them. These are not relevant across sessions.
1593 if [ -f "$ABCDETEMPDIR/status" ]; then
1594 mv "$ABCDETEMPDIR/status" "$ABCDETEMPDIR/status.old"
1595 grep -v ^encodetracklocation-
< "$ABCDETEMPDIR/status.old" \
1596 |
grep -v ^encode-output
> "$ABCDETEMPDIR/status"
1598 # Remove old error messages
1599 if [ -f "$ABCDETEMPDIR/errors" ]; then
1600 rm -f "$ABCDETEMPDIR/errors"
1604 # We are starting from scratch
1605 mkdir
-p "$ABCDETEMPDIR"
1606 if [ "$?" -gt "0" ]; then
1607 # Directory already exists or could not be created
1608 echo "abcde: Temp directory $ABCDETEMPDIR could not be created." >&2
1611 cat /dev
/null
> "$ABCDETEMPDIR/status"
1612 # Store the abcde version in the status file.
1613 echo "abcde-version=$VERSION" >> "$ABCDETEMPDIR/status"
1615 if [ X
"$MAKECUEFILE" = "Xy" -a X
"$WEHAVEACD" = "Xy" ]; then
1616 if checkstatus cuefile
> /dev
/null
2>&1 ; then :; else
1617 CUEFILE
=cue-$
(echo "$TRACKINFO" | cut
-f1 -d' ').txt
1618 vecho
"Creating cue file..."
1619 case $CDROMREADERSYNTAX in
1621 if $METAFLAC --export-cuesheet-to=- $CDROM > "$ABCDETEMPDIR/$CUEFILE"; then :; else
1622 log warning
"the input flac file does not contain a cuesheet."
1626 if $CUEREADER $CUEREADEROPTS > "$ABCDETEMPDIR/$CUEFILE"; then
1627 echo cuefile
=$CUEFILE >> "$ABCDETEMPDIR/status"
1629 log warning
"reading the CUE sheet with mkcue is still considered experimental"
1630 log warning
"and there was a problem with the CD reading. abcde will continue,"
1631 log warning
"but consider reporting the problem to the abcde author"
1637 # If we got the CDPARANOIA status and it is not recorded, save it now
1638 if [ -n "$CDPARANOIAAUDIOTRACKS" ]; then
1639 if checkstatus cdparanoia-audio-tracks
> /dev
/null
2>&1; then :; else
1640 echo cdparanoia-audio-tracks
=$CDPARANOIAAUDIOTRACKS >> "$ABCDETEMPDIR/status"
1644 # Create the discid file
1645 echo "$TRACKINFO" > "$ABCDETEMPDIR/discid"
1646 if checkstatus cddbmethod
> /dev
/null
2>&1 ; then :; else
1647 echo "cddbmethod=$CDDBMETHOD" >> "$ABCDETEMPDIR/status"
1652 # Create a proper CUE file based on the CUE file we created before.
1655 if CUEFILE_IN
="$ABCDETEMPDIR"/$
(checkstatus cuefile
); then
1656 CUEFILE_OUT
=$CUEFILE_IN.out
1657 ### FIXME ### checkstatus cddb
1658 if [ -e "$CDDBDATA" ]; then
1659 vecho
"Adding metadata to the cue file..."
1660 # FIXME It doesn't preserve spaces! Why?
1661 # FIXME parse $track into PERFORMER and TITLE - abcde already has code for this?
1663 echo "PERFORMER \"$DARTIST\"" >> "$CUEFILE_OUT"
1664 echo "TITLE \"$DALBUM\"" >> "$CUEFILE_OUT"
1665 cat "$CUEFILE_IN" |
while read line
1667 if echo "$line" |
grep "INDEX" > /dev
/null
2>&1 ; then
1668 eval track
="\$TRACK$n"
1670 echo "TITLE \"$track\"" >> "$CUEFILE_OUT"
1672 echo "$line" >> "$CUEFILE_OUT"
1674 mv "$CUEFILE_OUT" "$CUEFILE_IN"
1675 echo "cleancuefile" >> "$ABCDETEMPDIR/status"
1681 # Parses a CDDB file and outputs the title and the track names.
1682 # Variables: CDDBFILE
1686 # List out disc title/author and contents
1687 if [ "$ONETRACK" = "y" ]; then
1688 vecho
"ONETRACK mode selected: displaying only the title of the CD..."
1690 echo "---- $(grep DTITLE "${CDDBPARSEFILE}" | cut '-d=' -f2- | tr -d \\r\\n ) ----"
1691 if [ X
"$SHOWCDDBYEAR" = "Xy" ]; then
1692 PARSEDYEAR
=$
(grep DYEAR
"${CDDBPARSEFILE}" | cut
'-d=' -f2-)
1693 if [ ! X
"$PARSEDYEAR" = "X" ]; then
1694 echo "Year: $PARSEDYEAR"
1697 if [ X
"$SHOWCDDBGENRE" = "Xy" ]; then
1698 PARSEDGENRE
=$
(grep DGENRE
"${CDDBPARSEFILE}" | cut
'-d=' -f2-)
1699 if [ ! X
"$PARSEDGENRE" = "X" ]; then
1700 echo "Genre: $PARSEDGENRE"
1703 if [ ! "$ONETRACK" = "y" ]; then
1704 for TRACK
in $
(f_seq_row
1 $TRACKS)
1706 echo $TRACK: "$(grep ^TTITLE$(expr $TRACK - 1)= "${CDDBPARSEFILE}" | cut -f2- -d= | tr -d \\r\\n)"
1712 # Check for a local CDDB file, and report success
1715 if checkstatus cddb-readcomplete
&& checkstatus cddb-choice
>/dev
/null
; then :; else
1717 CDDBLOCALSTATUS
="notfound"
1718 CDDBDISCID
=$
(echo $TRACKINFO | cut
-d' ' -f1)
1721 if [ "$CDDBLOCALRECURSIVE" = "y" ]; then
1722 CDDBLOCALRESULTS
="$(find ${CDDBLOCALDIR} -name "${CDDBDISCID}" -type f 2> /dev/null)"
1723 if [ ! "${CDDBLOCALRESULTS}" = "" ]; then
1724 if (( $
(echo "${CDDBLOCALRESULTS}" |
wc -l) == 1 )); then
1725 CDDBLOCALFILE
="${CDDBLOCALRESULTS}"
1726 CDDBLOCALMATCH
=single
1727 elif (( $
(echo "${CDDBLOCALRESULTS}" |
wc -l) > 1 )); then
1728 CDDBLOCALMATCH
=multiple
1733 elif [ "$CDDBLOCALMATCH" = "none" ] && [ -r "${CDDBLOCALDIR}/${CDDBDISCID}" ]; then
1734 CDDBLOCALFILE
="${CDDBLOCALDIR}/${CDDBDISCID}"
1735 CDDBLOCALMATCH
=single
1740 # If the user has selected to check a local CDDB repo, we proceed with it
1741 case $CDDBLOCALMATCH in
1743 echo "Processing multiple matching CDDB entries..." > "$ABCDETEMPDIR/cddblocalchoices"
1745 echo "$CDDBLOCALRESULTS" |
while read RESULT
; do
1747 # List out disc title/author and contents
1748 CDDBLOCALREAD
="$ABCDETEMPDIR/cddblocalread.$X"
1749 cat "$RESULT" > "${CDDBLOCALREAD}"
1752 do_cddbparse
"${CDDBLOCALREAD}"
1754 } >> "$ABCDETEMPDIR/cddblocalchoices"
1756 if [ $
(cat "$ABCDETEMPDIR/cddblocalchoices" |
wc -l) -ge 24 ]; then
1757 page
"$ABCDETEMPDIR/cddblocalchoices"
1759 # It's all going to fit in one page, cat it
1760 cat "$ABCDETEMPDIR/cddblocalchoices" >&2
1762 CDDBLOCALCHOICES
=$
( echo "$CDDBLOCALRESULTS" |
wc -l )
1763 # Setting the choice to an impossible integer to avoid errors in the numeric comparisons
1764 CDDBLOCALCHOICENUM
=-1
1765 if [ "$INTERACTIVE" = "y" ]; then
1766 while [ $CDDBLOCALCHOICENUM -lt 0 ] ||
[ $CDDBLOCALCHOICENUM -gt $CDDBLOCALCHOICES ]; do
1767 echo -n "Locally cached CDDB entries found. Which one would you like to use (0 for none)? [0-$CDDBLOCALCHOICES]: " >&2
1768 read CDDBLOCALCHOICE
1769 [ x
"$CDDBLOCALCHOICE" = "x" ] && CDDBLOCALCHOICE
="1"
1770 # FIXME # Introduce diff's
1771 if echo $CDDBLOCALCHOICE |
egrep "[[:space:]]*[[:digit:]]+,[[:digit:]]+[[:space:]]*" > /dev
/null
2>&1 ; then
1772 diffentries cddblocalread
"$CDDBLOCALCHOICES" "$CDDBLOCALCHOICE"
1773 elif echo $CDDBLOCALCHOICE |
egrep "[[:space:]]*[[:digit:]]+[[:space:]]*" > /dev
/null
2>&1 ; then
1774 # Make sure we get a valid choice
1775 CDDBLOCALCHOICENUM
=$
(echo $CDDBLOCALCHOICE |
xargs printf %d
2>/dev
/null
)
1776 if [ $CDDBLOCALCHOICENUM -lt 0 ] ||
[ $CDDBLOCALCHOICENUM -gt $CDDBLOCALCHOICES ]; then
1777 echo "Invalid selection. Please choose a number between 0 and $CDDBLOCALCHOICES." >&2
1786 if [ ! "$CDDBLOCALCHOICENUM" = "0" ]; then
1787 #echo "Using local copy of CDDB data"
1788 echo "# DO NOT ERASE THIS LINE! Added by abcde to imitate cddb output" > "$ABCDETEMPDIR/cddbread.1"
1789 cat "$ABCDETEMPDIR/cddblocalread.$CDDBLOCALCHOICENUM" >> "$ABCDETEMPDIR/cddbread.1"
1790 echo 999 > "$ABCDETEMPDIR/cddbquery" # Assuming 999 isn't used by CDDB
1791 echo cddb-readcomplete
>> "$ABCDETEMPDIR/status"
1792 do_cddbparse
"$ABCDETEMPDIR/cddbread.1" > "$ABCDETEMPDIR/cddbchoices"
1793 echo cddb-choice
=1 >> "$ABCDETEMPDIR/status"
1794 CDDBLOCALSTATUS
="found"
1796 #echo "Not using local copy of CDDB data"
1797 CDDBLOCALSTATUS
="notfound"
1801 # List out disc title/author and contents
1802 do_cddbparse
"${CDDBLOCALFILE}"
1803 if [ "$CDROMREADERSYNTAX" = "flac" ] ; then
1804 echo -n "Embedded cuesheet entry found, use it? [y/n] (y): " >&2
1806 echo -n "Locally cached CDDB entry found, use it? [y/n] (y): " >&2
1808 if [ "$INTERACTIVE" = "y" ]; then
1810 while [ "$USELOCALRESP" != "y" ] && [ "$USELOCALRESP" != "n" ] && [ "$USELOCALRESP" != "" ] ; do
1811 echo -n 'Invalid selection. Please answer "y" or "n": ' >&2
1814 [ x
"$USELOCALRESP" = "x" ] && USELOCALRESP
="y"
1818 if [ "$USELOCALRESP" = "y" ]; then
1819 #echo "Using local copy of CDDB data"
1820 echo "# DO NOT ERASE THIS LINE! Added by abcde to imitate cddb output" > "$ABCDETEMPDIR/cddbread.1"
1821 cat "${CDDBLOCALFILE}" >> "$ABCDETEMPDIR/cddbread.1"
1822 echo 999 > "$ABCDETEMPDIR/cddbquery" # Assuming 999 isn't used by CDDB
1823 echo cddb-readcomplete
>> "$ABCDETEMPDIR/status"
1824 do_cddbparse
"${CDDBLOCALFILE}" > "$ABCDETEMPDIR/cddbchoices"
1825 echo cddb-choice
=1 >> "$ABCDETEMPDIR/status"
1826 CDDBLOCALSTATUS
="single"
1828 #echo "Not using local copy of CDDB data"
1829 CDDBLOCALSTATUS
="notfound"
1833 CDDBLOCALSTATUS
="notfound"
1839 do_musicbrainzstat
()
1852 # Perform CDDB protocol version check if it hasn't already been done
1853 if checkstatus cddb-statcomplete
; then :; else
1854 if [ "$CDDBAVAIL" = "n" ]; then
1856 echo 503 > "$ABCDETEMPDIR/cddbstat"
1859 CDDBUSER
=$
(echo $HELLOINFO | cut
-f1 -d'@')
1860 CDDBHOST
=$
(echo $HELLOINFO | cut
-f2- -d'@')
1861 while test $rc -eq 1 -a $CDDBPROTO -ge 3; do
1862 vecho
"Checking CDDB server status..."
1863 $CDDBTOOL stat
$CDDBURL $CDDBUSER $CDDBHOST $CDDBPROTO > "$ABCDETEMPDIR/cddbstat"
1864 RESPONSECODE
=$
(head -n 1 "$ABCDETEMPDIR/cddbstat" | cut
-f1 -d' ')
1865 case "$RESPONSECODE" in
1866 210) # 210 OK, status information follows (until terminating `.')
1869 501|
*) # 501 Illegal CDDB protocol level: <n>.
1870 CDDBPROTO
=`expr $CDDBPROTO - 1`
1874 if test $rc -eq 1; then
1878 echo cddb-statcomplete
>> "$ABCDETEMPDIR/status"
1886 CDDBDISCID
=$
(echo $TRACKINFO | cut
-d' ' -f1)
1887 CDDBLOCALFILE
="${CDDBLOCALDIR}/${CDDBDISCID}"
1889 # Perform CDDB query if it hasn't already been done
1890 if checkstatus cddb-querycomplete
; then :; else
1891 if [ "$CDDBAVAIL" = "n" ]; then
1893 echo 503 > "$ABCDETEMPDIR/cddbquery"
1894 # The default CDDBLOCALSTATUS is "notfound"
1895 # This part will be triggered if the user CDDB repo does not
1896 # contain the entry, or if we are not trying to use the repo.
1898 vecho
"Querying the CDDB server..."
1899 CDDBUSER
=$
(echo $HELLOINFO | cut
-f1 -d'@')
1900 CDDBHOST
=$
(echo $HELLOINFO | cut
-f2- -d'@')
1901 $CDDBTOOL query
$CDDBURL $CDDBPROTO $CDDBUSER $CDDBHOST $TRACKINFO > "$ABCDETEMPDIR/cddbquery"
1907 # no match found in database,
1908 # wget/fetch error, or user requested not to use CDDB
1909 # Make up an error code (503) that abcde
1910 # will recognize in do_cddbread
1911 # and compensate by making a template
1912 echo 503 > "$ABCDETEMPDIR/cddbquery"
1914 *) # strange and unknown error
1915 echo ERRORCODE
=$ERRORCODE
1916 echo "abcde: $CDDBTOOL returned unknown error code"
1920 echo cddb-querycomplete
>> "$ABCDETEMPDIR/status"
1927 # If it's not to be used, generate a template.
1928 # Then, display it (or them) and let the user choose/edit it
1929 if checkstatus cddb-readcomplete
; then :; else
1930 vecho
"Obtaining CDDB results..."
1931 # If CDDB is to be used, interpret the query results and read all
1932 # the available entries.
1933 rm -f "$ABCDETEMPDIR/cddbchoices"
1934 CDDBCHOICES
=1 # Overridden by multiple matches
1935 RESPONSECODE
=$
(head -n 1 "$ABCDETEMPDIR/cddbquery" | cut
-f1 -d' ')
1936 case "$RESPONSECODE" in
1938 # One exact match, retrieve it
1939 # 200 [section] [discid] [artist] / [title]
1940 if checkstatus cddb-read-1-complete
; then :; else
1941 echo -n "Retrieving 1 CDDB match..." >> "$ABCDETEMPDIR/cddbchoices"
1942 $CDDBTOOL read $CDDBURL $CDDBPROTO $CDDBUSER $CDDBHOST $
(cut
-f2,3 -d' ' "$ABCDETEMPDIR/cddbquery") > "$ABCDETEMPDIR/cddbread.1"
1943 echo "done." >> "$ABCDETEMPDIR/cddbchoices"
1944 echo cddb-read-1-complete
>> "$ABCDETEMPDIR/status"
1945 echo cddb-choice
=1 >> "$ABCDETEMPDIR/status"
1947 # List out disc title/author and contents
1948 echo ---- "$(cut '-d ' -f4- "$ABCDETEMPDIR/cddbquery
")" ---- >> "$ABCDETEMPDIR/cddbchoices"
1949 for TRACK
in $
(f_seq_row
1 $TRACKS)
1951 echo $TRACK: "$(grep ^TTITLE$(expr $TRACK - 1)= "$ABCDETEMPDIR/cddbread
.1" | cut -f2- -d= | tr -d \\r\\n)" >> "$ABCDETEMPDIR/cddbchoices"
1953 echo >> "$ABCDETEMPDIR/cddbchoices"
1957 case "$RESPONSECODE" in
1958 202) echo "No CDDB match." >> "$ABCDETEMPDIR/cddbchoices" ;;
1959 403|
409) echo "CDDB entry is corrupt, or the handshake failed." >> "$ABCDETEMPDIR/cddbchoices" ;;
1960 503) echo "CDDB unavailable." >> "$ABCDETEMPDIR/cddbchoices" ;;
1962 $CDDBTOOL template $
(cat "$ABCDETEMPDIR/discid") > "$ABCDETEMPDIR/cddbread.0"
1963 # List out disc title/author and contents of template
1964 echo ---- Unknown Artist
/ Unknown Album
---- >> "$ABCDETEMPDIR/cddbchoices"
1966 for TRACK
in $
(f_seq_row
1 $TRACKS)
1968 echo $TRACK: "$(grep ^TTITLE$(expr $TRACK - 1)= "$ABCDETEMPDIR/cddbread
.0" | cut -f2- -d= | tr -d \\r\\n)" >> "$ABCDETEMPDIR/cddbchoices"
1970 echo >> "$ABCDETEMPDIR/cddbchoices"
1971 echo cddb-read-0-complete
>> "$ABCDETEMPDIR/status"
1972 echo cddb-choice
=0 >> "$ABCDETEMPDIR/status"
1975 # Multiple exact, (possibly multiple) inexact matches
1977 if [ "$RESPONSECODE" = "211" ]; then IN
=in; fi
1978 if [ "$(wc -l < "$ABCDETEMPDIR/cddbquery
" | tr -d ' ')" -eq 3 ]; then
1979 echo "One ${IN}exact match:" >> "$ABCDETEMPDIR/cddbchoices"
1980 tail -n +2 "$ABCDETEMPDIR/cddbquery" |
head -n 1 >> "$ABCDETEMPDIR/cddbchoices"
1981 echo cddb-choice
=1 >> "$ABCDETEMPDIR/status"
1983 echo "Multiple ${IN}exact matches:" >> "$ABCDETEMPDIR/cddbchoices"
1985 vecho
-n "Retrieving multiple matches... "
1986 grep -v ^
[.
]$
"$ABCDETEMPDIR/cddbquery" |
( X
=0
1987 read DISCINFO
# eat top line
1991 if checkstatus cddb-read-
$X-complete; then :; else
1992 $CDDBTOOL read $CDDBURL $CDDBPROTO $CDDBUSER $CDDBHOST $
(echo $DISCINFO | cut
-f1,2 -d' ') > "$ABCDETEMPDIR/cddbread.$X"
1993 echo cddb-read-
$X-complete >> "$ABCDETEMPDIR/status"
1995 # List out disc title/author and contents
1996 echo \
#$X: ---- "$DISCINFO" ---- >> "$ABCDETEMPDIR/cddbchoices"
1997 for TRACK
in $
(f_seq_row
1 $TRACKS)
1999 echo $TRACK: "$(grep ^TTITLE$(expr $TRACK - 1)= "$ABCDETEMPDIR/cddbread.
$X" | cut -f2- -d= | tr -d \\r\\n)" >> "$ABCDETEMPDIR/cddbchoices"
2001 echo >> "$ABCDETEMPDIR/cddbchoices"
2004 CDDBCHOICES
=$
(expr $
(cat "$ABCDETEMPDIR/cddbquery" |
wc -l) - 2)
2008 for TRACK
in $
(f_seq_row
1 $TRACKS)
2010 echo $TRACK: "$(grep ^TTITLE$(expr $TRACK - 1)= "$ABCDETEMPDIR/cddbread
.1" | cut -f2- -d= | tr -d \\r\\n)" >> "$ABCDETEMPDIR/cddbchoices"
2012 echo >> "$ABCDETEMPDIR/cddbchoices"
2013 echo cddb-read-1-complete
>> "$ABCDETEMPDIR/status"
2014 echo cddb-choice
=1 >> "$ABCDETEMPDIR/status"
2017 echo "cddb-readcomplete" >> "$ABCDETEMPDIR/status"
2024 if checkstatus cddb-edit
>/dev
/null
; then
2025 CDDBDATA
="$ABCDETEMPDIR/cddbread.$(checkstatus cddb-choice)"
2026 VARIOUSARTISTS
="$(checkstatus variousartists)"
2027 VARIOUSARTISTSTYLE
="$(checkstatus variousartiststyle)"
2030 if [ "$INTERACTIVE" = "y" ]; then
2031 # We should show the CDDB results both when we are not using the local CDDB repo
2032 # or when we are using it but we could not find a proper match
2033 if [ "$CDDBUSELOCAL" = "y" ] && [ "$CDDBLOCALSTATUS" = "notfound" ] ||
[ ! "$CDDBUSELOCAL" = "y" ]; then
2034 # Display the $ABCDETEMPDIR/cddbchoices file created above
2035 # Pick a pager so that if the tracks overflow the screen the user can still view everything
2036 if [ -r "$ABCDETEMPDIR/cddbchoices" ]; then
2037 CDDBCHOICES
=$
(expr $
(cat "$ABCDETEMPDIR/cddbquery" |
wc -l) - 2)
2038 CHOICE
=$
(checkstatus cddb-choice
)
2039 if [ -n "$CHOICE" ] ; then
2040 case $CDDBCHOICES in
2041 -1) if head -1 "$ABCDETEMPDIR/cddbquery" |
grep "^$" > /dev
/null
2>&1 ; then
2042 log error
"CDDB query failed!"
2045 cat "$ABCDETEMPDIR/cddbchoices"
2048 1) cat "$ABCDETEMPDIR/cddbchoices" ;;
2050 echo "Selected: #$CHOICE"
2051 do_cddbparse
"$ABCDETEMPDIR/cddbread.$CHOICE"
2055 # The user has a choice to make, display the info in a pager if necessary
2056 if [ $
(cat "$ABCDETEMPDIR/cddbchoices" |
wc -l) -ge 24 ]; then
2057 page
"$ABCDETEMPDIR/cddbchoices"
2059 # It's all going to fit in one page, cat it
2060 cat "$ABCDETEMPDIR/cddbchoices" >&2
2064 # Setting the choice to an impossible integer to avoid errors in the numeric comparisons
2066 # I'll take CDDB read #3 for $400, Alex
2067 while [ $CDCHOICENUM -lt 0 ] ||
[ $CDCHOICENUM -gt $CDDBCHOICES ]; do
2068 echo -n "Which entry would you like abcde to use (0 for none)? [0-$CDDBCHOICES]: " >&2
2070 [ X
"$CDDBCHOICE" = "X" ] && CDDBCHOICE
=1
2071 if echo $CDDBCHOICE |
egrep "[[:space:]]*[[:digit:]]+,[[:digit:]]+[[:space:]]*" > /dev
/null
2>&1 ; then
2072 if [ ! X
"$DIFF" = "X" ]; then
2073 PARSECHOICE1
=$
(echo $CDDBCHOICE | cut
-d"," -f1 |
xargs printf %d
2>/dev
/null
)
2074 PARSECHOICE2
=$
(echo $CDDBCHOICE | cut
-d"," -f2 |
xargs printf %d
2>/dev
/null
)
2075 if [ $PARSECHOICE1 -lt 1 ] ||
[ $PARSECHOICE1 -gt $CDDBCHOICES ] || \
2076 [ $PARSECHOICE2 -lt 1 ] ||
[ $PARSECHOICE2 -gt $CDDBCHOICES ] || \
2077 [ $PARSECHOICE1 -eq $PARSECHOICE2 ]; then
2078 echo "Invalid diff range. Please select two coma-separated numbers between 1 and $CDDBCHOICES" >&2
2080 # We parse the 2 choices to diff, store them in temporary files and diff them.
2081 for PARSECHOICE
in $
(echo $CDDBCHOICE |
tr , \
); do
2082 do_cddbparse
"$ABCDETEMPDIR/cddbread.$PARSECHOICE" > "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE"
2084 echo "Showing diff between choices $PARSECHOICE1 and $PARSECHOICE2..." > "$ABCDETEMPDIR/cddbread.diff"
2085 $DIFF $DIFFOPTS "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE1" "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE2" >> "$ABCDETEMPDIR/cddbread.diff"
2086 if [ $
(cat "$ABCDETEMPDIR/cddbread.diff" |
wc -l) -ge 24 ]; then
2087 page
"$ABCDETEMPDIR/cddbread.diff"
2089 cat "$ABCDETEMPDIR/cddbread.diff" >&2
2093 echo "The diff program was not found in your path. Please choose a number between 0 and $CDDBCHOICES." >&2
2095 elif echo $CDDBCHOICE |
egrep "[[:space:]]*[[:digit:]]+[[:space:]]*" > /dev
/null
2>&1 ; then
2096 # Make sure we get a valid choice
2097 CDCHOICENUM
=$
(echo $CDDBCHOICE |
xargs printf %d
2>/dev
/null
)
2098 if [ $CDCHOICENUM -lt 0 ] ||
[ $CDCHOICENUM -gt $CDDBCHOICES ]; then
2099 echo "Invalid selection. Please choose a number between 0 and $CDDBCHOICES." >&2
2103 if [ "$CDCHOICENUM" = "0" ]; then
2104 vecho
"Creating empty CDDB template..."
2106 $CDDBTOOL template $
(cat "$ABCDETEMPDIR/discid") > "$ABCDETEMPDIR/cddbread.0"
2108 echo "Selected: #$CDCHOICENUM ($(grep ^DTITLE= "$ABCDETEMPDIR/cddbread.
$CDCHOICENUM" | cut -f2- -d= | tr -d \\r\\n))" >&2
2109 do_cddbparse
"$ABCDETEMPDIR/cddbread.$CDCHOICENUM"
2111 echo "cddb-choice=$CDCHOICENUM" >> "$ABCDETEMPDIR/status"
2115 # We need some code to show the selected option when local repository is selected and we have found a match
2116 vecho
"Using cached CDDB match..." >&2
2117 # Display the $ABCDETEMPDIR/cddbchoices file created above
2118 # Pick a pager so that if the tracks overflow the screen the user can still view everything
2119 if [ -r "$ABCDETEMPDIR/cddbchoices" ]; then
2120 CDDBCHOICES
=$
(expr $
(cat "$ABCDETEMPDIR/cddbquery" |
wc -l) - 2)
2121 CHOICE
=$
(checkstatus cddb-choice
)
2122 if [ "$USELOCALRESP" = "y" ]; then :; else
2123 if [ -n "$CHOICE" ] ; then
2124 case $CDDBCHOICES in
2127 echo "Selected template."
2129 1) cat "$ABCDETEMPDIR/cddbchoices" ;;
2131 echo "Selected: #$CHOICE"
2132 do_cddbparse
"$ABCDETEMPDIR/cddbread.$CHOICE"
2140 # We're noninteractive - pick the first choice.
2141 # But in case we run a previous instance and selected a choice, use it.
2142 if [ -r "$ABCDETEMPDIR/cddbchoices" ]; then
2143 # Show the choice if we are not using the locally stored one
2144 # or when the local search failed to find a match.
2145 PREVIOUSCHOICE
=$
(checkstatus cddb-choice
)
2146 if [ "$CDDBUSELOCAL" = "y" ] && [ "$CDDBLOCALSTATUS" = "notfound" ] ||
[ ! "$CDDBUSELOCAL" = "y" ]; then
2147 #if [ "$PREVIOUSCHOICE" ]; then
2148 cat "$ABCDETEMPDIR/cddbchoices"
2151 if [ ! -z "$PREVIOUSCHOICE" ] ; then
2152 CDCHOICENUM
=$PREVIOUSCHOICE
2155 echo "cddb-choice=$CDCHOICENUM" >> "$ABCDETEMPDIR/status"
2157 echo "Selected: #$CDCHOICENUM ($(grep ^DTITLE= "$ABCDETEMPDIR/cddbread.
$CDCHOICENUM" | cut -f2- -d= | tr -d \\r\\n))" >&2
2162 if checkstatus cddb-choice
>/dev
/null
; then :; else
2163 echo "abcde: internal error: cddb-choice not recorded." >&2
2166 CDDBDATA
="$ABCDETEMPDIR/cddbread.$(checkstatus cddb-choice)"
2167 echo -n "Edit selected CDDB data? [y/n] (" >&2
2168 if [ "$INTERACTIVE" = "y" ]; then
2169 if [ "$UNKNOWNDISK" = "y" ]; then
2172 [ "$EDITCDDB" != "n" ] && EDITCDDB
=y
2181 if [ "$EDITCDDB" = "y" ]; then
2182 CDDBDATAMD5SUM
=$
($MD5SUM "$CDDBDATA" | cut
-d " " -f 1);
2184 # Use the debian sensible-editor wrapper to pick the editor that the
2185 # user has requested via their $EDITOR environment variable
2186 if [ -x "/usr/bin/sensible-editor" ]; then
2187 /usr
/bin
/sensible-editor
"$CDDBDATA"
2188 elif [ -n "$EDITOR" ]; then
2189 if [ -x $
(which "${EDITOR%%\ *}") ]; then
2190 # That failed, try to load the preferred editor, starting
2191 # with their EDITOR variable
2192 eval $
(echo "$EDITOR") \"$CDDBDATA\"
2194 # If that fails, check for a vi
2195 elif which vi
>/dev
/null
2>&1; then
2197 elif [ -x /usr
/bin
/vim
]; then
2198 /usr
/bin
/vim
"$CDDBDATA"
2199 elif [ -x /usr
/bin
/vi
]; then
2200 /usr
/bin
/vi
"$CDDBDATA"
2201 elif [ -x /bin
/vi
]; then
2203 # nano should be on all (modern, i.e., sarge) debian systems
2204 elif which nano
>/dev
/null
2>&1 ; then
2206 elif [ -x /usr
/bin
/nano
]; then
2207 /usr
/bin
/nano
"$CDDBDATA"
2208 # mg should be on all OpenBSD systems
2209 elif which mg
>/dev
/null
2>&1 ; then
2211 elif [ -x /usr
/bin
/mg
]; then
2212 /usr
/bin
/mg
"$CDDBDATA"
2215 log warning
"no editor available. Check your EDITOR environment variable."
2217 # delete editor backup file if it exists
2218 if [ -w "$CDDBDATA~" ]; then
2223 # Some heuristics first. Look at Disc Title, and if it starts with
2224 # "Various", then we'll assume Various Artists
2225 if [ "$(grep ^DTITLE= "$CDDBDATA" | cut -f2- -d= | egrep -ci '^(various|soundtrack|varios|sonora|ost)')" != "0" ]; then
2226 echo "Looks like a Multi-Artist CD" >&2
2229 echo -n "Is the CD multi-artist? [y/n] (n): " >&2
2230 if [ "$INTERACTIVE" = "y" ]; then
2237 if [ "$VARIOUSARTISTS" = "y" ] && [ ! "$ONETRACK" = "y" ]; then
2240 # Need NUMTRACKS before cddb-tool will return it:
2241 NUMTRACKS
=$
(egrep '^TTITLE[0-9]+=' "$CDDBDATA" |
wc -l)
2242 if [ "$(grep -c "^TTITLE.
*\
/" "$CDDBDATA")" -gt "$(expr $NUMTRACKS / 2 )" ]; then
2243 # More than 1/2 tracks contain a "/", so guess forward
2245 elif [ "$(grep -c "^TTITLE.
*\
-" "$CDDBDATA")" -gt "$(expr $NUMTRACKS / 2 )" ]; then
2246 # More than 1/2 contain a "-", so guess forward-dash
2248 elif [ "$(grep -c "^TTITLE.
*(.
*)" "$CDDBDATA")" -gt "$(expr $NUMTRACKS / 2 )" ]; then
2249 # More than 1/2 contain something in parens, so guess trailing-paren
2253 echo "1) Artist / Title" >&2
2254 echo "2) Artist - Title" >&2
2255 echo "3) Title / Artist" >&2
2256 echo "4) Title - Artist" >&2
2257 echo "5) Artist: Title" >&2
2258 echo "6) Title (Artist)" >&2
2259 echo "7) This is a single-artist CD" >&2
2260 echo -n "Which style of multiple artist entries is it? [1-7] ($DEFAULTSTYLE): " >&2
2261 if [ "$INTERACTIVE" = "y" ]; then
2262 read VARIOUSARTISTSTYLE
2264 echo $DEFAULTSTYLE >&2
2265 VARIOUSARTISTSTYLE
=$DEFAULTSTYLE
2267 VARIOUSARTISTSTYLE
=$
(echo 0$VARIOUSARTISTSTYLE |
xargs printf %d
)
2268 # If they press Enter, then the default style (0) was chosen
2269 while [ $VARIOUSARTISTSTYLE -lt 0 ] ||
[ $VARIOUSARTISTSTYLE -gt 7 ]; do
2270 echo "Invalid selection. Please choose a number between 1 and 7."
2271 echo -n "Selection [1-7]: "
2272 read VARIOUSARTISTSTYLE
2273 VARIOUSARTISTSTYLE
=$
(echo 0$VARIOUSARTISTSTYLE |
xargs printf %d
)
2275 if [ "$VARIOUSARTISTSTYLE" = "0" ]; then
2276 VARIOUSARTISTSTYLE
=$DEFAULTSTYLE
2278 vecho
"Selected: $VARIOUSARTISTSTYLE"
2279 case "$VARIOUSARTISTSTYLE" in
2281 VARIOUSARTISTSTYLE
=forward
2284 VARIOUSARTISTSTYLE
=forward-dash
2287 VARIOUSARTISTSTYLE
=reverse
2290 VARIOUSARTISTSTYLE
=reverse-dash
2293 VARIOUSARTISTSTYLE
=colon
2296 VARIOUSARTISTSTYLE
=trailing-paren
2304 echo "variousartists=$VARIOUSARTISTS" >> "$ABCDETEMPDIR/status"
2305 echo "variousartiststyle=$VARIOUSARTISTSTYLE" >> "$ABCDETEMPDIR/status"
2307 if [ "$EDITCDDB" = "y" ] && [ "$UNINTENTIONALLY_ANGER_THE_FREEDB_PEOPLE" = "y" ]; then
2308 if [ "$CDDBDATAMD5SUM" != "" ] && [ "$CDDBDATAMD5SUM" != "$($MD5SUM "$CDDBDATA" | cut -d " " -f 1)" ]; then
2309 # This works but does not have the necessary error checking
2310 # yet. If you are familiar with the CDDB spec
2311 # (see http://www.freedb.org/src/latest/DBFORMAT)
2312 # and can create an error-free entry on your own, then put
2313 # UNINTENTIONALLY_ANGER_THE_FREEDB_PEOPLE=y in your
2314 # abcde.conf to enable it. Put CDDBSUBMIT=email@address in
2315 # your abcde.conf to change the email address submissions are
2318 # submit the modified file, if they want
2319 if [ "$NOSUBMIT" != "y" ]; then
2320 echo -n "Do you want to submit this entry to $CDDBSUBMIT? [y/n] (n): "
2322 while [ "$YESNO" != "y" ] && [ "$YESNO" != "n" ] && [ "$YESNO" != "Y" ] && \
2323 [ "$YESNO" != "N" ] && [ "$YESNO" != "" ]
2325 echo -n 'Invalid selection. Please answer "y" or "n": '
2328 if [ "$YESNO" = "y" ] ||
[ "$YESNO" = "Y" ]; then
2329 echo -n "Sending..."
2330 $CDDBTOOL send
"$CDDBDATA" $CDDBSUBMIT
2337 # User CDDBLOCALPOLICY to find out if we store the file or not...
2338 # Cache edited CDDB entry in the user's cddb dir
2339 if [ "$CDDBCOPYLOCAL" = "y" ]; then
2340 # Make sure the cache directory exists
2341 mkdir
-p $CDDBLOCALDIR
2342 cat "$CDDBDATA" |
tail -n $
(expr $
(cat "$CDDBDATA" |
wc -l ) - 1 ) > ${CDDBLOCALDIR}/$
(echo "$TRACKINFO" | cut
-d' ' -f1)
2345 echo "cddb-edit" >> "$ABCDETEMPDIR/status"
2348 # do_cdread [tracknumber]
2349 # do_cdread onetrack [firsttrack] [lasttrack]
2353 # The commands here don't go through run_command because they're never supposed to be silenced
2354 # return codes need to be doublechecked anyway, however
2355 if [ "$1" = "onetrack" ]; then
2356 # FIXME # Add the possibility of grabbing ranges of tracks in onetrack
2357 # FIXME # Until then, we grab the whole CD in one track, no matter what
2359 # We need the first and last track for cdda2wav
2361 LASTTRACK
=$
(expr $3 + 0)
2362 UTRACKNUM
=$FIRSTTRACK
2363 case "$CDROMREADERSYNTAX" in
2364 flac
) READTRACKNUMS
="$FIRSTTRACK.1-$(($LASTTRACK + 1)).0" ;;
2365 cdparanoia
) READTRACKNUMS
="$FIRSTTRACK-$LASTTRACK" ;;
2366 cdda2wav
) READTRACKNUMS
="$FIRSTTRACK+$LASTTRACK" ;;
2367 *) echo "abcde error: $CDROMREADERSYNTAX does not support ONETRACK mode"
2373 CDDBTRACKNUM
=$
(expr $UTRACKNUM - 1)
2374 if [ "$USEPIPES" = "y" ]; then
2375 TEMPARG
="PIPERIPPER_$CDROMREADERSYNTAX"
2376 FILEARG
="$( eval echo "\$
$TEMPARG" )"
2378 PIPE_MESSAGE
="and encoding "
2380 WAVDATA
="$ABCDETEMPDIR/track$UTRACKNUM.wav"
2381 case "$CDROMREADERSYNTAX" in
2382 ## FIXME ## Find the cases for dagrab and flac, to avoid exceptions
2384 FILEARG
="--output-name=$WAVDATA"
2387 FILEARG
="-f $WAVDATA"
2395 if [ "$1" = "onetrack" ]; then
2396 echo "Grabbing ${PIPE_MESSAGE}tracks $UTRACKNUM - $LASTTRACK as one track ..." >&2
2398 if [ -r "$CDDBDATA" ]; then
2399 getcddbinfo TRACKNAME
2400 echo "Grabbing ${PIPE_MESSAGE}track $UTRACKNUM: $TRACKNAME..." >&2
2402 echo "Grabbing ${PIPE_MESSAGE}track $UTRACKNUM..." >&2
2405 case "$CDROMREADERSYNTAX" in
2406 ### FIXME ### use an exception for flac, since it uses -o
2407 ### FIXME ### Shall we just use -o $FILEARG ??
2409 # Avoid problems wit math expressions by unpadding the given UTRACKNUM
2410 STRIPTRACKNUM
=$
(expr $UTRACKNUM + 0)
2411 nice
$READNICE $FLAC -d -f --cue=${READTRACKNUMS:-$STRIPTRACKNUM.1-$(($STRIPTRACKNUM + 1)).0} "$FILEARG" "$CDROM" ;;
2413 nice
$READNICE $CDROMREADER -$CDPARANOIACDROMBUS $CDROM ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" $REDIR ;;
2415 if [ "$OSFLAVOUR" = "OSX" ] ; then
2416 # Hei, we have to unmount the device before running anything like cdda2wav in OSX
2417 disktool
-u ${CDROM#/dev/} 0
2418 # Also, in OSX the cdrom device for cdda2wav changes...
2419 CDDA2WAVCDROM
="IODVDServices"
2420 elif [ "$OSFLAVOUR" = "FBSD" ] ; then
2421 CDDA2WAVCDROM
="$CDROMID"
2423 if [ "$CDROMID" = "" ]; then
2424 CDDA2WAVCDROM
="$CDROM"
2426 CDDA2WAVCDROM
="$CDROMID"
2429 nice
$READNICE $CDROMREADER -D $CDDA2WAVCDROM -t ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" $REDIR
2431 ## FIXME ## We have an exception for dagrab, since it uses -f
2432 ## FIXME ## Shall we just use -f $FILEARG ??
2433 dagrab
) nice
$READNICE $CDROMREADER -d $CDROM -v $UTRACKNUM "$FILEARG" $REDIR
2436 # Find the track's mounted path
2437 REALTRACKNUM
=$
(expr $UTRACKNUM + 0)
2438 FILEPATH
=$
(mount |
grep "$CDROM on" |
sed 's/^[^ ]* on \(.*\) (.*/\1/')
2439 FILEPATH
=$
(find "$FILEPATH" |
grep "/$REALTRACKNUM ");
2440 # If the file exists, copy it
2441 if [ -e "$FILEPATH" ] ; then
2442 nice
$READNICE $CDROMREADER "$FILEPATH" "$FILEARG" $REDIR
2446 debug
) nice
$READNICE $CDROMREADER -$CDPARANOIACDROMBUS $CDROM -w $UTRACKNUM-[:1] "$FILEARG" $REDIR
2450 # If we get some error or we get some missing wav
2451 # (as long as we dont use pipes)
2452 if [ "$RETURN" != "0" -o \
( ! -s "$WAVDATA" -a X
"$USEPIPES" != "Xy" \
) ]; then
2453 # Thank goodness errors is only machine-parseable up to the
2454 # first colon, otherwise this woulda sucked
2455 if [ "$RETURN" = "0" -a ! -s "$WAVDATA" ]; then
2456 RETURN
=73 # fake a return code as cdparanoia return 0 also on aborted reads
2458 if [ "$USEPIPES" = "y" ]; then
2459 echo "readencodetrack-$UTRACKNUM: $CDROMREADER returned code $RETURN" >> "$ABCDETEMPDIR/errors"
2461 echo "readtrack-$UTRACKNUM: $CDROMREADER returned code $RETURN" >> "$ABCDETEMPDIR/errors"
2465 if [ "$USEPIPES" = "y" ]; then
2466 echo readencodetrack-
$UTRACKNUM >> "$ABCDETEMPDIR/status"
2468 echo readtrack-
$UTRACKNUM >> "$ABCDETEMPDIR/status"
2470 if [ "$1" = "onetrack" ]; then
2471 echo onetrack
>> "$ABCDETEMPDIR/status"
2477 # No values accepted, only uses env variables
2480 if "$CDSPEED" "$CDSPEEDOPTS" "$CDSPEEDVALUE" >/dev
/null
; then
2481 vecho
"Setting CD speed to ${CDSPEEDVALUE}x"
2483 echo "abcde: unable to set the device speed" >&2
2489 # vecho outputs a message if EXTRAVERBOSE is selected
2492 if [ x
"$EXTRAVERBOSE" != "x" ]; then
2494 warning
) shift ; log warning
"$@" ;;
2502 # decho outputs a debug message if DEBUG is selected
2505 if [ x
"$DEBUG" != "x" ]; then
2506 if echo $1 |
grep "^\[" > /dev
/null
2>&1 ; then
2507 DEBUGECHO
=$
(echo "$@" |
tr -d '[]')
2508 echo "[DEBUG] $DEBUGECHO: `eval echo \\$${DEBUGECHO}`"
2515 # User-redefinable functions
2516 # Custom filename munging:
2519 #echo "$@" | sed s,:,\ -,g | tr \ /\* __+ | tr -d \'\"\?\[:cntrl:\]
2520 echo "$@" |
sed s
,:,\
-,g |
tr \
/ __ |
tr -d \'\"\?\
[:cntrl
:\
]
2523 # Custom genre munging:
2526 echo $CDGENRE |
tr "[:upper:]" "[:lower:]"
2530 # Empty pre_read function, to be defined in the configuration file.
2537 # Empty post_read function, to be defined in the configuration file.
2543 ###############################################################################
2546 # Start of execution
2547 ###############################################################################
2552 # Defaults to FreeDB, but a python musicbrainz can be used
2554 CDDBURL
="http://freedb.freedb.org/~cddb/cddb.cgi"
2555 CDDBSUBMIT
=freedb-submit@freedb.org
2557 HELLOINFO
="$(whoami)@$(hostname)"
2559 CDDBLOCALPOLICY
="always"
2560 CDDBLOCALRECURSIVE
="y"
2561 CDDBLOCALDIR
="$HOME/.cddb"
2564 # List of fields we parse and show during the CDDB parsing...
2565 SHOWCDDBFIELDS
="year,genre"
2568 #CDROMREADERSYNTAX=cdparanoia
2569 ENCODERSYNTAX
=default
2571 MP3ENCODERSYNTAX
=default
2572 OGGENCODERSYNTAX
=default
2573 FLACENCODERSYNTAX
=default
2574 SPEEXENCODERSYNTAX
=default
2575 MPPENCODERSYNTAX
=default
2576 AACENCODERSYNTAX
=default
2577 NORMALIZERSYNTAX
=default
2578 CUEREADERSYNTAX
=default
2580 OUTPUTFORMAT
='${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
2581 # Use the following VAOUTPUTFORMAT to revert to 2.0.x VA format:
2582 #VAOUTPUTFORMAT=${OUTPUTFORMAT}
2583 VAOUTPUTFORMAT
='Various-${ALBUMFILE}/${TRACKNUM}.${ARTISTFILE}-${TRACKFILE}'
2584 ONETRACKOUTPUTFORMAT
='${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}'
2585 VAONETRACKOUTPUTFORMAT
='Various-${ALBUMFILE}/${ALBUMFILE}'
2586 PLAYLISTFORMAT
='${ARTISTFILE}-${ALBUMFILE}.${OUTPUT}.m3u'
2587 PLAYLISTDATAPREFIX
=''
2588 VAPLAYLISTFORMAT
='${ARTISTFILE}-${ALBUMFILE}.${OUTPUT}.m3u'
2589 VAPLAYLISTDATAPREFIX
=''
2597 VARIOUSARTISTSTYLE
=forward
2603 # If using scsi devices, cdda2wav needs a CDROMID, instead of a device node
2604 # i.e. CDROMID="1,0,0"
2606 # If we are using the IDE bus, we need CDPARANOIACDROMBUS defined as "d"
2607 # If we are using the ide-scsi emulation layer, we need to define a "g"
2608 CDPARANOIACDROMBUS
="d"
2610 # program paths - defaults to checking your $PATH
2617 XINGMP3ENC
=xingmp3enc
2634 CDPARANOIA
=cdparanoia
2640 MUSICBRAINZ
=musicbrainz-get-tracks
2644 VORBISCOMMENT
=vorbiscomment
2646 NORMALIZE
=normalize-audio
2648 VORBISGAIN
=vorbisgain
2654 CUE2DISCID
=cue2discid
2656 # Options for programs called from abcde
2691 VORBISCOMMENTOPTS
="-R"
2692 METAFLACOPTS
="--no-utf8-convert"
2695 # Default to one process if -j isn't specified
2698 # List of actions to perform - by default, run to completion
2699 ACTIONS
=cddb
,read,encode
,tag
,move
,clean
2701 # This option is basicaly for Debian package dependencies:
2702 # List of prefered outputs - by default, run with whatever we have in the path
2703 DEFAULT_OUTPUT_BINARIES
=vorbis
:oggenc
,flac
:flac
,mp3
:lame
,mp3
:bladeenc
,spx
:speex
2705 # List of prefered cdromreaders - by default, run whichever we have in the path
2706 DEFAULT_CDROMREADERS
="cdparanoia cdda2wav"
2708 # Asume fetch if under FreeBSD. curl is used for Mac OS X. wget is used for
2709 # Linux/OpenBSD. ftp is user for NetBSD.
2710 # Let's use these checkings to determine the OS flavour, which will be used
2712 if [ X$
(uname
) = "XFreeBSD" ] ; then
2717 elif [ X$
(uname
) = "XDarwin" ] ; then
2720 # We should have disktool in OSX, but let's be sure...
2722 CDROMREADERSYNTAX
=cddafs
2723 elif [ X$
(uname
) = "XOpenBSD" ] ; then
2727 elif [ X$
(uname
) = "XNetBSD" ] ; then
2731 elif [ X$
(uname
) = "Solaris" ] ; then
2739 # If CDDBAVAIL is set to n, no CDDB read is done
2740 # If USEID3 is set to n, no ID3 tagging is done
2745 if [ -z "$OUTPUTDIR" ]; then
2749 if [ -z "$WAVOUTPUTDIR" ]; then
2750 WAVOUTPUTDIR
="$OUTPUTDIR"
2753 # Load system defaults
2754 if [ -r /etc
/abcde.conf
]; then
2757 # Load user preference defaults
2758 if [ -r $HOME/.abcde.conf
]; then
2762 # By this time, we need some HTTPGETOPTS already defined.
2763 # If the user has defined a non-default HTTPGET method, we should not be empty.
2765 if [ "$HTTPGETOPTS" = "" ] ; then
2767 wget
) HTTPGETOPTS
="-q -O -";;
2768 curl
) HTTPGETOPTS
="-f -s";;
2769 fetch
)HTTPGETOPTS
="-q -o -";;
2770 ftp) HTTPGETOPTS
="-q -o -";;
2771 *) log warning
"HTTPGET in non-standard and HTTPGETOPTS are not defined." ;;
2775 # If the CDROM has not been set yet, find a suitable one.
2776 # If this is a devfs system, default to /dev/cdroms/cdrom0
2777 # instead of /dev/cdrom
2778 if [ "$CDROM" = "" ] ; then
2779 if [ -e /dev
/cdroms
/cdrom0
]; then
2780 CDROM
=/dev
/cdroms
/cdrom0
2781 elif [ -e /dev
/cdrom
]; then
2783 elif [ -e /dev
/cd0c
]; then
2785 elif [ -e /dev
/acd0c
]; then
2787 elif [ -e /dev
/disk1
]; then
2792 # Parse command line options
2793 #while getopts 1a:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do
2794 while getopts 1a
:bBc
:C
:d
:Defghj
:klLmMnNo
:pPr
:s
:S
:t
:T
:uvVxw
:W
:z opt
; do
2797 a
) ACTIONS
="$OPTARG" ;;
2798 A
) EXPACTIONS
="$OPTARG" ;;
2800 B
) NOBATCHREPLAYGAIN
=y
;;
2801 c
) if [ -e "$OPTARG" ] ; then .
"$OPTARG" ; else log error
"config file \"$OPTARG\" cannot be found." ; exit 1 ; fi ;;
2802 C
) DISCID
="$( echo ${OPTARG#abcde.} | tr -d /)" ;;
2803 d
) CDROM
="$OPTARG" ;;
2805 e
) ERASEENCODEDSTATUS
=y
;;
2807 e
) ERASEENCODEDSTATUS
=y
;;
2808 E
) ENCODING
="$OPTARG" ;;
2812 j
) MAXPROCS
="$OPTARG" ;;
2815 L
) CDDBUSELOCAL
=y
;;
2820 o
) OUTPUTTYPE
="$OPTARG" ;;
2823 r
) REMOTEHOSTS
="$OPTARG" ;;
2824 R
) CDDBLOCALRECURSIVE
=y
;;
2825 s
) SHOWCDDBFIELDS
="$OPTARG" ;;
2826 S
) CDSPEEDVALUE
="$OPTARG" ;;
2827 t
) STARTTRACKNUMBER
="$OPTARG" ;;
2828 T
) STARTTRACKNUMBER
="$OPTARG" ; STARTTRACKNUMBERTAG
="y" ;;
2831 echo "This is abcde v$VERSION."
2832 echo "Usage: abcde [options] [tracks]"
2833 echo "abcde -h for extra help"
2836 V
) EXTRAVERBOSE
="y" ;;
2838 w
) COMMENT
="$OPTARG" ;;
2839 W
) if echo $OPTARG |
grep "[[:digit:]]" > /dev
/null
2>&1 ; then
2840 STARTTRACKNUMBER
="${OPTARG}01" ; STARTTRACKNUMBERTAG
="y" ; COMMENT
="CD${OPTARG}"
2842 log error
"argument of -W must be integer"
2846 z
) DEBUG
=y
; CDROMREADERSYNTAX
=debug
; EJECTCD
="n" ;;
2851 shift $
(($OPTIND - 1))
2853 # If the user specified a flac file, then switch to special flac mode
2854 if echo $CDROM |
grep -i '.flac$' > /dev
/null
2>&1 ; then
2855 if [ ! -f $CDROM ]; then
2856 log error
"the defined file for FLAC ripping cannot be found" >&2
2859 vecho warning
"abcde: switching to flac CDROMREADERSYNTAX..."
2860 CDROMREADERSYNTAX
=flac
2861 # Added a need on CUE2DISCID until we manage to convert the python script to bash.
2867 # If the user provided a DISCID, disable eject
2868 if [ -n "$DISCID" ] ||
[ "$CDROMREADERSYNTAX" = "flac" ]; then EJECTCD
=n
; fi
2870 # Check the available cd rippers in the system, from the ones we know.
2871 if [ "$CDROMREADERSYNTAX" = "" ]; then
2872 for DEFAULT_CDROMREADER
in $DEFAULT_CDROMREADERS; do
2873 if new_checkexec
$DEFAULT_CDROMREADER; then
2874 CDROMREADERSYNTAX
=$DEFAULT_CDROMREADER
2878 if [ "$CDROMREADERSYNTAX" = "" ]; then
2879 log error
"no cdreader found in your PATH"
2880 log error
"hints: are all dependencies installed? has the \$PATH been modified?"
2885 # Decide if we can continue.
2886 if [ "$ONETRACK" = "y" ]; then
2887 # FIXME # remove check as soon as we find out about the other readers
2888 case "$CDROMREADERSYNTAX" in
2892 *) log error
"$CDROMREADERSYNTAX does not support ONETRACK mode"
2895 if [ "$BATCHNORM" = "y" ]; then
2896 log warning
"BATCHNORM mode is not compatible with ONETRACK mode. Disabling..."
2899 if [ "$NOGAP" = "y" ]; then
2900 log warning
"NOGAP mode is not compatible with ONETRACK mode. Disabling..."
2903 # It does not matter how many tracks we want. In ONETRACK mode we grab them all
2904 # FIXME # allow ranges of tracks to be selected for onetrack ripping
2905 if [ $# -gt 0 ]; then
2906 log warning
"ONETRACK mode selected, grabbing all tracks..."
2909 while [ $# -gt 0 ]; do
2910 # Range parsing code courtesy of Vincent Ho
2911 RSTART
=$
(echo $1 | cut
-f1 -d-)
2912 REND
=$
(echo $1 | cut
-f2 -d-)
2913 if [ "$RSTART" = "$REND" ]; then
2916 NEWTRACKS
=$
(f_seq_line
$RSTART $REND)
2918 TRACKQUEUE
=$
(echo "$TRACKQUEUE" "$NEWTRACKS")
2923 # List of valid actions: cddb,read,normalize,encode,tag,move,playlist,clean
2924 # List of experimental actions: retag,transcode
2926 # Determine what actions are to be done from $ACTIONS and set the
2927 # following environment variables for them:
2940 for ACTION
in $
(echo $ACTIONS |
tr , \
)
2945 normalize
) DONORMALIZE
=y
; DOREAD
=y
;;
2946 # preprocess) DOPREPROCESS=y; DOREAD=y;;
2947 encode
) DOENCODE
=y
; DOREAD
=y
;;
2948 # postprocess) DOPREPROCESS=y; DOENCODE=y; DOREAD=y;;
2949 tag
) DOTAG
=y
; DOREAD
=y
; DOENCODE
=y
; DOCDDB
=y
;;
2950 move
) DOMOVE
=y
; DOTAG
=y
; DOREAD
=y
; DOENCODE
=y
; DOCDDB
=y
;;
2951 replaygain
) DOCDDB
=y
; DOREAD
=y
; DOENCODE
=y
; DOTAG
=y
; DOMOVE
=y
; DOREPLAYGAIN
=y
;;
2952 playlist
) DOCDDB
=y
; DOPLAYLIST
=y
;;
2957 if [ "$DONORMALIZE" = "y" ] && [ "$DOREPLAYGAIN" = "y" ]; then
2958 # FIXME # should we abort on error or just inform the user?
2959 log warning
"selected both normalize and replaygain actions"
2962 for SHOWCDDBFIELD
in $
(echo $SHOWCDDBFIELDS |
tr , \
); do
2963 case $SHOWCDDBFIELD in
2964 y
*|Y
*) SHOWCDDBYEAR
="y";;
2965 g
*|G
*) SHOWCDDBGENRE
="y";;
2972 # At this point a CDROM has to be defined, so we check it exists.
2973 if [ X
"$CDROM" != "X" ] ; then
2974 if [ "$CDROMREADERSYNTAX" = "cdda2wav" ] && [ "$NEEDCDROMID" = "y" ] ; then
2975 if [ "$OSFLAVOUR" = "FBSD" ]; then
2976 if echo "$CDROMID" |
grep "^[0-9],[0-9],[0-9]$" >/dev
/null
2>&1 ; then :; else
2977 log error
"CDROMID not in the right format for $CDROMREADERSYNTAX"
2978 log error
"Use \"cdrecord -scanbus\" to obtain a adecuate ID an set CDROMID accordingly"
2982 elif [ ! -e "$CDROM" -a X
"$DOREAD" = "Xy" ]; then
2983 log error
"CDROM device cannot be found."
2986 # avoid processing if we are not going to hit the CDROM.
2987 elif [ X
"$DOREAD" = "Xy" ]; then
2988 log error
"CDROM has not been defined or cannot be found"
2992 # USEPIPES pre-tests, before we get into more serious stuff
2993 # Not compatible with:
2994 # - multiple outputs
2996 # - lowdisk algorithm
2998 if [ X
"$USEPIPES" = "Xy" ]; then
2999 if [ $
(echo "$OUTPUTTYPE" |
tr , \ |
wc -w ) -gt 1 ]; then
3000 log error
"Unix pipes not compatible with multiple outputs"
3003 if [ X
"$DONORMALIZE" = "Xy" ]; then
3004 log error
"Unix pipes not compatible with normalizer"
3005 # FIXME # Do we need to exit or shall we just disable the mode?
3008 if [ X
"$BATCHNORM" = "Xy" ]; then
3009 log error
"Unix pipes not compatible with BATCHNORM encoding"
3012 if [ X
"$NOGAP" = "Xy" ]; then
3013 log error
"Unix pipes not compatible with NOGAP encoding"
3016 if [ X
"$DOENCODE" = "Xn" ]; then
3017 vecho warning
"Disabling Unix pipes since we are not encoding!"
3020 if [ X
"$LOWDISK" = "Xy" ]; then
3021 log error
"Unix pipes not compatible with lowdisk algorithm"
3026 # LOWDISK pre-tests, before we get into more problematic stuff
3027 # Not compatible with anything that needs all the files in the hard disc:
3030 if [ X
"$LOWDISK" = "Xy" ]; then
3031 if [ X
"$BATCHNORM" = "Xy" ]; then
3032 log error
"Unix pipes not compatible with BATCHNORM encoding"
3035 if [ X
"$NOGAP" = "Xy" ]; then
3036 log error
"Unix pipes not compatible with NOGAP encoding"
3041 # BATCHNORM pre-tests, before we get into serious problems
3042 # Not compatible with
3043 if [ "$BATCHNORM" = "y" ] && [ "$DONORMALIZE" = "n" ]; then
3044 vecho warning
"Disabling BATCHNORM since we are not normalizing!"
3048 # Check the encoding format from the ones available in the system, if nothing has been configured in the system.
3049 if [ X
"$OUTPUTTYPE" = "X" ]; then
3050 for DEFAULT_OUTPUT
in $
( echo "$DEFAULT_OUTPUT_BINARIES" |
tr , \
); do
3051 DEFAULT_OUTPUT_FORMAT
="$(echo $DEFAULT_OUTPUT | cut -d ":" -f 1)"
3052 DEFAULT_OUTPUT_BINARY
="$(echo $DEFAULT_OUTPUT | cut -d ":" -f 2)"
3053 if [ -x $
(which $DEFAULT_OUTPUT_BINARY) ] ; then
3054 OUTPUTTYPE
=$DEFAULT_OUTPUT_FORMAT
3055 vecho
"No default output type defined. Autoselecting $OUTPUTTYPE..." >&2
3059 if [ X
"$OUTPUTTYPE" = "X" ]; then
3060 log error
"no encoder found in the PATH"
3061 log error
"hints: are all dependencies installed? has the \$PATH been modified?"
3066 # Decide which CDROM reader we're gonna use
3067 case "$CDROMREADERSYNTAX" in
3069 CDROMREADER
="$CDPARANOIA"
3070 CDROMREADEROPTS
="$CDPARANOIAOPTS"
3073 CDROMREADER
="$CDDA2WAV"
3074 CDROMREADEROPTS
="$CDDA2WAVOPTS"
3077 CDROMREADER
="$DAGRAB"
3078 CDROMREADEROPTS
="$DAGRABOPTS"
3081 CDROMREADER
="$CDDAFS"
3082 CDROMREADEROPTS
="$CDDAFSOPTS"
3086 CDROMREADEROPTS
="$FLACOPTS"
3090 # There's only one normalize...
3091 case "$NORMALIZERSYNTAX" in
3093 NORMALIZER
="$NORMALIZE"
3094 NORMALIZEROPTS
="$NORMALIZEOPTS"
3098 # Allow -o OUTPUT(1):OPTIONS(1),...,OUTPUT(N):OPTIONS(N) mode of operation
3099 if echo "$OUTPUTTYPE" |
grep ":" > /dev
/null
2>&1 ; then
3100 for OUTPUT
in "$(echo "$OUTPUTTYPE" | tr , \ )"; do
3102 vorbis
:*|ogg
:*) OGGENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
3103 mp3
:*) MP3ENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
3104 flac
:*) FLACENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
3105 spx
:*) SPEEXENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
3106 mpc
:*) MPPENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
3107 m4a
:*) AACENCODEROPTSCLI
="$( echo $OUTPUT | cut -d: -f2- )" ;;
3110 for OUTPUT
in "$(echo "$OUTPUTTYPE" | tr , \ )"; do
3111 TEMPOUTPUT
=$
( echo "$OUTPUT" | cut
-d: -f1 )
3112 TEMPOUTPUTTYPE
="${TEMPOUTPUTTYPE:+$TEMPOUTPUTTYPE,}$TEMPOUTPUT"
3114 OUTPUTTYPE
="$TEMPOUTPUTTYPE"
3117 # If nothing has been specified, use oggenc for oggs and lame for mp3s and flac
3118 # for flacs and speexenc for speex and mppenc for mpps and faac for m4as
3120 # Getting ready for multiple output changes
3121 for OUTPUT
in $
(echo $OUTPUTTYPE |
tr , \
)
3125 [ "$OGGENCODERSYNTAX" = "default" ] && OGGENCODERSYNTAX
=oggenc
3126 [ "$DOTAG" = "y" ] && NEEDCOMMENTER
=y
3127 [ "$DOREPLAYGAIN" = "y" ] && NEEDVORBISGAIN
=y
3128 OGGOUTPUTCONTAINER
=ogg
3131 [ "$MP3ENCODERSYNTAX" = "default" ] && MP3ENCODERSYNTAX
=lame
3132 [ "$DOTAG" = "y" ] && NEEDTAGGER
=y
3133 [ "$DOREPLAYGAIN" = "y" ] && NEEDMP3GAIN
=y
3136 [ "$FLACENCODERSYNTAX" = "default" ] && FLACENCODERSYNTAX
=flac
3137 [ "$DOTAG" = "y" ] && NEEDMETAFLAC
=y
3138 [ "$DOREPLAYGAIN" = "y" ] && NEEDMETAFLAC
=y
3141 [ "$SPEEXENCODERSYNTAX" = "default" ] && SPEEXENCODERSYNTAX
=speexenc
3142 # [ "$DOREPLAYGAIN" = "y" ] &&
3145 [ "$MPPENCODERSYNTAX" = "default" ] && MPPENCODERSYNTAX
=mppenc
3146 [ "$DOREPLAYGAIN" = "y" ] && NEEDMPPGAIN
=y
3149 [ "$AACENCODERSYNTAX" = "default" ] && AACENCODERSYNTAX
=faac
3152 if [ "$KEEPWAVS" = "y" ]; then
3153 vecho
"Unsetting the KEEPWAVS option, since the resulting wav files were requested..."
3157 *) log error
"Invalid OUTPUTTYPE defined"
3163 # decide which encoder
3164 case "$MP3ENCODERSYNTAX" in
3166 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$LAMEOPTS}"
3170 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$TOOLAMEOPTS}"
3171 MP3ENCODER
="$TOOLAME"
3174 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$GOGOOPTS}"
3178 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$BLADEENCOPTS}"
3179 MP3ENCODER
="$BLADEENC"
3182 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$L3ENCOPTS}"
3186 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$XINGMP3ENCOPTS}"
3187 MP3ENCODER
="$XINGMP3ENC"
3190 MP3ENCODEROPTS
="${MP3ENCODEROPTSCLI:-$MP3ENCOPTS}"
3191 MP3ENCODER
="$MP3ENC"
3194 case "$OGGENCODERSYNTAX" in
3196 OGGENCODEROPTS
="${OGGENCODEROPTSCLI:-$VORBIZEOPTS}"
3197 OGGENCODER
="$VORBIZE"
3200 OGGENCODEROPTS
="${OGGENCODEROPTSCLI:-$OGGENCOPTS}"
3201 OGGENCODER
="$OGGENC"
3204 case "$FLACENCODERSYNTAX" in
3206 FLACENCODEROPTS
="${FLACENCODEROPTSCLI:-$FLACOPTS}"
3208 # FLAC streams can be encapsulated on a Ogg transport layer
3209 if echo "$FLACENCODEROPTS" |
egrep -- "(^| )--ogg($| )" > /dev
/null
2>&1 ;then
3210 log error
"FLAC on an Ogg container is not yet supported"
3211 log error
"due to problem with adding comments to such files"
3213 FLACOUTPUTCONTAINER
=ogg
3215 FLACOUTPUTCONTAINER
=flac
3219 case "$SPEEXENCODERSYNTAX" in
3221 SPEEXENCODEROPTS
="${SPEEXENCODEROPTSCLI:-$SPEEXENCOPTS}"
3222 SPEEXENCODER
="$SPEEXENC"
3225 case "$MPPENCODERSYNTAX" in
3227 MPPENCODEROPTS
="${MPPENCODEROPTSCLI:-$MPPENCOPTS}"
3228 MPPENCODER
="$MPPENC"
3231 case "$AACENCODERSYNTAX" in
3233 AACENCODEROPTS
="${AACENCODEROPTSCLI:-$AACENCOPTS}"
3234 AACENCODER
="$AACENC"
3239 if [ "$ID3TAGV" = "1" ]; then
3241 TAGGEROPTS
="$ID3OPTS"
3244 TAGGEROPTS
="$ID3V2OPTS"
3247 # Specific for NOGAP is the use of lame. Another encoder fails...
3248 if [ "$NOGAP" = "y" ] && [ ! "$MP3ENCODER" = "lame" ]; then
3249 log warning
"the NOGAP option is specific of lame. Deactivating..."
3254 case "$CUEREADERSYNTAX" in
3256 CUEREADEROPTS
="${CDROM}"
3261 # which information retrieval tool are we using?
3267 # Check if both OGGEOUTPUTCONTAINER and FLACOUTPUTCONTAINER are the same, and differentiante them
3268 if [ X
"$OGGOUTPUTCONTAINER" = "Xogg" ] && [ X
"$FLACOUTPUTCONTAINER" = "Xogg" ]; then
3269 log error
"FLAC on an Ogg container is not yet supported"
3270 log error
"due to problem with adding comments to such files"
3272 OGGOUTPUTCONTAINER
=ogg.ogg
3273 FLACOUTPUTCONTAINER
=flac.ogg
3274 vecho warning
"modified file endings due to conflicting transport layers in Ogg/Vorbis and Ogg/FLAC"
3277 # Clean up nice options (either use '-n NICELEVEL or -NICELEVEL')
3279 if [ "$ENCNICE" ]; then
3280 ENCNICE
="-n $ENCNICE"
3282 if [ "$READNICE" ]; then
3283 READNICE
="-n $READNICE"
3285 if [ "$DISTMP3NICE" ]; then
3286 DISTMP3NICE
="-n $DISTMP3NICE"
3289 # Don't check for stuff if it's not needed
3290 if [ "$REMOTEHOSTS" ]; then
3293 if [ "$DONORMALIZE" = "y" ]; then
3296 if [ "$EJECTCD" = "y" ]; then
3299 if [ ! "$CDDBAVAIL" = "n" ] && [ "$DOCDDB" = "y" ]; then
3300 if [ "$CDDBMETHOD" = "cddb" ]; then
3302 elif [ "$CDDBMETHOD" = "musicbrainz" ]; then
3306 if [ "$MAKECUEFILE" = "y" ]; then
3310 if [ X
"$CDSPEEDVALUE" != "X" ] && [ "$DOREAD" = "y"]; then
3311 case "$CDROMREADERSYNTAX" in
3312 cdparanoia|debug
) CDROMREADEROPTS
="$CDPARANOIAOPTS -S $CDSPEEDVALUE" ;;
3313 ### FIXME ### translate "cue2discid" from python to bash
3314 flac
) NEEDMETAFLAC
=y
; NEEDCUE2DISCID
=y
; CDSPEEDVALUE
="" ;;
3319 ###USEPIPESSUPPORT###
3321 # Rippers with USEPIPE support
3322 # FIXME # Include here all the rippers we can figure out support pipes
3323 PIPERIPPER_cdparanoia
="-"
3324 PIPERIPPER_debug
="-"
3325 PIPERIPPER_flac
="-c "
3327 # Encoders with USEPIPE support
3328 # FIXME # Include here all the encoders we can figure out support pipes
3334 # Figure out if we can use pipes with the ripper/encoder combination
3336 if [ "$USEPIPES" = "y" ]; then
3337 PIPERIPPERSVARCHECK
="PIPERIPPER_${CDROMREADERSYNTAX}"
3340 PIPEENCODERSVARCHECK
="PIPE_$MP3ENCODERSYNTAX" ;;
3342 PIPEENCODERSVARCHECK
="PIPE_$OGGENCODERSYNTAX" ;;
3344 PIPEENCODERSVARCHECK
="PIPE_$FLACENCODERSYNTAX" ;;
3346 PIPEENCODERSVARCHECK
="PIPE_$SPEEXENCODER" ;;
3348 PIPEENCODERSVARCHECK
="PIPE_$MPPENCODER" ;;
3350 decho
"PIPERIPPERSVARCHECK: $( eval echo "\$
$PIPERIPPERSVARCHECK" )"
3351 if [ "$( eval echo "\$
$PIPERIPPERSVARCHECK" )" = "$" ] || \
3352 [ "$( eval echo "\$
$PIPERIPPERSVARCHECK" )" = "" ] ; then
3353 log error
"no support for pipes with given ripper"
3354 log error
"read the USEPIPES file from the source tarball to get help."
3355 log error
"On a Debian system, it is under /usr/share/doc/abcde/USEPIPES.gz"
3358 decho
"PIPEENCODERSVARCHECK: $( eval echo "\$
$PIPEENCODERSVARCHECK" )"
3359 if [ "$( eval echo "\$
$PIPEENCODERSVARCHECK" )" = "$" ] || \
3360 [ "$( eval echo "\$
$PIPEENCODERSVARCHECK" )" = "" ] ; then
3361 log error
"no support for pipes with given encoder"
3362 log error
"read the USEPIPES file from the source tarball to help"
3363 log error
"on a Debian system, read /usr/share/doc/abcde/USEPIPES.gz"
3368 # Make sure a buncha things exist
3369 for X
in $CDROMREADER $CDDISCID ${NEEDTAGGER+$TAGGER} $MP3ENCODER \
3370 $OGGENCODER $FLACENCODER $SPEEXENCODER $MPPENCODER \
3371 ${NEEDHTTPGET+$HTTPGET} ${NEEDDISTMP3+$DISTMP3} \
3372 ${NEEDCOMMENTER+$VORBISCOMMENT} ${NEEDMETAFLAC+$METAFLAC} \
3373 ${NEEDNORMALIZER+$NORMALIZER} ${NEEDEJECT+$EJECT} \
3374 ${NEEDDISKTOOL+disktool} ${NEEDCDSPEED+$CDSPEED} \
3375 ${NEEDVORBISGAIN+$VORBISGAIN} ${NEEDMP3GAIN+$MP3GAIN} \
3376 ${NEEDMPPGAIN+$MPPGAIN} ${NEEDCUEREADER+$CUEREADER} \
3377 ${NEEDCUE2DISCID+$CUE2DISCID}
3382 # And last but not least, check if we can diff between files
3383 if [ -x $
(which $DIFF) ]; then :; else
3384 vecho warning
"Disabling diff since we cannot find it in the \$PATH..."
3388 ## Now that we have metaflac, check if we need cue2discid
3389 #case $CDROMREADERSYNTAX in
3391 # TRACKINFO=$($METAFLAC --show-tag=CDDB $CDROM | cut -d"=" -f2 | egrep "[a-f0-9]{8}")
3392 # if [ "$TRACKINFO" = "" ]; then
3393 # checkexec ${NEEDCUE2DISCID+$CUE2DISCID}
3398 CDROMREADER
="$CDROMREADER $CDROMREADEROPTS"
3399 CDDBTOOL
="$CDDBTOOL $CDDBTOOLOPTS"
3400 HTTPGET
="$HTTPGET $HTTPGETOPTS"
3402 # Here it used to say:
3403 # One thousand lines in, we can start doing stuff with things
3404 # Well, right now we are at line 3306 ;)
3406 # Export needed things so they can be read in this subshell
3407 export CDDBTOOL ABCDETEMPDIR TRACKQUEUE LOWDISK EJECTCD EJECT EJECTOPTS
3408 export CDROM CDDBDATA REMOTEHOSTS MAXPROCS HTTPGET MD5SUM
3410 if [ "$DOREAD" = "y" ]; then
3411 # User-definable function to set some things. Use it for
3412 # - closing the CD tray with eject -t
3413 # - set the CD speed value with eject -x
3414 vecho
-n "Executing customizable pre-read function... "
3416 pre_read
# Execute the user-defined pre-read funtion. Close the CD with it.
3421 case "$CDDBMETHOD" in
3423 do_discid
# Get ABCDETEMPDIR created and status file initialized
3430 if [ "$DOCDDB" = "y" ]; then
3431 # start with a sane default:
3432 CDDBLOCALSTATUS
=notfound
3433 if [ $CDDBUSELOCAL = "y" ]; then
3436 if checkstatus cddb-choice
> /dev
/null
; then
3439 if [ "$CDDBLOCALSTATUS" = "notfound" ] ; then
3440 case "$CDDBMETHOD" in
3454 eval "$($CDDBTOOL parse "$CDDBDATA")"
3457 # Before reading tracks, we set the speed of the device
3459 if [ X
"$CDSPEEDVALUE" != "X" ]; then
3460 case "$CDROMREADERSYNTAX" in
3461 cdparanoia|debug
) ;;
3467 # Define the first and last track, since we might need them later in several places
3468 FIRSTTRACK
=$
( get_first
$TRACKQUEUE )
3469 LASTTRACK
=$
( get_last
$TRACKQUEUE )
3471 if [ -f "$ABCDETEMPDIR/status" ] && [ X
"$ERASEENCODEDSTATUS" = "Xy" ]; then
3472 mv "$ABCDETEMPDIR/status" "$ABCDETEMPDIR/status.old"
3473 grep -v ^encodetracklocation-
< "$ABCDETEMPDIR/status.old" \
3474 |
grep -v ^encode-output
> "$ABCDETEMPDIR/status"
3477 if checkstatus onetrack
; then ONETRACK
=y
; fi
3479 if [ "$ONETRACK" = "y" ]; then
3480 # Reuse the CUEFILE in case we created it in a previous run
3481 if CUEFILE
=$
(checkstatus cuefile
); then
3486 # Create playlist if needed (backgroundable) and start reading in tracks
3490 if [ ! "$ONETRACK" = "y" ]; then
3491 if [ "$DOPLAYLIST" = "y" ]; then
3492 echo Creating playlist...
>&2
3497 # For the lowdisk option, only one program is running at once so the encoder
3498 # can be unsilenced right away.
3499 if [ "$LOWDISK" = "y" ] ||
[ "$ONETRACK" = "y" ]; then
3500 echo "encode-output=loud" >> "$ABCDETEMPDIR/status"
3503 if [ "$ONETRACK" = "y" ]; then
3504 TRACKS
="$FIRSTTRACK"
3505 if [ "$USEPIPES" = "y" ]; then
3506 if checkstatus readencodetrack-
$FIRSTTRACK; then :; else
3507 do_cdread onetrack
$FIRSTTRACK $LASTTRACK | do_encode
$FIRSTTRACK %local0
% > /dev
/null
2>&1
3510 if checkstatus readtrack-
$FIRSTTRACK; then :; else
3511 do_cdread onetrack
$FIRSTTRACK $LASTTRACK
3515 for UTRACKNUM
in $TRACKQUEUE
3517 if [ "$DOREAD" = "y" ]; then
3518 if [ "$USEPIPES" = "y" ]; then
3519 if checkstatus readencodetrack-
$UTRACKNUM; then :; else
3520 # Read, pipe, shut up!
3521 do_cdread
$UTRACKNUM | do_encode
$UTRACKNUM %local0
% > /dev
/null
2>&1
3524 if checkstatus readtrack-
$UTRACKNUM; then :; else
3525 do_cdread
$UTRACKNUM
3527 if [ "$?" != "0" ]; then
3528 # CD read failed - don't give the goahead to
3535 if [ "$NOGAP" = "y" ] ||
[ "$BATCHNORM" = "y" ]; then
3538 # If we are not reading, set the encode output to loud already, so
3539 # that we can see the output of the first track.
3540 if [ "$MAXPROCS" = "1" ] && [ ! "$DOREAD" = "y" ]; then
3541 echo "encode-output=loud" >> "$ABCDETEMPDIR/status"
3543 echo NEXTTRACK
# Get the encoder machine churning again
3544 if [ "$DOREAD" = "y" ]; then
3545 if [ "$LOWDISK" = "y" ] && [ "$DOENCODE" = "y" ]; then
3546 until checkstatus encodetrack-
$UTRACKNUM
3548 if checkerrors encodetrack-
$UTRACKNUM; then
3559 # Now that we're done the encoding can be loud again -
3560 # if we're not using SMP.
3561 if [ "$MAXPROCS" = "1" ]; then
3562 echo "encode-output=loud" >> "$ABCDETEMPDIR/status"
3565 # All tracks read, start encoding.
3566 if [ "$NOGAP" = "y" ] ||
[ "$BATCHNORM" = "y" ] ||
[ "$ONETRACK" = "y" ]; then
3570 # Execute the user-defined post_read funtion before ejecting CD
3573 # We are now finished with the cdrom - it can be safely ejected. Note that
3574 # abcde will not have completed yet.
3575 if [ "$EJECTCD" = "y" ] && [ -x $
(which $EJECT) ]; then
3576 # We check if the disk we are processing is actually the disk inside the
3577 # CD tray. If not, we do not eject the CD, since it might be so that the
3578 # user ejected it manually.
3579 #CURRENTTRACKINFO=$($CDDISCID $CDROM)
3580 #if if [ "$?" != "1" ] && [ "$CURRENTTRACKINFO" = "$TRACKINFO" ] ; then
3581 # More FreeBSD bits.
3582 if [ X
"$(uname)" = X
"FreeBSD" ] ; then
3583 # FreeBSD eject uses the EJECT environment variable to name the CDROM
3584 # but in this script EJECT is in the envionment and names the program
3587 # The FreeBSD eject needs "adc0" not "/dev/adc0c"
3588 cd="$(echo $CDROM | sed -e 's=.*/==;s=[a-h]$==;')"
3589 $eject $EJECTOPTS $cd
3590 elif [ X
"$(uname)" = X
"Darwin" ] ; then
3591 disktool
-e ${CDROM#/dev/} 0
3593 $EJECT $EJECTOPTS $CDROM
3600 ## Do we need to pre-process
3601 #if [ x"$PREPROCESS" = "x" ] ; then
3604 # for PRETRACKNUM in $TRACKQUEUE
3607 # if [ "$GOAHEAD" = "NO" ]; then break; fi
3609 # until [ $PREPROCEED ]
3611 # if checkstatus readtrack-$PRETRACKNUM; then PREPROCEED=y; break; fi
3612 # # all locations are working, wait and try again later
3613 # if [ ! $PREPROCEED ]; then sleep 3; fi
3615 # ( do_preprocess $PRETRACKNUM
3623 # In BATCHNORM and/or NOGAP modes, we want all tracks to be read first.
3625 if [ "$BATCHNORM" = "y" ] ||
[ "$NOGAP" = "y" ]; then
3626 read GOAHEAD
# For blocking - will contain either "NO" or "NEXTTRACK"
3627 if [ "$GOAHEAD" = "NO" ]; then break; fi
3628 for LASTTRACK
in $TRACKQUEUE; do :; done
3629 if checkstatus readtrack-
$LASTTRACK; then
3630 if [ "$DONORMALIZE" = "y" ] && [ "$BATCHNORM" = "y" ]; then
3631 if checkstatus normalizetrack-
$LASTTRACK; then :; else do_batch_normalize
; fi
3632 if checkerrors batch-normalize
; then exit 1; fi
3634 if [ "$DOENCODE" = "y" ] && [ "$NOGAP" = "y" ]; then
3635 if [ "$DONORMALIZE" = "y" ]; then
3636 for UTRACKNUM
in $TRACKQUEUE
3638 if checkstatus readtrack-
$UTRACKNUM; then
3639 if checkstatus normalizetrack-
$UTRACKNUM; then :; else do_normalize
$UTRACKNUM; fi
3643 if checkstatus encodetrack-
$LASTTRACK; then :; else do_nogap_encode
; fi
3644 if checkerrors nogap-encode
; then exit 1; fi
3649 # If we are using ONETRACK, we can proceed with the normal encoding using just the $FIRSTTRACK as TRACKQUEUE
3650 if [ "$ONETRACK" = "y" ] ; then
3651 TRACKQUEUE
="$FIRSTTRACK"
3652 TRACKS
="$FIRSTTRACK"
3655 # Do the encoding, including parallelization of remote encoding
3656 # Figure out where each track is going to be encoded
3657 ENCODELOCATIONS
="$(echo $REMOTEHOSTS | tr , ' ')"
3658 if [ "$MAXPROCS" != "0" ]; then
3659 for NUM
in $
(f_seq_row
1 "$MAXPROCS")
3661 ENCODELOCATIONS
="$ENCODELOCATIONS %local$NUM%"
3665 ENCODELOCATIONS
=$
(echo $ENCODELOCATIONS)
3666 for UTRACKNUM
in $TRACKQUEUE
3669 read GOAHEAD
# For blocking - will contain either "NO" or "NEXTTRACK"
3670 if [ "$GOAHEAD" = "NO" ]; then break; fi
3671 # find out where this track is to be encoded
3672 if [ "$DOENCODE" = "y" -a "$USEPIPES" != "y" ]; then
3673 # Make sure we have a place to encode this, if not, exit stage right
3674 if [ -z "$ENCODELOCATIONS" ]; then
3680 for LOCATION
in $ENCODELOCATIONS
3682 PREVIOUSTRACK
="$(checkstatus encodetracklocation-$LOCATION)"
3683 # check first if a track has ever been assigned to this location
3684 if [ -z "$PREVIOUSTRACK" ]; then PROCEED
=y
; break; fi
3685 # If it errored out, rebuild $ENCODELOCATIONS without this location in it
3686 if checkerrors encodetrack-
$PREVIOUSTRACK; then
3687 for TEMPLOCATION
in $ENCODELOCATIONS
3689 if [ "$TEMPLOCATION" != "$LOCATION" ]; then
3690 TEMPENCODELOCATIONS
="$TEMPENCODELOCATIONS $TEMPLOCATION"
3693 ENCODELOCATIONS
=$
(echo $TEMPENCODELOCATIONS)
3698 # We're still here, this location must have been previously assigned,
3699 # and last completed without error - check if it's done with the
3700 # previous track yet
3701 if checkstatus encodetrack-
$PREVIOUSTRACK; then PROCEED
=y
; break; fi
3703 # all locations are working, wait and try again later
3704 if [ ! $PROCEED ]; then sleep 3; fi
3706 # Record the location we're about to encode the next track at
3707 echo "encodetracklocation-$LOCATION=$UTRACKNUM" >> "$ABCDETEMPDIR/status"
3709 # Don't proceed with the rest of the loop if we can't encode
3710 if [ "$ABORT" ]; then continue; fi
3711 # Set TRACKNUM, TRACKNAME
3712 if [ -e "$CDDBDATA" ]; then
3713 if [ "$ONETRACK" = "y" ]; then
3715 TRACKNUM
="$FIRSTTRACK"
3719 CDDBTRACKNUM
=$
(expr $UTRACKNUM - 1)
3720 getcddbinfo TRACKNAME
3724 # You can't encode a file which needs to be normalized before finishing
3725 # You can't tag a file before it's finished encoding -
3726 # thus all of this is backgrounded together
3728 if [ "$DONORMALIZE" = "y" ]; then
3729 if checkstatus readtrack-
$UTRACKNUM; then
3730 if checkstatus normalizetrack-
$UTRACKNUM; then :; else do_normalize
$UTRACKNUM; fi
3733 if [ "$DOENCODE" = "y" -a "$USEPIPES" != "y" ]; then
3734 if checkstatus readtrack-
$UTRACKNUM; then
3735 #if checkstatus encodetrack-$UTRACKNUM; then :; else do_encode $UTRACKNUM $LOCATION; fi
3736 if [ "$DONORMALIZE" = "y" ]; then
3737 if checkstatus normalizetrack-
$UTRACKNUM; then
3738 if checkstatus encodetrack-
$UTRACKNUM; then :; else do_encode
$UTRACKNUM $LOCATION $OUTPUT; fi
3741 if checkstatus encodetrack-
$UTRACKNUM; then :; else do_encode
$UTRACKNUM $LOCATION $OUTPUT; fi
3745 if [ "$DOTAG" = "y" ]; then
3746 if checkstatus encodetrack-
$UTRACKNUM; then
3747 if checkstatus tagtrack-
$UTRACKNUM; then :; else do_tag
$UTRACKNUM; fi
3749 # Lets tag the cue file
3750 if checkstatus cleancuefile
>/dev
/null
; then :; else
3751 if checkstatus cuefile
>/dev
/null
; then
3756 if [ "$DOMOVE" = "y" ]; then
3757 if checkstatus tagtrack-
$UTRACKNUM; then
3758 if checkstatus movetrack-
$UTRACKNUM; then :; else do_move
$UTRACKNUM; fi
3765 # Go through it again and make sure there's no distmp3 stragglers, otherwise
3766 # we'll delete the files they're working on
3767 ## FIXME ## Check also for files which are encoded using PIPEs.
3768 if [ "$DOENCODE" = "y" -a "$USEPIPES" != "y" ]; then
3773 for LOCATION
in $ENCODELOCATIONS
3775 CHECKTRACK
="$(checkstatus encodetracklocation-$LOCATION)"
3776 # "How can he give us a status update, if he's DEAD?"
3777 if checkstatus encodetrack-
$CHECKTRACK; then
3780 # Nothing to see here please go quietly back to your homes
3781 if [ -z "$CHECKTRACK" ]; then continue; fi
3782 # You're still here? Maybe there is something...
3783 if checkstatus encodetrack-
$CHECKTRACK; then :; else PROCEED
= ; break; fi
3786 if [ ! $PROCEED ]; then sleep 5; fi
3789 # If the above didn't catch the stragglers, this will
3791 if [ "$DOREPLAYGAIN" = "y" ]; then
3795 # Check to see if run_command logged any errors
3796 if [ -f "$ABCDETEMPDIR/errors" ]; then
3797 log error
"The following commands failed to run:"
3798 cat "$ABCDETEMPDIR/errors"
3802 if [ "$KEEPWAVS" = "y" ];then
3806 # Check if we have moved all the formats we had previously encoded, if we are not using the FORCE.
3807 if [ "$DOCLEAN" = "y" ] && [ ! "$FORCE" = "y" ]; then
3808 ENCODED_FORMATS
=$
(egrep "^encodetrack-(.{3,6})-(.{1,2})$" "$ABCDETEMPDIR/status" | cut
-d"-" -f2 |
sort -u |
tr '\n' '|')
3809 MOVED_FORMATS
=$
(egrep "^movetrack-output-(.{3,6})$" "$ABCDETEMPDIR/status" | cut
-d"-" -f3 |
sort -u |
tr '\n' '|')
3810 if [ "$ENCODED_FORMATS" != "$MOVED_FORMATS" ]; then
3811 log warning
"The encoded formats does not match with the moved ones"
3812 log warning
"Formats encoded: $( echo $ENCODED_FORMATS | tr "|
" " " )"
3813 log warning
"Formats moved: $( echo $MOVED_FORMATS | tr "|
" " " )"
3814 log warning
"Use \"abcde -a clean -f -C $DISCID\" to force the removal of the remaining data."
3818 if [ "$DOCLEAN" = "y" ]; then
3819 # Wipe all the evidence
3820 # Gimme gimme gimme some more time!
3822 rm -rf "$ABCDETEMPDIR"
3825 echo "Finished. Not cleaning $ABCDETEMPDIR."