无法使用 youtube-dl 或 annie 从 Bilibili 下载视频

无法使用 youtube-dl 或 annie 从 Bilibili 下载视频

所以我尝试使用 annie 从 Bilibili 下载视频。我最初选择了 youtube-dl,但不幸的是它似乎不支持 Bilibili 网站,所以我选择了 annie,按照Reddit 用户 但尽管如此,我使用 Annie 似乎也没有运气。我想知道这是因为 Bilibili 更新了他们的机制还是我在某个地方犯了错误。这是代码。

apple@apples-MacBook-Pro ~ % annie "https://www.bilibili.com/s/video/BV1TD4y1R7k2"
Downloading https://www.bilibili.com/s/video/BV1TD4y1R7k2 error:
this page has no playlist
apple@apples-MacBook-Pro ~ % 

此外,youtube-dl 声称它支持比利比利我当然记得不久前使用 youtube-dl 下载了 Bilibili 的视频。那么发生了什么。Bilibili 更新了他们的代码吗?

apple@apples-MacBook-Pro ~ % youtube-dl "https://www.bilibili.com/video/av90163846?p=1"
[BiliBili] 90163846: Downloading webpage
[BiliBili] 90163846: Downloading video info page
WARNING: Unable to download JSON metadata: HTTP Error 412: Precondition Failed
[BiliBili] 90163846: Downloading video info page
ERROR: Unable to download JSON metadata: HTTP Error 412: Precondition Failed (caused by 
HTTPError()); please report this issue on https://yt-dl.org/bug . Make sure you are using 
the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the -- 
verbose flag and include its complete output.
apple@apples-MacBook-Pro ~ % 

编辑:如果有帮助的话,这里是调试日志。

 apple@192 ~ % youtube-dl -v "https://bilibili.com/video/BV1TD4y1R7k2"         
[debug] System config: [u'--format', u'mp4', u'-o', u'~/Desktop/%(title)s.%(ext)s', u'--write-sub', u'--embed-subs']
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'https://bilibili.com/video/BV1TD4y1R7k2']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2021.03.14
[debug] Python version 2.7.16 (CPython) - Darwin-20.3.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 4.3.1, ffprobe 4.3.1, rtmpdump 2.4
[debug] Proxy map: {}
[BiliBili] 1TD4y1R7k2: Downloading webpage
[BiliBili] 1TD4y1R7k2: Downloading video info page
ERROR: requested format not available
Traceback (most recent call last):
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 806, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 838, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 872, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1675, in process_video_result
    expected=True)
ExtractorError: requested format not available

apple@192 ~ % 

答案1

要解决此问题,您需要做两件事:

  1. 升级到 youtube-dl 的当前版本。Bilibili 提取器最后一次更改是在 2021 年 3 月 8 日,当我使用旧版本进行测试时,它不起作用
  2. 使用看起来像https://www.bilibili.com/video/BV1TD4y1R7k2youtube-dl 的输入的 Bilibili URL。不要使用像第一个示例那样的 Bilibili URL,因为它有/秒/在其中。因此https://www.bilibili.com/s/video/BV1TD4y1R7k2,您应该使用https://www.bilibili.com/video/BV1TD4y1R7k2

答案2

在命令中添加以下内容

--add-header 接受:'/

相关内容