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

北慕城南 提交于 2021-01-02 05:35:43

问题


I'm making a little graphic interface with Python 3 which should download a youtube video with it URL. I use for that the module youtube_dl. 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 somewhere that it was because they don't find any video info (https://github.com/ytdl-org/youtube-dl/blob/d4f53af482cc47b0473a3576da7ad902bea4ac39/youtube_dl/extractor/youtube.py#L1831), but I don't find any solution to resolve this problem. Thank's by advance for helping me.


回答1:


Updating youtube-dl helped me: youtube-dl --update




回答2:


You could try adding a cookie file as some videos are age restricted. Use this plugin Chrome plugin Cookie.txt to download your cookies in a txt file then use these --cookies /path/to/cookies/file.txt flags not forgetting to put the right path to the file of your cookies.txt.

Sample:

youtube-dl -n --cookies ~/Downloads/cookies.txt https://www.youtube.com/watch\?v\=h7Ii7KKapig

Surce




回答3:


I had the same error on Ubuntu 20.04. I solved it by updating youtube-dl by downloading a .deb from: https://packages.debian.org/sid/all/youtube-dl/download

Though you can also get the update on youtube-dl's official site.




回答4:


If you are using youtube-dl command line on MacOsx update using this command :

sudo youtube-dl --update



来源:https://stackoverflow.com/questions/63816790/youtube-dl-error-youtube-said-unable-to-extract-video-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!