Youtube_dl:错误:YouTube 说:无法提取视频数据

新手上路,请多包涵

我正在用 Python 3 制作一个小图形界面,它应该下载一个带有 URL 的 youtube 视频。为此,我使用了 youtube_dl 模块。这是我的代码:

 import youtube_dl # Youtube_dl is used for download the video

ydl_opt = {"outtmpl" : "/videos/%(title)s.%(ext)s", "format": "bestaudio/best"} # Here we give some advanced settings. outtmpl is used to define the path of the video that we are going to download

def operation(link):
    """
    Start the download operation
    """
    try:
        with youtube_dl.YoutubeDL(ydl_opt) as yd: # The method YoutubeDL() take one argument which is a dictionary for changing default settings
            video = yd.download([link]) # Start the download
        result.set("Your video has been downloaded !")
    except Exception:
        result.set("Sorry, we got an error.")

operation("https://youtube.com/watch?v=...")

当我执行我的代码时,出现此错误:

 ERROR: YouTube said: Unable to extract video data

我在 这里 看到是因为没有找到任何视频信息,我该如何解决这个问题?

原文由 Bastien 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.1k
2 个回答

更新 youtube-dl 帮助了我。根据您安装它的方式,以下是命令:

  • youtube-dl --update (自我更新)
  • pip install -U youtube-dl (通过python)
  • brew upgrade youtube-dl (macOS + 自制软件)
  • choco upgrade youtube-dl (Windows + Chocolatey)

原文由 Manoj D Bhat 发布,翻译遵循 CC BY-SA 4.0 许可协议

对于 ubuntu 用户:

 sudo apt purge youtube-dl
sudo pip3 install youtube-dl
hash youtube-dl

原文由 hurelhuyag 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题