Örnek işlevi genişletirken bash komut dosyası sorunu


0

Ben kullanıyorum abcdebenim Ahududu pi ile (Daha iyi bir CD kodlayıcı) ve aranması ve albüm kapaklarını gömme yeni işlevselliği kullanmak istiyorum. Bunun için abcde.confkendi tanımlayabilirsiniz bir kısmını sahiptir post_encode ()işlevi.

Http://www.andrews-corner.org/getalbumart.html adresinden çalışan bir örnek şöyle görünür:

#--------------------------------------------------------------------------#
#  A post_encode function to embed album art downloaded with abcde 2.7     #
#  and greater using the new getalbumart function. OUTPUTTYPE must be      # 
#  mp3 and and tagging is with eyeD3. To use this function copy the        # 
#  entire code block and paste it into your ~/.abcde.conf file.            #
#                                                                          # 
#                abcde: Downloading Album Art...                           #
#         http://www.andrews-corner.org/getalbumart.html                   #
#--------------------------------------------------------------------------#
post_encode ()
{
ARTISTFILE="$(mungefilename "$TRACKARTIST")"
ALBUMFILE="$(mungefilename "$DALBUM")"

if [ "$VARIOUSARTISTS" = "y" ] ; then
FINDPATH="$(eval echo "$VAOUTPUTFORMAT")"
else
FINDPATH="$(eval echo "$OUTPUTFORMAT")"
fi

FINALDIR="$(dirname "$OUTPUTDIR/$FINDPATH")"
cd "$FINALDIR"

if [ "$OUTPUTTYPE" = "mp3" ] && [ "$TAGGER" = "$EYED3" ] ; then
vecho "Preparing to embed the album art..." >&2
else
vecho "Not embedding album art, you need mp3 output and eyeD3 tagging..."  >&2
return 1
fi

if [ -e "cover.jpg" ] ; then
for i in *.mp3
do
eyeD3 --add-image cover.jpg:FRONT_COVER "$i"
done

mkdir backup
mv cover.jpg backup
vecho "Your files have had the album art embedded..." >&2
else
vecho "No album art found so no image embedded..." >&2
fi
}

Bunu tek seferde (abcde'nin güçlü yönlerinden biri) birkaç formatta yapabilmek ve hepsini tek bir fonksiyonda yerine getirememek istiyorum.

Bu benim bir işlev yapma konusundaki başarısız denemem post_encode ():

post_encode ()
{
ARTISTFILE="$(mungefilename "$TRACKARTIST")"
ALBUMFILE="$(mungefilename "$DALBUM")"

if [ "$VARIOUSARTISTS" = "y" ] ; then
FINDPATH="$(eval echo "$VAOUTPUTFORMAT")"
else
FINDPATH="$(eval echo "$OUTPUTFORMAT")"
fi

FINALDIR="$(dirname "$OUTPUTDIR/$FINDPATH")"
cd "$FINALDIR"

if [[ "$OUTPUTTYPE" == *"mp3"* ]] && [ "$TAGGER" = "$EYED3" ] ; then
vecho "Preparing to embed the album art..." >&2
else
vecho "Not embedding album art, you need mp3 output and eyeD3 tagging..." >&2
return 1
fi

if [ -e "cover.jpg" ] ; then
for i in *.mp3
do
eyeD3 --add-image cover.jpg:FRONT_COVER "$i"
done

if [[ "$OUTPUTTYPE" == *"flac"* ]] ; then
vecho "Preparing to embed the album art..." >&2
else
vecho "Not embedding album art, you need flac output.." >&2
return 1
fi

if [ -e "cover.jpg" ] ; then
for i in *.flac
do
metaflac --import-picture-from=cover.jpg "$i"
done

mkdir backup
mv cover.jpg backup
vecho "Your files have had the album art embedded..." >&2
else
vecho "No album art found so no image embedded..." >&2
fi
}

Ve işte çalışan şikayetler abcde:

pi@EMK-RPi2B ~ $ abcde
/etc/abcde.conf: line 512: syntax error at unexpected word `}'
/etc/abcde.conf: line 512: `}'
^[Grabbing entire CD - tracks01 02 03 04 05 06 07 08 09 10 11 12 13 14 15

Burada ne yanlış yaptım? Orada sadece eşleşen bir {}çift ​​var, 512 numaralı hattın şikayeti, }yukarıdaki sonuncusu ...

Yanıtlar:


1

Bunu düzeltin:

if [ -e "cover.jpg" ] ; then
for i in *.mp3
do
eyeD3 --add-image cover.jpg:FRONT_COVER "$i"
done

Açık:

if [ -e "cover.jpg" ] ; then
for i in *.mp3
do
eyeD3 --add-image cover.jpg:FRONT_COVER "$i"
done
fi

Ve bu numara yaptı! Benim açımdan aptalca bir gözetim sanırım. Hızlı yardım için teşekkürler!
emk2203
Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.