-#!/bin/sh
+#!/bin/bash
# Copyright (c) 1998-2001 Robert Woodcock <rcw@debian.org>
# Copyright (c) 2003-2005 Jesus Climent <jesus.climent@hispalinux.es>
# This code is hereby licensed for public consumption under either the
#
# Copyright for this work is to expire January 1, 2010, after which it
# shall be public domain.
+#
+# $Id$
-VERSION="2.3.99"
+VERSION='2.3.99-$Revision$'
usage ()
{
echo "Options:"
echo "-1 Encode the whole CD in a single file"
echo "-a <action1[,action2]...>"
-echo " Actions to perform (cddb,read,normalize,encode,tag,move,playlist,clean)"
+echo " Actions to perform:"
+echo " cddb,read,normalize,encode,tag,move,replaygain,playlist,clean"
#echo "-A Experimental actions (retag, transcode)"
echo "-b Enable batch normalization"
+#echo "-B Disable batch replaygain (do file by file)"
echo "-c <file>"
echo " Specify a configuration file (overrides system and user config files)"
echo "-C <discid#>"
echo " Specify CDROM device to grab (flac uses a single-track flac file)"
echo "-D Debugging mode (equivalent to sh -x abcde)"
echo "-e Erase encoded track information from status file"
-#echo "-E Set the encoding information for the tags"
echo "-f Force operations that otherwise are considered harmful. Read \"man abcde\""
echo "-g Use \"lame --nogap\" for MP3 encoding. Disables low disk and pipes flags"
echo "-h This help information"
echo "-m Modify playlist to include CRLF endings, to comply with some players"
echo "-M Create a CUE file"
echo "-o <type1[,type2]...>"
-echo " Output file type(s) (vorbis,mp3,flac,spx,mpc,wav). Defaults to vorbis"
+echo " Output file type(s) (vorbis,mp3,flac,spx,mpc,wav,m4a). Defaults to vorbis"
echo "-p Pad track numbers with 0's (if less than 10 tracks)"
echo "-P Use UNIX pipes to read+encode without wav files"
echo "-r <host1[,host2]...>"
echo " Also encode on these remote hosts"
-echo "-R Add replaygain values to the tag info (only for vorbis,flac)"
+#echo "-R Add replaygain values to the tag info (only for vorbis,flac,mp3)"
echo "-s <field>"
echo " Show dielfs from the CDDB info (year,genre)"
echo "-S <#> Set the CD speed"
echo "-t <#> Start the track numbering at a given number"
echo "-T <#> Same as -t but modifies tag numbering"
+echo "-u Use UNICODE tags and comments"
echo "-v Show version number and exit"
echo "-V Be a bit more verbose about what is happening behind the scenes"
echo "-x Eject CD after all tracks are read"
BLURB="$1"
shift
case $BLURB in
- error) echo "[ERR] abcde: $@" >&2 ;;
- warning) echo "[WAR] $@" >&2 ;;
- info) echo "[INF] $@" ;;
+ error) echo "[ERROR] abcde: $@" >&2 ;;
+ warning) echo "[WARNING] $@" >&2 ;;
+ info) echo "[INFO] $@" ;;
esac
}
f_seq_line ()
{
i=$1
- if echo i | grep -q "[[:digit:]]" ; then
+ if echo $i | grep -q "[[:digit:]]" ; then
while [ $i -ne `expr $2 + 1` ]
do
printf $i" "
# do_getcddbinfo
# Finds an specific field from cddbinfo
-#
-# TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2 -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')
-# TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2 -d= | tr -d \[:cntrl:\])
-# TRACKNAME="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
-
do_getcddbinfo()
{
case $1 in
if checkstatus replaygain; then :; else
run_command "" echo "Adding replygain information..."
for OUTPUT in $( echo $OUTPUTTYPE | tr , \ )
- # THE OUTPUT NEEDS TO BE CORRECTED WITH THE CONTAINER?
do
case $OUTPUT in
vorbis|ogg)
;;
esac
OUTPUTFILES=""
+ REPLAYINDEX=0
for UTRACKNUM in $TRACKQUEUE
do
CDDBTRACKNUM=$(expr $UTRACKNUM - 1)
ALBUMFILE="$(mungefilename "$DALBUM")"
do_gettracknum
if [ "$VARIOUSARTISTS" = "y" ]; then
- OUTPUTFILE=$(eval echo $VAOUTPUTFORMAT)
+ OUTPUTFILE="$(eval echo $VAOUTPUTFORMAT)"
else
- OUTPUTFILE=$(eval echo $OUTPUTFORMAT)
+ OUTPUTFILE="$(eval echo $OUTPUTFORMAT)"
fi
- OUTPUTFILES="$OUTPUTDIR/$OUTPUTFILE.$OUTPUT $OUTPUTFILES"
+ OUTPUTFILES[$REPLAYINDEX]="$OUTPUTDIR/$OUTPUTFILE.$OUTPUT"
+ (( REPLAYINDEX = $REPLAYINDEX + 1 ))
done
case "$OUTPUT" in
flac)
- run_command replaygain-flac $METAFLAC --add-replay-gain $OUTPUTFILES
+ run_command replaygain-flac $METAFLAC --add-replay-gain "${OUTPUTFILES[@]}"
;;
vorbis|ogg)
- run_command replaygain-vorbis $VORBISGAIN --album $OUTPUTFILES
+ run_command replaygain-vorbis $VORBISGAIN --album "${OUTPUTFILES[@]}"
+ ;;
+ mp3)
+ run_command replaygain-mp3 $MP3GAIN -a "${OUTPUTFILES[@]}"
+ ;;
+ mpc)
+ run_command replaygain-mpc $MPPGAIN --auto "${OUTPUTFILES[@]}"
;;
*);;
esac
done
- if checkerrors replaygain-.{3,6}; then :; else
+ if checkerrors "replaygain-.{3,6}"; then :; else
run_command replaygain true
fi
fi
mpc)
run_command tagtrack-$OUTPUT-$1 true
;;
+ m4a)
+ run_command tagtrack-$OUTPUT-$1 true
+ ;;
wav)
run_command tagtrack-$OUTPUT-$1 true
;;
mpc)
TEMPARG="PIPE_$MPPENCODER"
;;
+ m4a)
+ TEMPARG="PIPE_$MPPENCODER"
+ ;;
esac
IN="$( eval echo "\$$TEMPARG" )"
else
if [ -s "$IN" -o X"$USEPIPES" = "Xy" ] ; then
for OUTPUT in $(echo $OUTPUTTYPE | tr , \ )
do
- if [ "$NOGAP" = "y" ] && checkstatus encodetrack-$OUTPUT-$1 ; then
- continue
- fi
case "$OUTPUT" in
vorbis|ogg)
OUT="$ABCDETEMPDIR/track$1.$OGGOUTPUTCONTAINER"
+ OUTPUT=$OGGOUTPUTCONTAINER
;;
flac)
OUT="$ABCDETEMPDIR/track$1.$FLACOUTPUTCONTAINER"
+ OUTPUT=$FLACOUTPUTCONTAINER
;;
*)
OUT="$ABCDETEMPDIR/track$1.$OUTPUT"
;;
esac
+ if [ "$NOGAP" = "y" ] && checkstatus encodetrack-$OUTPUT-$1 ; then
+ continue
+ fi
if [ X"$USEPIPES" = "Xy" ]; then
RUN_COMMAND=""
+ # We need a way to store the creation of the files when using PIPES
+ RUN_COMMAND_PIPES="run_command encodetrack-$OUTPUT-$1 true"
else
run_command '' echo "Encoding track $1 of $TRACKS: $TRACKNAME..."
RUN_COMMAND="run_command encodetrack-$OUTPUT-$1"
case "$2" in
%local*%)
case "$FLACENCODERSYNTAX" in
- flac) $RUN_COMMAND nice $ENCNICE $FLACENCODER $FLACENCODEROPTS -o "$OUT" "$IN" ;;
+ flac) $RUN_COMMAND nice $ENCNICE $FLACENCODER -f $FLACENCODEROPTS -o "$OUT" "$IN" ;;
esac
;;
*)
## FIXME ## to the encoder ends up empty.
$RUN_COMMAND nice $ENCNICE $MPPENCODER $MPPENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" "$IN" "$OUT"
;;
+ m4a)
+ # Quick hack to avoid tagging Ogg/Speex, since there is no other way to tag than inline tagging
+ if [ ! "$DOTAG" = "y" ]; then
+ $RUN_COMMAND nice $ENCNICE $AACENCODER $AACENCODEROPTS --artist "$TRACKARTIST" --album "$DALBUM" --title "$TRACKNAME" --track "$1" --genre "$CDGENRE" --year "$CDYEAR" --comment "$COMMENT" -o "$OUT" "$IN"
+
+ else
+ $RUN_COMMAND nice $ENCNICE $AACENCODER $AACENCODEROPTS -o "$OUT" "$IN"
+ fi
+ ;;
wav)
# In case of wav output we need nothing. Just keep the wavs.
- run_command encodetrack-$OUTPUT-$1 true
;;
esac
+ $RUN_COMMAND_PIPES
done
# Only remove .wav if the encoding succeeded
if checkerrors "encodetrack-(.{3,6})-$1"; then :; else
# do_batch_gain
# variables used:
-# MP3GAIN, MP3GAINOPTS, VORBISGAIN, VORBISGAINOPTS
+# MP3GAIN, MP3GAINOPTS, VORBISGAIN, VORBISGAINOPTS, MPPGAIN, MPPGAINOPTS
# FIXME #
do_batch_gain ()
{
do
# Shares some code with do_move since the filenames have to match
CDDBTRACKNUM=$(expr $UTRACKNUM - 1)
- #TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2 -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')
do_getcddbinfo TRACKNAME
splitvarious
TRACKFILE="$(mungefilename "$TRACKNAME")"
if [ "$CDROMREADERSYNTAX" = "flac" ] ; then
TRACKINFO=$($METAFLAC $METAFLACOPTS --export-cuesheet-to=- $CDROM | $CUE2DISCID)
else
- TRACKINFO=$($CDDISCID $CDROM)
+ case "$CDDBMETHOD" in
+ cddb) TRACKINFO=$($CDDISCID $CDROM) ;;
+ # FIXME # musicbrainz needs a cleanup
+ musicbrainz) TRACKINFO=$($MUSICBRAINZ -c $CDROM ) ;;
+ esac
fi
# Make sure there's a CD in there by checking cd-discid's return code
if [ ! "$?" = "0" ]; then
disktool -m ${CDROM#/dev/}
fi
WEHAVEACD=y
+ DISCID=$(echo $TRACKINFO | cut -f1 -d' ')
else
TRACKINFO=$(cat "$WAVOUTPUTDIR/abcde.$DISCID/discid")
fi
TRACKS="$(echo "$CDPARANOIAOUTPUT" | egrep '^[[:space:]]+[[:digit:]]' | tail -n 1 | get_first | tr -d "." | tr '\n' ' ')"
CDPARANOIAAUDIOTRACKS="$TRACKS"
else
+ # Previous versions of abcde would store the tracks on a file, instead of the status record.
+ if [ -f "$ABCDETEMPDIR/cdparanoia-audio-tracks" ]; then
+ echo cdparanoia-audio-tracks=$( cat "$ABCDETEMPDIR/cdparanoia-audio-tracks" ) >> "$ABCDETEMPDIR/status"
+ rm -f "$ABCDETEMPDIR/cdparanoia-audio-tracks"
+ fi
if [ -f "$ABCDETEMPDIR/status" ] && TRACKS=$(checkstatus cdparanoia-audio-tracks); then :; else
TRACKS=$(echo $TRACKINFO | cut -f2 -d' ')
fi
exit 1
fi
rm -rf "$ABCDETEMPDIR" || exit 1
- mkdir "$ABCDETEMPDIR"
+ mkdir -p "$ABCDETEMPDIR"
if [ "$?" -gt "0" ]; then
# Directory already exists or could not be created
echo "abcde: Temp directory $ABCDETEMPDIR could not be created." >&2
fi
else
# We are starting from scratch
- mkdir "$ABCDETEMPDIR"
+ mkdir -p "$ABCDETEMPDIR"
if [ "$?" -gt "0" ]; then
# Directory already exists or could not be created
echo "abcde: Temp directory $ABCDETEMPDIR could not be created." >&2
exit 1
fi
cat /dev/null > "$ABCDETEMPDIR/status"
+ # Store the abcde version in the status file.
+ echo "abcde-version=$VERSION" >> "$ABCDETEMPDIR/status"
fi
if [ X"$MAKECUEFILE" = "Xy" -a X"$WEHAVEACD" = "Xy" ]; then
if checkstatus cuefile > /dev/null 2>&1 ; then :; else
# Create the discid file
echo "$TRACKINFO" > "$ABCDETEMPDIR/discid"
+ if checkstatus cddbmethod > /dev/null 2>&1 ; then :; else
+ echo "cddbmethod=$CDDBMETHOD" >> "$ABCDETEMPDIR/status"
+ fi
}
# do_cleancue
fi
}
+do_musicbrainzstat ()
+{
+ :
+}
+
+do_musizbrainz ()
+{
+ :
+}
+
# do_cddbstat
do_cddbstat ()
{
CHOICE=$(checkstatus cddb-choice)
if [ -n "$CHOICE" ] ; then
case $CDDBCHOICES in
+ -1) log error "CDDB query failed!"
+ exit 1
+ ;;
1) cat "$ABCDETEMPDIR/cddbchoices" ;;
*)
echo "Selected: #$CHOICE"
echo -n "Which entry would you like abcde to use (0 for none)? [0-$CDDBCHOICES]: " >&2
read CDDBCHOICE
[ X"$CDDBCHOICE" = "X" ] && CDDBCHOICE=1
- if echo $CDDBCHOICE | egrep -q "[[:digit:]]+,[[:digit:]]+" ; then
+ if echo $CDDBCHOICE | egrep -q "[[:space:]]*[[:digit:]]+,[[:digit:]]+[[:space:]]*" ; then
if [ ! X"$DIFF" = "X" ]; then
- PARSECHOICE1=$(echo $CDDBCHOICE | cut -d"," -f1)
- PARSECHOICE2=$(echo $CDDBCHOICE | cut -d"," -f2)
+ PARSECHOICE1=$(echo $CDDBCHOICE | cut -d"," -f1 | xargs printf %d 2>/dev/null)
+ PARSECHOICE2=$(echo $CDDBCHOICE | cut -d"," -f2 | xargs printf %d 2>/dev/null)
if [ $PARSECHOICE1 -lt 1 ] || [ $PARSECHOICE1 -gt $CDDBCHOICES ] || \
[ $PARSECHOICE2 -lt 1 ] || [ $PARSECHOICE2 -gt $CDDBCHOICES ] || \
[ $PARSECHOICE1 -eq $PARSECHOICE2 ]; then
echo "Invalid diff range. Please select two coma-separated numbers between 1 and $CDDBCHOICES" >&2
else
-
# We parse the 2 choices to diff, store them in temporary files and diff them.
for PARSECHOICE in $(echo $CDDBCHOICE | tr , \ ); do
do_cddbparse "$ABCDETEMPDIR/cddbread.$PARSECHOICE" > "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE"
else
echo "The diff program was not found in your path. Please choose a number between 0 and $CDDBCHOICES." >&2
fi
- else
+ elif echo $CDDBCHOICE | egrep -q "[[:space:]]*[[:digit:]]+[[:space:]]*" ; then
+ # Make sure we get a valid choice
+ CDCHOICENUM=$(echo $CDDBCHOICE | xargs printf %d 2>/dev/null)
if [ $CDCHOICENUM -lt 0 ] || [ $CDCHOICENUM -gt $CDDBCHOICES ]; then
- # Make sure we get a valid choice
- CDCHOICENUM=$(echo $CDDBCHOICE | xargs printf %d 2>/dev/null)
echo "Invalid selection. Please choose a number between 0 and $CDDBCHOICES." >&2
fi
fi
LASTTRACK=$3
UTRACKNUM=$FIRSTTRACK
case "$CDROMREADERSYNTAX" in
- ### FIXME ### How are we calculating the tracks in flac mode?
flac) READTRACKNUMS="$FIRSTTRACK.1-$(($LASTTRACK + 1)).0" ;;
cdparanoia) READTRACKNUMS="$FIRSTTRACK-$LASTTRACK" ;;
cdda2wav) READTRACKNUMS="$FIRSTTRACK+$LASTRACK" ;;
- *) log error "$CDROMREADERSYNTAX does not support ONETRACK mode"
- exit 1 ;;
+ *) echo "abcde error: $CDROMREADERSYNTAX does not support ONETRACK mode"
+ exit 1 ;;
esac
else
UTRACKNUM=$1
echo "Grabbing ${PIPE_MESSAGE}tracks $UTRACKNUM - $LASTTRACK as one track ..." >&2
else
if [ -r "$CDDBDATA" ]; then
- #TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head -n 1 | cut -f2 -d= | tr -d \[:cntrl:\])
do_getcddbinfo TRACKNAME
echo "Grabbing ${PIPE_MESSAGE}track $UTRACKNUM: $TRACKNAME..." >&2
else
flac)
nice $READNICE $FLAC -d --cue=${READTRACKNUMS:-$UTRACKNUM.1-$(($UTRACKNUM + 1)).0} "$FILEARG" "$CDROM" ;;
cdparanoia)
+ echo "nice $READNICE $CDROMREADER -$CDPARANOIACDROMBUS $CDROM ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" $REDIR ;;" > /tmp/log
nice $READNICE $CDROMREADER -$CDPARANOIACDROMBUS $CDROM ${READTRACKNUMS:-$UTRACKNUM} "$FILEARG" $REDIR ;;
cdda2wav)
if [ "$OSFLAVOUR" = "OSX" ] ; then
decho ()
{
if [ x"$DEBUG" != "x" ]; then
- DEBUGECHO=$(echo "$@" | tr -d '[]')
- echo "[DEBUG] $DEBUGECHO: `eval echo \\$${DEBUGECHO}`"
+ if echo $1 | grep -q "^\[" ; then
+ DEBUGECHO=$(echo "$@" | tr -d '[]')
+ echo "[DEBUG] $DEBUGECHO: `eval echo \\$${DEBUGECHO}`"
+ else
+ echo "[DEBUG] $1"
+ fi
fi
}
###############################################################################
# Builtin defaults
+
+# CDDB
+# Defaults to FreeDB, but a python musicbrainz can be used
+CDDBMETHOD=cddb
CDDBURL="http://freedb.freedb.org/~cddb/cddb.cgi"
CDDBSUBMIT=freedb-submit@freedb.org
CDDBPROTO=5
SHOWCDDBFIELDS="year,genre"
INTERACTIVE=y
-CDROMREADERSYNTAX=cdparanoia
+#CDROMREADERSYNTAX=cdparanoia
ENCODERSYNTAX=default
MP3ENCODERSYNTAX=default
FLACENCODERSYNTAX=default
SPEEXENCODERSYNTAX=default
MPPENCODERSYNTAX=default
+AACENCODERSYNTAX=default
NORMALIZERSYNTAX=default
CUEREADERSYNTAX=default
SPEEXENC=speexenc
# mpp (Musepack)
MPPENC=mppenc
+# m4a
+AACENC=faac
ID3=id3
ID3V2=id3v2
CDDAFS=cp
CDDISCID=cd-discid
CDDBTOOL=cddb-tool
+MUSICBRAINZ=musicbrainz-get-tracks
EJECT=eject
MD5SUM=md5sum
DISTMP3=distmp3
NORMALIZE=normalize-audio
CDSPEED=eject
VORBISGAIN=vorbisgain
+MP3GAIN=mp3gain
+MPPGAIN=replaygain
MKCUE=mkcue
MKTOC=cdrdao
DIFF=diff
VORBIZEOPTS=
OGGENCOPTS=
# flac
-FLACOPTS="-f"
+FLACOPTS=
# speex
SPEEXENCOPTS=
# mpc
MPPENCOPTS=
+# m4a
+AACENCOPTS=
ID3OPTS=
ID3V2OPTS=
MKTOCOPTS=""
VORBISCOMMENTOPTS="-R"
METAFLACOPTS="--no-utf8-convert"
+DIFFOPTS=
# Default to one process if -j isn't specified
MAXPROCS=1
# List of actions to perform - by default, run to completion
ACTIONS=cddb,read,encode,tag,move,clean
+# This option is basicaly for Debian package dependencies:
# List of prefered outputs - by default, run with whatever we have in the path
-# This option is basicaly for Debian package dependencies
DEFAULT_OUTPUT_BINARIES=vorbis:oggenc,flac:flac,mp3:lame,mp3:bladeenc,spx:speex
+# List of prefered cdromreaders - by default, run whichever we have in the path
+DEFAULT_CDROMREADERS="cdparanoia cdda2wav"
+
# Asume fetch if under FreeBSD. curl is used for Mac OS X. wget is used for Linux/OpenBSD/NetBSD.
# Let's use these checkings to determine the OS flavour, which will be used later
if [ X$(uname) = "XFreeBSD" ] ; then
fi
# Parse command line options
-#while getopts 1a:A:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do
-while getopts 1a:bc:C:d:Defghj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W:z opt ; do
+#while getopts 1a:bc:C:d:Dehj:klLmMnNo:pPr:Rs:S:t:T:vVxw:W: opt ; do
+while getopts 1a:bBc:C:d:Defghj:klLmMnNo:pPr:s:S:t:T:uvVxw:W:z opt ; do
case "$opt" in
1) ONETRACK=y ;;
a) ACTIONS="$OPTARG" ;;
A) EXPACTIONS="$OPTARG" ;;
b) BATCHNORM=y ;;
+ B) NOBATCHREPLAYGAIN=y ;;
c) if [ -e "$OPTARG" ] ; then . "$OPTARG" ; else log error "config file \"$OPTARG\" cannot be found." ; exit 1 ; fi ;;
- C) DISCID="${OPTARG#abcde.}" ;;
+ C) DISCID="$( echo ${OPTARG#abcde.} | tr -d /)" ;;
d) CDROM="$OPTARG" ;;
D) set -x ;;
e) ERASEENCODEDSTATUS=y ;;
p) PADTRACKS=y ;;
P) USEPIPES=y ;;
r) REMOTEHOSTS="$OPTARG" ;;
- R) REPLAYGAIN=y ;;
+ R) DOREPLAYGAIN=y ;;
s) SHOWCDDBFIELDS="$OPTARG" ;;
S) CDSPEEDVALUE="$OPTARG" ;;
-# t) PREPROCESSFORMATS="$OPTARG"
-# PREPROCESS=y ;;
-# T) POSTPROCESSFORMATS="$OPTARG" ;;
t) STARTTRACKNUMBER="$OPTARG" ;;
T) STARTTRACKNUMBER="$OPTARG" ; STARTTRACKNUMBERTAG="y" ;;
+ u) CDDBPROTO=6 ;;
v)
echo "This is abcde v$VERSION."
echo "Usage: abcde [options] [tracks]"
fi
fi
+# If the user provided a DISCID, disable eject
+if [ -n "$DISCID" ]; then EJECTCD=n ; fi
+
+# Check the available cd rippers in the system, from the ones we know.
+if [ "$CDROMREADERSYNTAX" = "" ]; then
+ for DEFAULT_CDROMREADER in $DEFAULT_CDROMREADERS; do
+ if [ -x $( which $DEFAULT_CDROMREADER ) ]; then
+ CDROMREADERSYNTAX=$DEFAULT_CDROMREADER
+ break
+ fi
+ done
+ if [ "$CDROMREADERSYNTAX" = "" ]; then
+ log error "no cdreader found in your PATH"
+ log error "hints: are all dependencies installed? has the \$PATH been modified?"
+ exit 1
+ fi
+fi
+
# Decide if we can continue.
if [ "$ONETRACK" = "y" ]; then
# FIXME # remove check as soon as we find out about the other readers
if [ "$DONORMALIZE" = "y" ] && [ "$DOREPLAYGAIN" = "y" ]; then
# FIXME # should we abort on error or just inform the user?
- :
+ log warning "selected both normalize and replaygain actions"
fi
for SHOWCDDBFIELD in $(echo $SHOWCDDBFIELDS | tr , \ ); do
flac:*) FLACENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;;
spx:*) SPEEXENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;;
mpc:*) MPPENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;;
+ m4a:*) AACENCODEROPTSCLI="$( echo $OUTPUT | cut -d: -f2- )" ;;
esac
done
for OUTPUT in "$(echo "$OUTPUTTYPE" | tr , \ )"; do
OUTPUTTYPE="$TEMPOUTPUTTYPE"
fi
-# If nothing has been specified, use oggenc for oggs and lame for mp3s and flac for flacs and speexenc for speex and mppenc for mpps
+# If nothing has been specified, use oggenc for oggs and lame for mp3s and flac
+# for flacs and speexenc for speex and mppenc for mpps and faac for m4as
# Getting ready for multiple output changes
for OUTPUT in $(echo $OUTPUTTYPE | tr , \ )
vorbis|ogg)
[ "$OGGENCODERSYNTAX" = "default" ] && OGGENCODERSYNTAX=oggenc
[ "$DOTAG" = "y" ] && NEEDCOMMENTER=y
- [ "$REPLAYGAIN" = "y" ] && NEEDVORBISGAIN=y
+ [ "$DOREPLAYGAIN" = "y" ] && NEEDVORBISGAIN=y
OGGOUTPUTCONTAINER=ogg
;;
mp3)
[ "$MP3ENCODERSYNTAX" = "default" ] && MP3ENCODERSYNTAX=lame
[ "$DOTAG" = "y" ] && NEEDTAGGER=y
+ [ "$DOREPLAYGAIN" = "y" ] && NEEDMP3GAIN=y
;;
flac)
[ "$FLACENCODERSYNTAX" = "default" ] && FLACENCODERSYNTAX=flac
- [ "$REPLAYGAIN" = "y" ] && NEEDMETAFLAC=y
[ "$DOTAG" = "y" ] && NEEDMETAFLAC=y
+ [ "$DOREPLAYGAIN" = "y" ] && NEEDMETAFLAC=y
;;
spx)
[ "$SPEEXENCODERSYNTAX" = "default" ] && SPEEXENCODERSYNTAX=speexenc
+# [ "$DOREPLAYGAIN" = "y" ] &&
;;
mpc)
[ "$MPPENCODERSYNTAX" = "default" ] && MPPENCODERSYNTAX=mppenc
+ [ "$DOREPLAYGAIN" = "y" ] && NEEDMPPGAIN=y
+ ;;
+ m4a)
+ [ "$AACENCODERSYNTAX" = "default" ] && AACENCODERSYNTAX=faac
;;
wav)
if [ "$KEEPWAVS" = "y" ]; then
MPPENCODER="$MPPENC"
;;
esac
-
+case "$AACENCODERSYNTAX" in
+ faac)
+ AACENCODEROPTS="${AACENCODEROPTSCLI:-$AACENCOPTS}"
+ AACENCODER="$AACENC"
+ ;;
+esac
# and which tagger
if [ "$ID3TAGV" = "1" ]; then
NEEDEJECT=y
fi
if [ ! "$CDDBAVAIL" = "n" ] && [ "$DOCDDB" = "y" ]; then
- NEEDHTTPGET=y
+ if [ "$CDDBMETHOD" = "cddb" ]; then
+ NEEDHTTPGET=y
+ elif [ "$CDDBMETHOD" = "musicbrainz" ]; then
+ :
+ fi
fi
if [ "$MAKECUEFILE" = "y" ]; then
NEEDCUEREADER=y
esac
fi
+###USEPIPESSUPPORT###
+
# Rippers with USEPIPE support
# FIXME # Include here all the rippers we can figure out support pipes
PIPERIPPER_cdparanoia="-"
+PIPERIPPER_debug="-"
PIPERIPPER_flac="-c "
# Encoders with USEPIPE support
mpc)
PIPEENCODERSVARCHECK="PIPE_$MPPENCODER" ;;
esac
- if [ "$( eval echo "\$$PIPERIPPERSVARCHECK" )" = "$" ] ; then
+ decho "PIPERIPPERSVARCHECK: $( eval echo "\$$PIPERIPPERSVARCHECK" )"
+ if [ "$( eval echo "\$$PIPERIPPERSVARCHECK" )" = "$" ] || \
+ [ "$( eval echo "\$$PIPERIPPERSVARCHECK" )" = "" ] ; then
log error "no support for pipes with given ripper"
log error "read the USEPIPES file from the source tarball to get help."
log error "On a Debian system, it is under /usr/share/doc/abcde/USEPIPES.gz"
exit 1;
fi
- vecho PIPES: "$( eval echo "\$$PIPEENCODERSVARCHECK" )"
- if [ "$( eval echo "\$$PIPEENCODERSVARCHECK" )" = "$" ] ; then
+ decho "PIPEENCODERSVARCHECK: $( eval echo "\$$PIPEENCODERSVARCHECK" )"
+ if [ "$( eval echo "\$$PIPEENCODERSVARCHECK" )" = "$" ] || \
+ [ "$( eval echo "\$$PIPEENCODERSVARCHECK" )" = "" ] ; then
log error "no support for pipes with given encoder"
log error "read the USEPIPES file from the source tarball to help"
log error "on a Debian system, read /usr/share/doc/abcde/USEPIPES.gz"
${NEEDCOMMENTER+$VORBISCOMMENT} ${NEEDMETAFLAC+$METAFLAC} \
${NEEDNORMALIZER+$NORMALIZER} ${NEEDEJECT+$EJECT} \
${NEEDDISKTOOL+disktool} ${NEEDCDSPEED+$CDSPEED} \
- ${NEEDVORBISGAIN+$VORBISGAIN} ${NEEDCUEREADER+$CUEREADER} \
- ${NEEDCUE2DISCID+$CUE2DISCID}
+ ${NEEDVORBISGAIN+$VORBISGAIN} ${NEEDMP3GAIN+$MP3GAIN} \
+ ${NEEDMPPGAIN+$MPPGAIN} \
+ ${NEEDCUEREADER+$CUEREADER} ${NEEDCUE2DISCID+$CUE2DISCID}
do
# Cut off the command-line options we just added in
X=$(echo $X | cut -d' ' -f2)
vecho "done."
-do_discid # Get ABCDETEMPDIR created and status file initialized
+case "$CDDBMETHOD" in
+ cddb)
+ do_discid # Get ABCDETEMPDIR created and status file initialized
+ ;;
+ musicbrainz)
+ do_musicbrainz
+ ;;
+esac
if [ "$DOCDDB" = "y" ]; then
if [ $CDDBUSELOCAL = "y" ]; then
:
else
if [ ! "$CDDBLOCALSUCCESS" = "y" ] ; then
- do_cddbstat
- do_cddbquery
- do_cddbread
+ case "$CDDBMETHOD" in
+ cddb)
+ do_cddbstat
+ do_cddbquery
+ do_cddbread
+ ;;
+ musicbrainz)
+ do_musicbrainz
+ ;;
+ esac
fi
fi
do_cddbedit
if [ "$NOGAP" = "y" ] || [ "$BATCHNORM" = "y" ]; then
:
else
+ # If we are not reading, set the encode output to loud already, so
+ # that we can see the output of the first track.
+ if [ "$MAXPROCS" = "1" ] && [ ! "$DOREAD" = "y" ]; then
+ echo "encode-output=loud" >> "$ABCDETEMPDIR/status"
+ fi
echo NEXTTRACK # Get the encoder machine churning again
if [ "$DOREAD" = "y" ]; then
if [ "$LOWDISK" = "y" ] && [ "$DOENCODE" = "y" ]; then
TRACKNUM="$FIRSTTRACK"
splitvarious
else
-# TRACKNUM=$(printf %0.${TRACKNUMPADDING}d $(expr ${UTRACKNUM} + 0))
TRACKNUM=$UTRACKNUM
CDDBTRACKNUM=$(expr $UTRACKNUM - 1)
- #TRACKNAME="$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | cut -f2- -d= | tr -d \[:cntrl:\] | sed 's/\ \+$//')"
do_getcddbinfo TRACKNAME
splitvarious
fi
fi
# If the above didn't catch the stragglers, this will
wait
-if [ "$REPLAYGAIN" = "y" ]; then
+if [ "$DOREPLAYGAIN" = "y" ]; then
do_replaygain
fi
+
# Check to see if run_command logged any errors
if [ -f "$ABCDETEMPDIR/errors" ]; then
log error "The following commands failed to run:"
if [ "$DOCLEAN" = "y" ] && [ ! "$FORCE" = "y" ]; then
ENCODED_FORMATS=$(egrep "^encodetrack-(.{3,6})-(.{1,2})$" "$ABCDETEMPDIR/status" | cut -d"-" -f2 | sort -u | tr '\n' '|')
MOVED_FORMATS=$(egrep "^movetrack-output-(.{3,6})$" "$ABCDETEMPDIR/status" | cut -d"-" -f3 | sort -u | tr '\n' '|')
- decho [ENCODED_FORMATS]
- decho [MOVED_FORMATS]
if [ "$ENCODED_FORMATS" != "$MOVED_FORMATS" ]; then
- log warning "Not all encoded formats have been requested to be moved."
- log warning "Use \"-a clean -f -C $DISCID\" to force the removal of the remaining data."
+ log warning "The encoded formats does not match with the moved ones"
+ log warning "Formats encoded: $( echo $ENCODED_FORMATS | tr "|" " " )"
+ log warning "Formats moved: $( echo $MOVED_FORMATS | tr "|" " " )"
+ log warning "Use \"abcde -a clean -f -C $DISCID\" to force the removal of the remaining data."
DOCLEAN=n
fi
fi