youtube-dl 提取签名失败

使用youtube-dl软件下载YouTube被认为非常有用。
出现了一条消息,它停止工作,具体如下。
ERROR: Signature extraction failed: Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/youtube.py", line 479, in _decrypt_signature
    video_id, player_url, s
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/youtube.py", line 383, in _extract_signature_function
    res = self._parse_sig_js(code)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/youtube.py", line 454, in _parse_sig_js
    u'Initial JS player signature function name')
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/common.py", line 391, in _search_regex
    raise RegexNotFoundError(u'Unable to extract %s' % _name)
RegexNotFoundError: Unable to extract Initial JS player signature function name; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type  youtube-dl -U  to update.
; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type  youtube-dl -U  to update.

我应该怎么做才能继续进行?

1在消息中明确指出:“请在https://yt-dl.org/bug上报告此问题”。那为什么不这样做呢? - Rinzwind
3请确保您正在使用最新版本;输入“youtube-dl -U”以进行更新。您已经这样做了吗? - David Foerster
亲爱的David Foerster,我尝试了一下,收到了一条消息:“看起来你是通过包管理器、pip、setup.py或者tarball安装了youtube-dl。请使用它们来进行更新。” - Ohmygirl
2@HELLOVENUS 你说得对,youtube-dl -U 不再起作用了。更新 youtube-dl 到最新版本的说明在这里:youtube-dl is not working。顺便说一下,如果你使用 pip install --upgrade youtube-dl 而不是 pip install --upgrade youtube_dl,也可以正常工作,并且在 Python 虚拟环境中进行本地安装(即不使用 sudo)也是可行的。 - karel
6个回答

你遇到了这个错误:
Unable to extract Initial JS player signature function name

由于youtube-dl不是最新版本。谷歌现在比几年前更频繁地改变访问YouTube视频的方式,为了保持youtube-dl的最新状态,它也需要更频繁地更新。要安装最新版本的youtube-dl,请打开终端并输入:

sudo snap install youtube-dl # start with snap run youtube-dl 

或者:

sudo apt remove youtube-dl  
sudo apt install python3-pip
python3 -m pip install youtube-dl

升级youtube-dl到最新版本:
sudo snap install youtube-dl # youtube-dl snap is automatically upgraded 

或者

python3 -m pip install --upgrade youtube-dl    

谷歌频繁更改访问YouTube视频的代码,这真是太疯狂了。我记得只有几个月前更新了youtube-dl,但直到我更新它之后,它才能下载选定的视频。

youtube-dl是一个Python程序,因此您也可以在Python虚拟环境中本地安装最新版本的youtube-dl。有关如何设置和使用Python虚拟环境的信息,请参见如何在Ubuntu中设置和使用虚拟Python环境?


对我来说没用 :-( - Philippe Gachoud
2对我来说,首先我需要卸载掉"sudo apt-get remove youtube-dl",然后使用pip命令进行安装。 - Diego Andrés Díaz Espinoza

我唯一能让它正常工作的方法是使用最新版本(对于我来说是debian上的版本)。
sudo wget https://yt-dl.org/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+x /usr/local/bin/youtube-dl
hash -r

GitHub 仓库

我之前也遇到过同样的问题,这个方法解决了它。
 sudo -H pip install --upgrade youtube-dl

尝试将链接放入“link”中。

稍微修改了一下工作方式:sudo -H python3 -m pip install --upgrade youtube-dl - KrisWebDev

这件事曾经发生在我身上。正如评论中所说,你必须更新你的系统或者只是更新youtube-dl。此外,在这个例子中使用引号也是很好的做法。
youtube-dl "https://www.youtube.com/watch?v=n6AL-WpgoFw"

你在帖子中使用的这个字符 ¨ 是不可见的。请将其替换为 '". - afzalex
对我来说很有效 ;) - Prateek Joshi

只有这种方式对我有效!

每次我听新音乐时,总是会跳舞,这里是如何从pip安装youtube-dl。

如果您从repo安装它,则无法下载音乐,总是抱怨!因此,请使用此方法来下载海绵宝宝放松杰作:

!pip install --upgrade youtube-dl 
!youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=oq526_37wc0

这些答案对我都没用。我通过使用错误中给出的指令来解决了这个问题:
sudo youtube-dl -U
我不知道为什么这种更新方式有效,而那个升级命令不行。

在Ubuntu 18.04上,sudo youtube-dl -U无法正常工作。它给出了以下结果:sudo youtube-dl -U Usage: youtube-dl [OPTIONS] URL [URL...] youtube-dl: error: youtube-dl's self-update mechanism is disabled on Debian. Please update youtube-dl using apt(8). See https://packages.debian.org/sid/youtube-dl for the latest packaged version.然而,在18.04上,sudo snap install youtube-dl-casept是可以正常工作的。 - karel