yt-dlp: Cannot download video from udemy
Hi there,
I got 403 error when downloading course from udemy business. I used command:
yt-dlp -u udemy@abc.com -p password -P '~/Downloads' -o '%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s' https://abc.udemy.com/course/ielts-vocab-builder-002/
I’m sure that the username/password in command is correct. Please see the log:
[debug] Command-line config: ['-u', 'PRIVATE', '-p', 'PRIVATE', '-P', "'~/Downloads'", '-o', "'%(playlist)s/%(chapter_number)s", '-', "%(chapter)s/%(title)s.%(ext)s'", 'https://abc.udemy.com/course/ielts-vocab-builder-002/', '-v']
[debug] Encodings: locale cp1252, fs utf-8, out utf-8, pref cp1252
[debug] yt-dlp version 2021.09.25 (exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-10-10.0.18363-SP0
[debug] exe versions: none
[debug] Optional libraries: Crypto, mutagen, sqlite, websockets
[debug] Proxy map: {}
[debug] [generic] Extracting URL: -
ERROR: [generic] '-' is not a valid URL. Set --default-search "ytsearch" (or run yt-dlp "ytsearch:-" ) to search YouTube
Traceback (most recent call last):
File "yt_dlp\extractor\common.py", line 585, in extract
File "yt_dlp\extractor\generic.py", line 2490, in _real_extract
yt_dlp.utils.ExtractorError: '-' is not a valid URL. Set --default-search "ytsearch" (or run yt-dlp "ytsearch:-" ) to search YouTube
Traceback (most recent call last):
File "yt_dlp\extractor\common.py", line 585, in extract
File "yt_dlp\extractor\generic.py", line 2490, in _real_extract
yt_dlp.utils.ExtractorError: '-' is not a valid URL. Set --default-search "ytsearch" (or run yt-dlp "ytsearch:-" ) to search YouTube
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "yt_dlp\YoutubeDL.py", line 1227, in wrapper
File "yt_dlp\YoutubeDL.py", line 1252, in __extract_info
File "yt_dlp\extractor\common.py", line 601, in extract
yt_dlp.utils.ExtractorError: [generic] '-' is not a valid URL. Set --default-search "ytsearch" (or run yt-dlp "ytsearch:-" ) to search YouTube
[debug] [generic] Extracting URL: %(chapter)s/%(title)s.%(ext)s'
ERROR: [generic] "%(chapter)s/%(title)s.%(ext)s'" is not a valid URL. Set --default-search "ytsearch" (or run yt-dlp "ytsearch:%(chapter)s/%(title)s.%(ext)s'" ) to search YouTube
Traceback (most recent call last):
File "yt_dlp\extractor\common.py", line 585, in extract
File "yt_dlp\extractor\generic.py", line 2490, in _real_extract
yt_dlp.utils.ExtractorError: "%(chapter)s/%(title)s.%(ext)s'" is not a valid URL. Set --default-search "ytsearch" (or run yt-dlp "ytsearch:%(chapter)s/%(title)s.%(ext)s'" ) to search YouTube
Traceback (most recent call last):
File "yt_dlp\extractor\common.py", line 585, in extract
File "yt_dlp\extractor\generic.py", line 2490, in _real_extract
yt_dlp.utils.ExtractorError: "%(chapter)s/%(title)s.%(ext)s'" is not a valid URL. Set --default-search "ytsearch" (or run yt-dlp "ytsearch:%(chapter)s/%(title)s.%(ext)s'" ) to search YouTube
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "yt_dlp\YoutubeDL.py", line 1227, in wrapper
File "yt_dlp\YoutubeDL.py", line 1252, in __extract_info
File "yt_dlp\extractor\common.py", line 601, in extract
yt_dlp.utils.ExtractorError: [generic] "%(chapter)s/%(title)s.%(ext)s'" is not a valid URL. Set --default-search "ytsearch" (or run yt-dlp "ytsearch:%(chapter)s/%(title)s.%(ext)s'" ) to search YouTube
[udemy:course] Downloading login popup
ERROR: [udemy:course] course: Unable to download webpage: HTTP Error 403: Forbidden (caused by <HTTPError 403: 'Forbidden'>); please report this issue on https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see https://github.com/yt-dlp/yt-dlp on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
File "yt_dlp\extractor\common.py", line 694, in _request_webpage
File "yt_dlp\YoutubeDL.py", line 3256, in urlopen
File "urllib\request.py", line 531, in open
File "urllib\request.py", line 640, in http_response
File "urllib\request.py", line 569, in error
File "urllib\request.py", line 502, in _call_chain
File "urllib\request.py", line 649, in http_error_default
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 16
- Comments: 28 (3 by maintainers)
I was just playing around with this and found a simple work-around, namely
--cookies-from-browser firefox
I don’t know that firefox is a necessary argument, but I think the cloudflare issue must be getting proc’d by some difference in
--cookies-from-browser
and--cookies
. It seems plausible udemy may be directly parsing the cookies files for the header linesI have not tried to modify the netscape-formatted cookies file to see if it changes behavior, just a shot in the dark.
Account shared. Answer from pukkandan: Cloudflare captcha is causing the issue. Will need to investigate further to find a solution
The workaround from @gamedazed provided few days ago does not work for me. Also it seems that Udemy Business is using AWS CloudFront now. It stopped working all of a sudden around May 14th / May 15th (relative to sun).
I want to watch Udemy video on mpv for studying and note-taking. I tested
2022.06.29
and found some issues and workaround.udemy.py:L168-L171
Udemy login popup is updated. So it needs to be updated. But after a few successful logins, I couldn’t log in. Udemy just returnend the login popup html. I don’t know why. Maybe Udemy restriction?
yt-dlp
needs to be updated inudemy.py:L132-L139
udemy.py:L205
_real_extract
passes wrongcourse_id
to_download_lecture
. It always gets403 Forbidden
. Ifcourse_id
is correct,yt-dlp
will download video properly. I wanted to make a PR but I couldn’t fix the 3 because I couldn’t pass playlist url which has realcourse_id
to_real_extract
.same issue using version
2022.05.18
with v2021.10.22 I only get the “course: Unable to download webpage” error: