Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Udemy] ERROR: Unable to download webpage: HTTP Error 403: Forbidden #29915

Closed
5 tasks done
fhcaglayan opened this issue Sep 6, 2021 · 35 comments
Closed
5 tasks done
Labels
account-needed broken-IE problem with existing site extraction duplicate

Comments

@fhcaglayan
Copy link

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.

@Zeddex

This comment was marked as duplicate.

@pbpalomino
Copy link

Your URL is not right.

try

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

@fhcaglayan
Copy link
Author

fhcaglayan commented Sep 8, 2021

Same problem unfortunately:

C:\>youtube-dl.exe -u **** -p **** https://www.udemy.com/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/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

@fhcaglayan
Copy link
Author

If you want in private I can share my account details with a temporary password so you can try for yourself as well.

@pbpalomino
Copy link

pbpalomino commented Sep 8, 2021

@fhcaglayan may be an unescaped string from you password.

You are not able to login.

Try using cookies.

this works on my machine

youtube-dl ^
--cookies udemy_cookies.txt ^
-o '%(playlist)s/%(chapter_number)s - %(chapter)s/%(playlist_index)s. %(title)s.%(ext)s' ^
'YOURURL' ^
--verbose

^ splits large lines on windows cmd.

@fhcaglayan
Copy link
Author

fhcaglayan commented Sep 8, 2021 via email

@Michael-Obele

This comment was marked as duplicate.

@MacroController

This comment was marked as off-topic.

@lorenzlars
Copy link

I also have the same issue. I tried it with escaped username and password and also with cookie. I also tried the url with /courses in it and without it. And I tried ending the url with / and without. I think something has changed on Udemy side which causes the issue.

@dirkf
Copy link
Contributor

dirkf commented Nov 17, 2021

Duplicate of #29410.

@brskl88
Copy link

brskl88 commented Nov 28, 2021

Hey everybody.I have almost the same problem.My problem is when i start to download, it downloads first video without any problems.It is on my hard disk.But when it tries to download second one it gives the error.I use cookie method and i export the cookie file by "Export Cookies" extension on Firefox.But on my case it gives another error when it tries to download second video.It says

[udemy] 15779426: Downloading lecture JSON
ERROR: No video formats found; please report this issue on https://yt-dl.org/bug

So i add my verbose output here.

Verbose Output

youtube-dl --cookies cookie.txt --verbose https://www.udemy.com/the-advanced-cryptocurrency-trading-course-with-strategies/
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--cookies', 'cookie.txt', '--verbose', 'https://www.udemy.com/the-advanced-cryptocurrency-trading-course-with-strategies/']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.06.06
[debug] Python version 3.8.10 (CPython) - Linux-5.11.0-27-generic-x86_64-with-glibc2.29
[debug] exe versions: ffmpeg 4.2.4, ffprobe 4.2.4, rtmpdump 2.4
[debug] Proxy map: {}
[udemy:course] the-advanced-cryptocurrency-trading-course-with-strategies: Downloading webpage
[udemy:course] 2500544: Downloading course curriculum
[download] Downloading playlist: 2500544
[udemy:course] playlist 2500544: Collected 39 video ids (downloading 39 of them)
[download] Downloading video 1 of 39
[udemy] 15929840: Downloading webpage
[udemy] 15929840: Downloading lecture JSON
[udemy] 19874331: Downloading m3u8 information
[debug] Default format spec: bestvideo+bestaudio/best
[debug] Invoking downloader on 'https://www.udemy.com/assets/19874331/files/2019-09-10_20-55-46-ceaae9486ee7f497888103ddf974b304/2/hls/AVC_1920x1080_800k_AAC-HE_64k/aa0025a2af4592ba37f10526c90a4b4ff6c6.m3u8?provider=cdn77&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXRoIjoiMjAxOS0wOS0xMF8yMC01NS00Ni1jZWFhZTk0ODZlZTdmNDk3ODg4MTAzZGRmOTc0YjMwNC8yLyIsImV4cCI6MTYzODEwOTM4MH0.7JGx6OM1vh3_hOMK2Pt3W18fYzckuL3FdWkljG4LK7A&v=1'
[download] What You Will Learn in This Course-19874331.mp4 has already been downloaded
[download] 100% of 19.40MiB
[debug] ffmpeg command line: ffprobe -show_streams 'file:What You Will Learn in This Course-19874331.mp4'
[ffmpeg] Fixing malformed AAC bitstream in "What You Will Learn in This Course-19874331.mp4"
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:What You Will Learn in This Course-19874331.mp4' -c copy -f mp4 -bsf:a aac_adtstoasc 'file:What You Will Learn in This Course-19874331.temp.mp4'
[download] Downloading video 2 of 39
[udemy] 15779426: Downloading webpage
[udemy] 15779426: Downloading lecture JSON
ERROR: No video formats found; 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 "/usr/lib/python3/dist-packages/youtube_dl/YoutubeDL.py", line 815, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/youtube_dl/YoutubeDL.py", line 836, in __extract_info
    ie_result = ie.extract(url)
  File "/usr/lib/python3/dist-packages/youtube_dl/extractor/common.py", line 534, in extract
    ie_result = self._real_extract(url)
  File "/usr/lib/python3/dist-packages/youtube_dl/extractor/udemy.py", line 408, in _real_extract
    self._sort_formats(formats, field_preference=('height', 'width', 'tbr', 'format_id'))
  File "/usr/lib/python3/dist-packages/youtube_dl/extractor/common.py", line 1374, in _sort_formats
    raise ExtractorError('No video formats found')
