gpt4 book ai didi

python - Youtube_dl : ERROR : YouTube said: Unable to extract video data

转载 作者:行者123 更新时间:2023-12-03 06:05:51 31 4
gpt4 key购买 nike

我正在用 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
我看到了 here那是因为它没有找到任何视频信息,我该如何解决这个问题?

最佳答案

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

  • youtube-dl --update (自行更新)
  • pip install -U youtube-dl (通过python)
  • brew upgrade youtube-dl (macOS + 自制软件)
  • choco upgrade youtube-dl (Windows + Chocolatey)
  • 关于python - Youtube_dl : ERROR : YouTube said: Unable to extract video data,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63816790/

    31 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com