Youtube - 下载播放列表 - youtube-dl
Youtube - downloading a playlist - youtube-dl
我正在尝试从 playlist 下载所有视频:
我正在为此使用 youtube-dl,命令是:
youtube-dl -citk –format mp4 –yes-playlist https://www.youtube.com/watch?v=7Vy8970q0Xc&list=PLwJ2VKmefmxpUJEGB1ff6yUZ5Zd7Gegn2
但这只会下载第一个视频。不确定我做错了什么。
从url中删除v=...&
部分,只保留list=...
部分。主要问题是特殊字符 &
,由 shell 解释。
您也可以在命令中引用您的'url'。
这里有更多信息(例如):
https://askubuntu.com/questions/564567/how-to-download-playlist-from-youtube-dl
在shell中,&
是一个特殊字符,建议shell在后台启动所有直到&的进程。为避免这种行为,您可以将 URL 放在引号中。有关详细信息,请参阅 youtube-dl FAQ。
还要注意-citk
。除了 -i
,这些选项没有什么意义。有关详细信息,请参阅 youtube-dl FAQ。甚至 -f mp4
看起来也很奇怪。
所以你想要的是:
youtube-dl -i -f mp4 --yes-playlist 'https://www.youtube.com/watch?v=7Vy8970q0Xc&list=PLwJ2VKmefmxpUJEGB1ff6yUZ5Zd7Gegn2'
或者,您可以只使用播放列表 ID:
youtube-dl -i PLwJ2VKmefmxpUJEGB1ff6yUZ5Zd7Gegn2
上面的方法我都试过了,但是none可以解决我的问题。我通过更新旧版本的 youtube-dl 来下载播放列表来修复它。
更新它
sudo youtube-dl -U
或
youtube-dl -U
使用上述命令成功更新后
youtube-dl -cit https://www.youtube.com/playlist?list=PLttJ4RON7sleuL8wDpxbKHbSJ7BH4vvCk
经过多次尝试解决这个问题,我找到了最佳解决方案。
安装与使用;
Windows 用户:
脚本:
youtube-dl --ignore-errors --format bestaudio --extract-audio --audio-format mp3 --audio-quality 160K --output "%(title)s.%(ext)s" --yes-playlist https://www.youtube.com/playlist?list={your-youtube-playlist-id}
- 从 the offical site 下载 youtube-dl.exe 文件。
- 从 the offical site for convert WebM to MP3 (Recomended build version)
下载 ffmpeg
- 解压缩所有 zip 文件并将 youtube-dl.exe、ffmpeg.exe 和 ffprobe.exe 文件移动到您要下载 MP3 文件的文件夹。
- 在同一文件夹中打开 cmd(Windows 终端)。
- 将脚本
{your-youtube-playlist-id}
参数替换为您的 YouTube 播放列表 ID。
- 运行 脚本。
macOS/Linux 用户:
脚本:
youtube-dl --ignore-errors --format bestaudio --extract-audio --audio-format mp3 --audio-quality 160K --output "%(title)s.%(ext)s" --yes-playlist 'https://www.youtube.com/playlist?list={your-youtube-playlist-id}'
- 打开终端,如果您没有Homebrew,请安装它。 (Linux 用户可以跳过此步骤。)
- 运行
brew install youtube-dl ffmpeg
并安装 youtube-dl 和 ffmpeg 以将 WebM 转换为 MP3。 (安装其他依赖项可能需要更长的时间。)(对于 Linux 用户:install youtube-dl ffmpeg
)
- 在要下载 MP3 文件的文件夹中打开一个终端。
- 将脚本
{your-youtube-playlist-id}
参数替换为您的 YouTube 播放列表 ID。
- 运行 脚本。
您的 link 不是播放列表。
合适的播放列表 URL 如下所示:
https://www.youtube.com/playlist?list=PLHSdFJ8BDqEyvUUzm6R0HxawSWniP2c9K
您的 URL 只是某个播放列表 的第一个视频。它包含 https://www.youtube.com/watch?
而不是 https://www.youtube.com/playlist?
.
通过单击视频列表右侧播放列表的标题来选择播放列表,然后使用此 URL。
最简单的方法是创建一个 file.txt
文件并传递 link url link 所以:
https://www.youtube.com/watch?v=5Lj1BF0Kn8c&list=PL9YFoJnn53xyf9GNZrtiraspAIKc80s1i
确保在终端中包含 -a
参数:
youtube-dl -a file.txt
下载播放列表时可能有用的一些命令
下载播放列表
youtube-dl <playlist link>
最佳质量视频和最佳质量音频(合并)+ 首选分辨率
youtube-dl -f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]' <playlist link>
This command will download videos in 1080p resolution if 1080p is available otherwise it will download the next best (less than 1080p) resolution. Here, You can use 480 or 720, etc instead of 1080.
Note: Make sure that ‘FFmpeg’ is installed, otherwise video and audio will not be merged.
最佳质量视频和最佳质量音频(合并)+首选分辨率+在文件名上添加视频上传日期
youtube-dl -o "[%(upload_date)s] %(title)s.%(ext)s" -f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]' <playlist link>
最佳质量视频和最佳质量音频(合并)+首选分辨率+在文件名上添加视频上传日期+在文件名上添加上传者姓名
youtube-dl -o "[%(upload_date)s] %(title)s [%(uploader)s].%(ext)s" -f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]' <playlist link>
Subtitle
最佳质量视频和最佳质量音频(合并)+ 首选分辨率 + 下载自动生成的字幕
youtube-dl --write-auto-sub -f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]' <playlist link>
最佳质量视频和最佳质量音频(合并)+首选分辨率+下载视频创作者上传的字幕
youtube-dl --write-sub -f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]' <playlist link>
最佳质量视频和最佳质量音频合并 + 首选分辨率 + 下载视频创作者上传的特定语言的字幕
youtube-dl --write-sub --sub-lang en -f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]' <playlist link>
基本上,解决这个问题的方法很简单,就是用它的编码版本 %26
替换 &
符号
对于那些在通过 PHP(例如 shell_exec()
)解决这个问题的人来说,解决方案可能是
str_replace("&", "%26", $shell_command);
我正在尝试从 playlist 下载所有视频:
我正在为此使用 youtube-dl,命令是:
youtube-dl -citk –format mp4 –yes-playlist https://www.youtube.com/watch?v=7Vy8970q0Xc&list=PLwJ2VKmefmxpUJEGB1ff6yUZ5Zd7Gegn2
但这只会下载第一个视频。不确定我做错了什么。
从url中删除v=...&
部分,只保留list=...
部分。主要问题是特殊字符 &
,由 shell 解释。
您也可以在命令中引用您的'url'。
这里有更多信息(例如):
https://askubuntu.com/questions/564567/how-to-download-playlist-from-youtube-dl
在shell中,&
是一个特殊字符,建议shell在后台启动所有直到&的进程。为避免这种行为,您可以将 URL 放在引号中。有关详细信息,请参阅 youtube-dl FAQ。
还要注意-citk
。除了 -i
,这些选项没有什么意义。有关详细信息,请参阅 youtube-dl FAQ。甚至 -f mp4
看起来也很奇怪。
所以你想要的是:
youtube-dl -i -f mp4 --yes-playlist 'https://www.youtube.com/watch?v=7Vy8970q0Xc&list=PLwJ2VKmefmxpUJEGB1ff6yUZ5Zd7Gegn2'
或者,您可以只使用播放列表 ID:
youtube-dl -i PLwJ2VKmefmxpUJEGB1ff6yUZ5Zd7Gegn2
上面的方法我都试过了,但是none可以解决我的问题。我通过更新旧版本的 youtube-dl 来下载播放列表来修复它。 更新它
sudo youtube-dl -U
或
youtube-dl -U
使用上述命令成功更新后
youtube-dl -cit https://www.youtube.com/playlist?list=PLttJ4RON7sleuL8wDpxbKHbSJ7BH4vvCk
经过多次尝试解决这个问题,我找到了最佳解决方案。
安装与使用;
Windows 用户:
脚本:
youtube-dl --ignore-errors --format bestaudio --extract-audio --audio-format mp3 --audio-quality 160K --output "%(title)s.%(ext)s" --yes-playlist https://www.youtube.com/playlist?list={your-youtube-playlist-id}
- 从 the offical site 下载 youtube-dl.exe 文件。
- 从 the offical site for convert WebM to MP3 (Recomended build version) 下载 ffmpeg
- 解压缩所有 zip 文件并将 youtube-dl.exe、ffmpeg.exe 和 ffprobe.exe 文件移动到您要下载 MP3 文件的文件夹。
- 在同一文件夹中打开 cmd(Windows 终端)。
- 将脚本
{your-youtube-playlist-id}
参数替换为您的 YouTube 播放列表 ID。 - 运行 脚本。
macOS/Linux 用户:
脚本:
youtube-dl --ignore-errors --format bestaudio --extract-audio --audio-format mp3 --audio-quality 160K --output "%(title)s.%(ext)s" --yes-playlist 'https://www.youtube.com/playlist?list={your-youtube-playlist-id}'
- 打开终端,如果您没有Homebrew,请安装它。 (Linux 用户可以跳过此步骤。)
- 运行
brew install youtube-dl ffmpeg
并安装 youtube-dl 和 ffmpeg 以将 WebM 转换为 MP3。 (安装其他依赖项可能需要更长的时间。)(对于 Linux 用户:install youtube-dl ffmpeg
) - 在要下载 MP3 文件的文件夹中打开一个终端。
- 将脚本
{your-youtube-playlist-id}
参数替换为您的 YouTube 播放列表 ID。 - 运行 脚本。
您的 link 不是播放列表。
合适的播放列表 URL 如下所示:
https://www.youtube.com/playlist?list=PLHSdFJ8BDqEyvUUzm6R0HxawSWniP2c9K
您的 URL 只是某个播放列表 的第一个视频。它包含 https://www.youtube.com/watch?
而不是 https://www.youtube.com/playlist?
.
通过单击视频列表右侧播放列表的标题来选择播放列表,然后使用此 URL。
最简单的方法是创建一个 file.txt
文件并传递 link url link 所以:
https://www.youtube.com/watch?v=5Lj1BF0Kn8c&list=PL9YFoJnn53xyf9GNZrtiraspAIKc80s1i
确保在终端中包含 -a
参数:
youtube-dl -a file.txt
下载播放列表时可能有用的一些命令
下载播放列表
youtube-dl <playlist link>
最佳质量视频和最佳质量音频(合并)+ 首选分辨率
youtube-dl -f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]' <playlist link>
This command will download videos in 1080p resolution if 1080p is available otherwise it will download the next best (less than 1080p) resolution. Here, You can use 480 or 720, etc instead of 1080.
Note: Make sure that ‘FFmpeg’ is installed, otherwise video and audio will not be merged.
最佳质量视频和最佳质量音频(合并)+首选分辨率+在文件名上添加视频上传日期
youtube-dl -o "[%(upload_date)s] %(title)s.%(ext)s" -f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]' <playlist link>
最佳质量视频和最佳质量音频(合并)+首选分辨率+在文件名上添加视频上传日期+在文件名上添加上传者姓名
youtube-dl -o "[%(upload_date)s] %(title)s [%(uploader)s].%(ext)s" -f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]' <playlist link>
Subtitle
最佳质量视频和最佳质量音频(合并)+ 首选分辨率 + 下载自动生成的字幕
youtube-dl --write-auto-sub -f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]' <playlist link>
最佳质量视频和最佳质量音频(合并)+首选分辨率+下载视频创作者上传的字幕
youtube-dl --write-sub -f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]' <playlist link>
最佳质量视频和最佳质量音频合并 + 首选分辨率 + 下载视频创作者上传的特定语言的字幕
youtube-dl --write-sub --sub-lang en -f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]' <playlist link>
基本上,解决这个问题的方法很简单,就是用它的编码版本 %26
&
符号
对于那些在通过 PHP(例如 shell_exec()
)解决这个问题的人来说,解决方案可能是
str_replace("&", "%26", $shell_command);