youtube-dl: [Udemy] ERROR: Unable to download webpage: HTTP Error 403: Forbidden

Checklist

  • I’m reporting a broken site support
  • I’ve verified that I’m running youtube-dl version 2021.06.06
  • I’ve checked that all provided URLs are alive and playable in a browser
  • I’ve checked that all URLs and arguments with special characters are properly quoted or escaped
  • I’ve searched the bugtracker for similar issues including closed ones

Verbose log


C:\>youtube-dl.exe -u **** -p **** https://www.udemy.com/course/learn-advanced-java/ --verbose
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-u', 'PRIVATE', '-p', 'PRIVATE', 'https://www.udemy.com/course/learn-advanced-java/', '--verbose']
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252
[debug] youtube-dl version 2021.06.06
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.18362
[debug] exe versions: none
[debug] Proxy map: {}
[udemy:course] Downloading login popup
ERROR: Unable to download webpage: HTTP Error 403: Forbidden (caused by HTTPError()); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\extractor\common.py", line 634, in _request_webpage
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\YoutubeDL.py", line 2288, in urlopen
  File "C:\Python\Python34\lib\urllib\request.py", line 470, in open
  File "C:\Python\Python34\lib\urllib\request.py", line 580, in http_response
  File "C:\Python\Python34\lib\urllib\request.py", line 508, in error
  File "C:\Python\Python34\lib\urllib\request.py", line 442, in _call_chain
  File "C:\Python\Python34\lib\urllib\request.py", line 588, in http_error_default```

Description

I was trying to download the learn advanced Java course which I have bought from Udemy for offline watching purposes. However, youtube-dl gives me an error when trying to do so.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 35 (15 by maintainers)

Most upvoted comments

I was having the 403 issue, and then I was having an extract login-form form issue, but I was able to resolve both of them and get youtube-dl working with Udemy.

First I was able to resolve the 403 by logging into the website in chrome and then downloading the cookie file and including it with the ‘–cookie /path/to/cookie.txt’ option. (See How do I pass cookies to youtube-dl). But then I was still getting the error:

ERROR: Unable to extract login-form form; 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.

It turns out this was caused because in my youtube-dl request I was passing -u username -p password options to the request which was causing the login popup preventing the download.

Also to note, in the URL for a course in Udemy, i.e. https://www.udemy.com/course/understanding-typescript/, there is an extra /course/ that needs to be removed for the request. So the URL should instead look like https://www.udemy.com/understanding-typescript/.

Put all this together and a valid request should look like:

youtube-dl --cookie /path/to/cookies.txt -o '~/your/path/%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s' https://www.udemy.com/COURSE-NAME/

Where you replace the path to the cookie file, the path to the output directory, and the course name in the Udemy URL.

Hope this helps 😃

What’s wrong?

youtube-dl 2021.12.17 still has a problem using -u and -p

note

however using --cookies is a workaround.

… in the URL for a course in Udemy, i.e. https://www.udemy.com/course/understanding-typescript/, there is an extra /course/ that needs to be removed for the request …

This should be handled automatically. Could you post some -v -F logs showing behaviour with/without course/? Or if this patch makes it work with the raw URL as quoted above, let us know:

--- old/youtube-dl/youtube_dl/extractor/udemy.py
+++ new/youtube-dl/youtube_dl/extractor/udemy.py
@@ -17,6 +17,7 @@
     float_or_none,
     int_or_none,
     js_to_json,
+    remove_start,
     sanitized_Request,
     try_get,
     unescapeHTML,
@@ -437,6 +438,7 @@
     def _real_extract(self, url):
         course_path = self._match_id(url)
 
+        course_path = remove_start(course_path, 'course/')
         webpage = self._download_webpage(url, course_path)
 
         course_id, title = self._extract_course_info(webpage, course_path)

Your URL is not right.

try

youtube-dl.exe -u **** -p **** https://www.udemy.com/learn-advanced-java/ --verbose