Youtube_dl : ERROR : YouTube said: Unable to extract video data(Youtube_dl:错误:YouTube 说:无法提取视频数据)
问题描述
我正在用 Python 3 制作一个小的图形界面,它应该下载一个带有 URL 的 youtube 视频.为此,我使用了 youtube_dl 模块.这是我的代码:
I'm making a little graphic interface with Python 3 which should download a youtube video with its URL.
I used the youtube_dl module for that.
This is my code :
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=...")
当我执行我的代码时,我收到这个错误:
When I execute my code, I get this error:
ERROR: YouTube said: Unable to extract video data
我看到了这里 是因为没有找到任何视频信息,我该如何解决这个问题?
I saw here that it was because it doesn't find any video info, how can I resolve this problem?
推荐答案
更新 youtube-dl 帮助了我.根据您的安装方式,以下是命令:
Updating youtube-dl helped me. Depending on the way you installed it, here are the commands:
youtube-dl --update(自我更新)pip install -U youtube-dl(通过python)brew upgrade youtube-dl(macOS + homebrew)choco upgrade youtube-dl(Windows + Chocolatey)
youtube-dl --update(self-update)pip install -U youtube-dl(via python)brew upgrade youtube-dl(macOS + homebrew)choco upgrade youtube-dl(Windows + Chocolatey)
这篇关于Youtube_dl:错误:YouTube 说:无法提取视频数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Youtube_dl:错误:YouTube 说:无法提取视频数据
基础教程推荐
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
