我正在使用abcde
(更好的 CD 编码器)和我的树莓派,并想使用搜索和嵌入专辑封面的新功能。为此,有abcde.conf
一个部分可以让你定义自己的post_encode ()
函数。
来自的一个工作示例http://www.andrews-corner.org/getalbumart.html看起来像这样:
#--------------------------------------------------------------------------#
# 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
}
我希望能够一次性对几种格式执行此操作(abcde 的优势之一),但无法通过一个函数实现全部操作。
这是我的失败的尝试制作一个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
}
以下是关于跑步的抱怨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
我在这里做错了什么?那里只有一{}
对匹配的,对第 512 行的投诉是关于}
上面的最后一个...
答案1
更正此问题:
if [ -e "cover.jpg" ] ; then
for i in *.mp3
do
eyeD3 --add-image cover.jpg:FRONT_COVER "$i"
done
在:
if [ -e "cover.jpg" ] ; then
for i in *.mp3
do
eyeD3 --add-image cover.jpg:FRONT_COVER "$i"
done
fi