Technical questionAccepted answer
Youtube_dl : ERROR : YouTube said: Unable to extract video data
Bastien
Sep 9
0 views1
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?
1 answer
Accepted answer · original discussion
Manoj D Bhat
PermalinkDec 10
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)
3 question comments
Use comments to ask for clarification. Post a solution as an answer.
Solebay SharpPermalink
Sep 9
You will get more traction with this question if you are able to boil it down a bit to the specific section that is throwing this error. I’m often worried about not including enough data but people are generally more likely to engage if its a simple question, versus something which at first glance looks like ‘do this for me’. I’m not casting any aspersions about you, but people will click, glance, and hit back on these quite a lot.
Minion JimPermalink
Sep 10
I just tested your code and it works except for the fact that the url is wrong. Firstly, you misspelt
https (you have htps) and second it should be /watch rather than ?watch so your operation call line would become operation("https://youtube.com/watch?v=..."). I assume this is just a typo with the question, but I hope this resolves it (I could not reproduce your error)