i want download video from youtube using youtube-dl library
this my code:
import youtube_dl
video_url = "https://www.youtube.com/watch?v=w9Fcgdlw-Nc"
desired_format = 'mp4'
ydl_opts = {
'format': desired_format,
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([video_url])
But i get this error:
PS C:\Users\sepeh\Desktop\Bot> & "C:/Program Files/Python39/python.exe" c:/Users/sepeh/Desktop/Bot/main.py
[youtube] w9Fcgdlw-Nc: Downloading webpage
ERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\YoutubeDL.py", line 815, in wrapper
return func(self, *args, **kwargs)
File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\YoutubeDL.py", line 836, in __extract_info
ie_result = ie.extract(url)
File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\extractor\common.py", line 534, in extract
ie_result = self._real_extract(url)
File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\extractor\youtube.py", line 1794, in _real_extract
'uploader_id': self._search_regex(r'/(?:channel|user)/([^/?&#]+)', owner_profile_url, 'uploader id') if owner_profile_url else None,
File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\extractor\common.py", line 1012, in _search_regex
raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\sepeh\Desktop\Bot\main.py", line 26, in <module>
ydl.download(["https://www.youtube.com/watch?v=w9Fcgdlw-Nc"])
File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\YoutubeDL.py", line 2068, in download
res = self.extract_info(
File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\YoutubeDL.py", line 808, in extract_info
return self.__extract_info(url, ie, download, extra_info, process)
File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\YoutubeDL.py", line 824, in wrapper
self.report_error(compat_str(e), e.format_traceback())
File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\YoutubeDL.py", line 628, in report_error
self.trouble(error_message, tb)
File "C:\Users\sepeh\AppData\Roaming\Python\Python39\site-packages\youtube_dl\YoutubeDL.py", line 598, in trouble
raise DownloadError(message, exc_info)
youtube_dl.utils.DownloadError: ERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
PS C:\Users\sepeh\Desktop\Bot>
What i do?
When I asked ChatGPT for help, it gave me 2 solutions:
- Upgrading the library
pip install --upgrade youtube-dl - Bug report on the official website of the library
But if there was such a bug, everyone would be involved in it now. I think the problem is on my side...