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

Bastien picture Bastien · Sep 9, 2020 · Viewed 72.3k times · Source

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.

Answer

Manoj D Bhat picture Manoj D Bhat · Dec 10, 2020

Updating youtube-dl helped me. Depending on the way you installed it, here are the commands:

  • youtube-dl --update (self-update)
  • pip install -U youtube-dl (via python)
  • brew upgrade youtube-dl (macOS + homebrew)
  • choco upgrade youtube-dl (Windows + Chocolatey)