Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 838
Bastien Avatar asked Sep 09 '20 17:09

Bastien


3 Answers

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)
like image 116
Manoj D Bhat Avatar answered Oct 17 '22 03:10

Manoj D Bhat


For ubuntu users:

sudo apt purge youtube-dl 
sudo pip3 install youtube-dl
hash youtube-dl
like image 25
hurelhuyag Avatar answered Oct 17 '22 01:10

hurelhuyag


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.

like image 13
Andrés Heras Avatar answered Oct 17 '22 01:10

Andrés Heras