我已修改此脚本以从 YouTube 下载歌曲,但是当我像这样运行它时出现以下错误:
sh youtube2mp3.sh https://www.youtube.com/watch?v=gpOJ6iu8fqQ
错误:
youtube2mp3.sh: line 31: [: too many arguments
youtube2mp3.sh: line 39: [: too many arguments
youtube2mp3.sh: line 49: [: too many arguments
Sorry but the system encountered a problem.
行号指的是if [ -f $video_title.$ext1 ]
三行......我认为我的论点在以前的版本中可以正常工作,但我被困在这一点上 - 有人可以解释我需要做些什么来纠正它吗?
address=$1
video_title="$(python youtube-dl $address)"
ext1="flv"
ext2="mp4"
ext3="webm"
if [ -f $video_title.$ext1 ]
then
ffmpeg -i $video_title.$ext1 "$video_title".wav
lame "$video_title".wav "$video_title".mp3
rm $video_title.$ext1 "$video_title".wav
else
if [ -f $video_title.$ext2 ]
then
ffmpeg -i $video_title.$ext2 "$video_title".wav
lame "$video_title".wav "$video_title".mp3
rm $video_title.$ext2 "$video_title".wav
else
if [ -f $video_title.$ext3 ]
then
ffmpeg -i $video_title.$ext3 -acodec libmp3lame -aq 4 "$video_title".mp3
rm $video_title.$ext3
else
echo "Sorry but the system encountered a problem."
fi
fi
fi