Ruby youtube-dl.rb KeyError('Ai',)引起的错误

Ruby youtube-dl.rb error caused by KeyError('Ai',)

我一直在使用一个名为 youtube-dl.rb 的 gem,它真的很好用,但几天前它给了我一个错误,我一直无法修复它。

这是我用来测试 gem 的示例代码,因为它一直给我错误:

require 'youtube-dl.rb'
options_mp3 = {
    extract_audio: true,
    audio_format: "mp3",    
    output: '%(title)s.%(ext)s'
}
YoutubeDL.download "https://www.youtube.com/watch?v=bqUZn0gWLk4", options_mp3

这是我得到的错误:

D:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/cocaine-0.5.8/lib/cocaine/command_line.rb:91:in `run': Command 'D:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/youtube-dl.rb-0.3.1.2016.09.11.1/vendor/bin/youtube-dl --output "some_file.mp3" --no-color --no-progress --print-json "https://www.youtube.com/watch?v=bqUZn0gWLk4"' returned 1. Expected 0 (Cocaine::ExitStatusError)
Here is the command output: STDOUT:
STDERR:
ERROR: Signature extraction failed: Traceback (most recent call last):
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpj47q005f\build\youtube_dl\extractor\youtube.py", line 1005, in  _decrypt_signature
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpj47q005f\build\youtube_dl\extractor\youtube.py", line 932, in _extract_signature_function
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpj47q005f\build\youtube_dl\extractor\youtube.py", line 984, in <lambda>
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpj47q005f\build\youtube_dl\jsinterp.py", line 254, in resf
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpj47q005f\build\youtube_dl\jsinterp.py", line 55, in interpret_statement
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpj47q005f\build\youtube_dl\jsinterp.py", line 174, in interpret_expression
KeyError: 'Ai'
(caused by KeyError('Ai',)); 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.
    from D:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/youtube-dl.rb-0.3.1.2016.09.11.1/lib/youtube-dl/runner.rb:62:in `run'
    from D:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/youtube-dl.rb-0.3.1.2016.09.11.1/lib/youtube-dl/video.rb:39:in `download'
    from D:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/youtube-dl.rb-0.3.1.2016.09.11.1/lib/youtube-dl/video.rb:15:in `download'
    from D:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/youtube-dl.rb-0.3.1.2016.09.11.1/lib/youtube-dl.rb:25:in `download'
    from test.rb:12:in `<main>'

每当我在 github 网站上使用示例 youtube link 时,它不会给我一个错误并下载 mp4 格式的视频

YoutubeDL.download "https://www.youtube.com/watch?v=gvdf5n-zI14", output: 'some_file.mp4'

有人知道如何解决这个问题吗?如果没有,关于以不同方式下载 youtube 视频有什么建议吗?

2017 年 1 月 10 日,YouTube 以一种破坏性的方式更换了他们的播放器 youtube-dl。因此,youtube-dl 一直在 updated. Please make sure that you are using youtube-dl 2017.01.10 or newer. Have a look at the updating instructions 如何更新 youtube-dl。