youtube_dl.utils.ExtractorError: No video formats found; 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.

So is there any solution to fix it?Or do i make any mistakes when writing my command?Thank you.

@dirkf
Copy link
Contributor

dirkf commented Nov 28, 2021

That looks like #25656, not that it helps.

@brskl88
Copy link

brskl88 commented Nov 28, 2021

That looks like #25656, not that it helps.

Thank you for the response.I already removed that part of the link as it says to remove "/course/".but it didn't fix the problem.is there another solution to fix this?the interesting thing is everything works for first video and it downloads it.but for second one it gives the error.

@dirkf
Copy link
Contributor

dirkf commented Nov 28, 2021

Try loading the failing video in your browser. That may reveal what the problem is.

@razafinarivohanania

This comment was marked as duplicate.

@zdegeorge
Copy link

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 :)

@dirkf
Copy link
Contributor

dirkf commented Dec 23, 2021

... 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)

@dirkf
Copy link
Contributor

dirkf commented Dec 29, 2021

On reflection I can't see how stripping course/ could affect the extraction unless through redirection back to the unstripped URL.

There seem to be two major problems here:

  • the extractor hasn't been properly updated for more than a year, judging by old failed PRs that appear to target the current site structure;
  • yt-dl web requests are being subjected to some sort of protocol violation presumably imposed through Cloudflare, so that any request may randomly be rejected with 403 (this is how redirection might have an effect).

This happens despite trying Python versions from 2.7 to 3.9, removing the Accept: header, varying the UA, ...

From the metadata, the site may possibly also be serving videos with DRM.

It has an optional Download button that the Instructor can enable. It may be easier to ask for that.

@thelonghop
Copy link

thelonghop commented Dec 31, 2021

I'm getting this error as well. Have tried with -u/-p and with cookies, with and without /courses/

$ youtube-dl --verbose --cookies ./network008 -o '%(playlist)s/%(chapter_number)s - %(chapter)s/%(playlist_index)s. %(title)s.%(ext)s' https://www.udemy.com/comptia-network-n10-008/
[debug] System config: [u'-o', u'/home/user1/Videos/ytdl/%(title)s']
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'--verbose', u'--cookies', u'./network008', u'-o', u'%(playlist)s/%(chapter_number)s - %(chapter)s/%(playlist_index)s. %(title)s.%(ext)s', u'https://www.udemy.com/comptia-network-n10-008/']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Python version 2.7.18 (CPython) - Linux-5.13.0-22-generic-x86_64-with-LinuxMint-20.2-uma
[debug] exe versions: ffmpeg 4.2.4, ffprobe 4.2.4, rtmpdump 2.4
[debug] Proxy map: {}
[udemy:course] comptia-network-n10-008: Downloading webpage
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 "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 634, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 2288, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python2.7/urllib2.py", line 435, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 548, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 473, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 556, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)

@dirkf
Copy link
Contributor

dirkf commented Dec 31, 2021

Looks like the same problem. If someone can work out how to fix Cloudflare's protocol violation (2nd bullet above) it could be possible to make further progress.

@dirkf

This comment has been minimized.

@dirkf

This comment has been minimized.

@dirkf

This comment has been minimized.

@dirkf

This comment has been minimized.

@dirkf

This comment has been minimized.

@dirkf

This comment was marked as off-topic.

@dirkf

This comment was marked as off-topic.

@dmiraj dmiraj mentioned this issue Jan 31, 2022
11 tasks
@agails
Copy link

agails commented Feb 9, 2022

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 :)

Thank you so much, your instructions worked like a charm! This should be highlighted on the main page!

@dirkf dirkf changed the title ERROR: Unable to download webpage: HTTP Error 403: Forbidden (caused by HTTPError()); please report this issue on https://yt-dl.org/bug [Udemy] ERROR: Unable to download webpage: HTTP Error 403: Forbidden Feb 26, 2022
@nicheath
Copy link

nicheath commented Mar 5, 2022

youtube-dl 2021.12.17 still has a problem using -u and -p however using --cookies is a workaround.

@pashakiz

This comment was marked as off-topic.

@nicheath

This comment was marked as resolved.

@dirkf
Copy link
Contributor

dirkf commented Mar 8, 2022

What's wrong?

...
ERROR: Unable to extract course 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.
...

See #30719.

@dirkf dirkf added broken-IE problem with existing site extraction account-needed duplicate labels Apr 27, 2022
@GwamakaCharles
Copy link

TESTED AND WORKS ON A MAC OS

  1. Install youtube-dl through brew install youtube-dl. If you used curl, you can remove it through rm -rf /usr/local/bin/youtube-dl.
  2. If you face symlink permissions ERRORS, run sudo chown -R $(whoami) $(brew --prefix)/* then brew doctor and fix each error according to the instructions.
  3. brew cleanup
  4. brew link youtube-dl
  5. cd . (navigate to your favorable location that you wish to put your videos folder)
  6. Login to udemy and get site cookies text file. I used Get Cookies.txt.
  7. mkdir MyVideos. (name it as you wish)
  8. youtube-dl --cookies udemy.com_cookies.txt -o '~/MyVideos/%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s' https://www.udemy.com/<course-name>
  9. Done! 🎮

@niharika1102

This comment was marked as duplicate.

@dirkf
Copy link
Contributor

dirkf commented Apr 13, 2023

Still duplicate of #29410.

@dirkf dirkf closed this as not planned Won't fix, can't repro, duplicate, stale Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
account-needed broken-IE problem with existing site extraction duplicate
Projects
None yet
Development

No branches or pull requests