youtube-dl从youtube下载mp3的脚本

2020年12月31日

注:转自hostloc社区,作者:嗷嗷

首先要安装python,youtu be-dl和ffmpeg

youtube-dl安装方法:https://www.myzhenai.com.cn/post/2968.html

Linux安装FFmpeg的方法:https://www.myzhenai.com.cn/post/1236.html

Linux和Windows下利用ffmpeg批量转换视频的方法:https://www.myzhenai.com.cn/post/3387.html

cmd="youtube-dl -i -x --audio-format mp3 --embed-thumbnail"
if [ -n "$3" ] ;then
    $cmd --playlist-start $2 --playlist-end $3 $1
elif [ -n "$2" ] ;then
    $cmd --playlist-start $2 $1
elif [ -n "$1" ] ;then
    $cmd $1
else
    echo "Error: no input"
fi

 

把它保存到文件,给权限

cat << EOF > ~/yd.sh
cmd="youtube-dl -i -x --audio-format mp3 --embed-thumbnail"
if [ -n "$3" ] ;then
    $cmd --playlist-start $2 --playlist-end $3 $1
elif [ -n "$2" ] ;then
    $cmd --playlist-start $2 $1
elif [ -n "$1" ] ;then
    $cmd $1
else
    echo "Error: no input"
fi
EOF
#sed -i "s///" ~/yd.sh #这里就是去掉<xxx>
chmod +x ~/yd.sh
下载单个视频是这样用的
    ~/yd.sh 视频链接
下载播放列表是这样用的
    ~/yd.sh 播放列表链接
指定从列表第5个视频开始下载
    ~/yd.sh 播放列表链接 5
指定从列表第5个视频开始第12个视频结束下载
    ~/yd.sh 播放列表链接 5 12

 


sicnature ---------------------------------------------------------------------
Your current IP address is: 34.229.223.223
Your IP address location: 美国弗吉尼亚阿什本
Your IP address country and region: 美国 美国
Your current browser is:
Your current system is:
Original content, please indicate the source:
同福客栈论坛 | 蟒蛇科普海南乡情论坛 | JiaYu Blog
sicnature ---------------------------------------------------------------------
Welcome to reprint. Please indicate the source https://www.myzhenai.com.cn/post/3613.html

1 评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注