为什么用youtube-dl只能在bilibili上下载第一集视频?
Why can only download the first episode video on bilibili with youtube-dl?
我可以下载系列的第一集。
yutube-dl https://www.bilibili.com/video/av90163846?p=1
现在我想下载该系列的所有剧集。
for i in $(seq 1 55)
do
yutube-dl https://www.bilibili.com/video/av90163846?p=$i
done
除第一集以外的所有其他剧集都无法下载,它们都包含相同的错误信息,如下所示:
[BiliBili] 90163846: Downloading webpage
[BiliBili] 90163846: Downloading video info page
[download] 【合集300集全】地道美音 美国中小学教学 自然科学 社会常识-90163846.flv has already been downloaded
请尝试检查会发生什么,然后如何解决?
@Christos Lytras,你的代码发生了奇怪的事情:
for i in $(seq 1 55)
do
youtube-dl https://www.bilibili.com/video/av90163846?p=$i -o "%(title)s-%(id)s-$i.%(ext)s"
done
确实可以在bilibili上下载视频,但是下载的视频都是不同的名称和相同的内容,所有的内容都和第一集一样,试一试,你会发现事实。
发生此错误是因为 youtube-dl
忽略文件名 ?
之后的 URI 参数,因此它尝试下载的下一个文件与前一个文件同名,但失败,因为文件已经以那个名字存在。解决方案是使用 --output
模板文件系统选项设置一个文件名,使用变量 i
.
-o, --output TEMPLATE Output filename template, see the "OUTPUT
TEMPLATE" for all the info
The -o
option allows users to indicate a
template for the output file names.
The basic usage is not to set any template arguments when downloading
a single file, like in youtube-dl -o funny_video.flv "https://some/video"
. However, it may contain special sequences that
will be replaced when downloading each video. The special sequences
may be formatted according to python string formatting operations. For
example, %(NAME)s
or %(NAME)05d
. To clarify, that is a percent symbol
followed by a name in parentheses, followed by formatting operations.
Allowed names along with sequence type are:
id
(string): Video identifier
title
(string): Video title
url
(string): Video URL
ext
(string): Video filename extension
...
对于您的情况,要在输出文件名中使用 i
,您可以使用如下内容:
for i in $(seq 1 55)
do
youtube-dl https://www.bilibili.com/video/av90163846?p=$i -o "%(title)s-%(id)s-$i.%(ext)s"
done
它将使用 title
id
i
变量进行索引,ext
进行视频扩展。
您可以检查 Output Template 变量以获得更多定义文件名的选项。
更新
显然,bilibili.com 有一些 Javascript 涉及设置视频播放器和获取视频文件。您无法使用 youtube-dl
提取整个播放列表。我建议您开箱即用 Annie which supports Bilibili playlists 。它具有适用于所有主要操作系统的安装程序,您可以像这样使用它来下载整个播放列表:
annie -p https://www.bilibili.com/video/av90163846
of 如果您只想下载 55 个视频,您可以使用 -end 55
cli 选项,如下所示:
annie -end 55 -p https://www.bilibili.com/video/av90163846
You can use the -start
, -end
or -items
option to specify the download
range of the list:
-start
Playlist video to start at (default 1)
-end
Playlist video to end at
-items
Playlist video items to download. Separated by commas like: 1,5,6,8-10
For bilibili playlists only:
-eto
File name of each bilibili episode doesn't include the playlist title
如果您只想获取播放列表的信息而不下载文件,请使用 -i
命令行选项,如下所示:
annie -i -p https://www.bilibili.com/video/av90163846
将输出如下内容:
Site: 哔哩哔哩 bilibili.com
Title: 【合集300集全】地道美音 美国中小学教学 自然科学 社会常识 P1 【001】Parts of Plants
Type: video
Streams: # All available quality
[64] -------------------
Quality: 高清 720P
Size: 308.24 MiB (323215935 Bytes)
# download with: annie -f 64 ...
[32] -------------------
Quality: 清晰 480P
Size: 201.57 MiB (211361230 Bytes)
# download with: annie -f 32 ...
[16] -------------------
Quality: 流畅 360P
Size: 124.75 MiB (130809508 Bytes)
# download with: annie -f 16 ...
Site: 哔哩哔哩 bilibili.com
Title: 【合集300集全】地道美音 美国中小学教学 自然科学 社会常识 P2 【002】Life Cycle of a Plant
Type: video
Streams: # All available quality
[64] -------------------
Quality: 高清 720P
Size: 227.75 MiB (238809781 Bytes)
# download with: annie -f 64 ...
[32] -------------------
Quality: 清晰 480P
Size: 148.96 MiB (156191413 Bytes)
# download with: annie -f 32 ...
[16] -------------------
Quality: 流畅 360P
Size: 94.82 MiB (99425641 Bytes)
# download with: annie -f 16 ...
我可以下载系列的第一集。
yutube-dl https://www.bilibili.com/video/av90163846?p=1
现在我想下载该系列的所有剧集。
for i in $(seq 1 55)
do
yutube-dl https://www.bilibili.com/video/av90163846?p=$i
done
除第一集以外的所有其他剧集都无法下载,它们都包含相同的错误信息,如下所示:
[BiliBili] 90163846: Downloading webpage
[BiliBili] 90163846: Downloading video info page
[download] 【合集300集全】地道美音 美国中小学教学 自然科学 社会常识-90163846.flv has already been downloaded
请尝试检查会发生什么,然后如何解决?
@Christos Lytras,你的代码发生了奇怪的事情:
for i in $(seq 1 55)
do
youtube-dl https://www.bilibili.com/video/av90163846?p=$i -o "%(title)s-%(id)s-$i.%(ext)s"
done
确实可以在bilibili上下载视频,但是下载的视频都是不同的名称和相同的内容,所有的内容都和第一集一样,试一试,你会发现事实。
发生此错误是因为 youtube-dl
忽略文件名 ?
之后的 URI 参数,因此它尝试下载的下一个文件与前一个文件同名,但失败,因为文件已经以那个名字存在。解决方案是使用 --output
模板文件系统选项设置一个文件名,使用变量 i
.
-o, --output TEMPLATE Output filename template, see the "OUTPUT TEMPLATE" for all the info
The
-o
option allows users to indicate a template for the output file names.The basic usage is not to set any template arguments when downloading a single file, like in
youtube-dl -o funny_video.flv "https://some/video"
. However, it may contain special sequences that will be replaced when downloading each video. The special sequences may be formatted according to python string formatting operations. For example,%(NAME)s
or%(NAME)05d
. To clarify, that is a percent symbol followed by a name in parentheses, followed by formatting operations. Allowed names along with sequence type are:
id
(string): Video identifier
title
(string): Video title
url
(string): Video URL
ext
(string): Video filename extension
...
对于您的情况,要在输出文件名中使用 i
,您可以使用如下内容:
for i in $(seq 1 55)
do
youtube-dl https://www.bilibili.com/video/av90163846?p=$i -o "%(title)s-%(id)s-$i.%(ext)s"
done
它将使用 title
id
i
变量进行索引,ext
进行视频扩展。
您可以检查 Output Template 变量以获得更多定义文件名的选项。
更新
显然,bilibili.com 有一些 Javascript 涉及设置视频播放器和获取视频文件。您无法使用 youtube-dl
提取整个播放列表。我建议您开箱即用 Annie which supports Bilibili playlists 。它具有适用于所有主要操作系统的安装程序,您可以像这样使用它来下载整个播放列表:
annie -p https://www.bilibili.com/video/av90163846
of 如果您只想下载 55 个视频,您可以使用 -end 55
cli 选项,如下所示:
annie -end 55 -p https://www.bilibili.com/video/av90163846
You can use the
-start
,-end
or-items
option to specify the download range of the list:-start Playlist video to start at (default 1) -end Playlist video to end at -items Playlist video items to download. Separated by commas like: 1,5,6,8-10
For bilibili playlists only:
-eto File name of each bilibili episode doesn't include the playlist title
如果您只想获取播放列表的信息而不下载文件,请使用 -i
命令行选项,如下所示:
annie -i -p https://www.bilibili.com/video/av90163846
将输出如下内容:
Site: 哔哩哔哩 bilibili.com
Title: 【合集300集全】地道美音 美国中小学教学 自然科学 社会常识 P1 【001】Parts of Plants
Type: video
Streams: # All available quality
[64] -------------------
Quality: 高清 720P
Size: 308.24 MiB (323215935 Bytes)
# download with: annie -f 64 ...
[32] -------------------
Quality: 清晰 480P
Size: 201.57 MiB (211361230 Bytes)
# download with: annie -f 32 ...
[16] -------------------
Quality: 流畅 360P
Size: 124.75 MiB (130809508 Bytes)
# download with: annie -f 16 ...
Site: 哔哩哔哩 bilibili.com
Title: 【合集300集全】地道美音 美国中小学教学 自然科学 社会常识 P2 【002】Life Cycle of a Plant
Type: video
Streams: # All available quality
[64] -------------------
Quality: 高清 720P
Size: 227.75 MiB (238809781 Bytes)
# download with: annie -f 64 ...
[32] -------------------
Quality: 清晰 480P
Size: 148.96 MiB (156191413 Bytes)
# download with: annie -f 32 ...
[16] -------------------
Quality: 流畅 360P
Size: 94.82 MiB (99425641 Bytes)
# download with: annie -f 16 ...