ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
129.78k stars 9.79k forks source link

[udemy] HTTP Error 403: Forbidden (JSON) #30802

Open chrispaivacwb opened 2 years ago

chrispaivacwb commented 2 years ago

Verbose log

youtube-dl --cookies cookies.txt https://www.udemy.com/course/desenvolvendo-para-sharepoint-com-spfx/ --verbose
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--cookies', 'cookies.txt', 'https://www.udemy.com/course/desenvolvendo-para-sharepoint-com-spfx/', '--verbose']
[debug] Encodings: locale cp1252, fs mbcs, out cp850, pref cp1252
[debug] youtube-dl version 2021.12.17
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.19041
[debug] exe versions: ffmpeg git-2020-07-13-7772666
[debug] Proxy map: {}
[udemy:course] course: Downloading webpage
[udemy:course] 3229057: Downloading course curriculum
[download] Downloading playlist: 3229057
[udemy:course] playlist 3229057: Collected 71 video ids (downloading 71 of them)
[download] Downloading video 1 of 71
[udemy] 20418981: Downloading webpage
[udemy] 20418981: Downloading lecture JSON
[udemy] 20418981: Downloading lecture JSON
ERROR: Unable to download JSON metadata: 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\tmpupik7c6w\build\youtube_dl\extractor\common.py", line 634, in _request_webpage
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpupik7c6w\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

Trying getting a paid udemy video course using --cookies and didn´t work.

dirkf commented 2 years ago

Actually, duplicate of #22306, closed as solved.

See also #29705, #29410.

chrispaivacwb commented 2 years ago

I couldn't see any solutions from the pointed posts.

dirkf commented 2 years ago

No, the only thing I noted was the statement by one poster that the site's cookies are very short-lived.

The issues reported for this site are of three types:

The latter two may be related.

So this is a duplicate of #22306, closed as solved.

It's possible that the site serves some pages in a way that the extractor doesn't handle: because of the need for login, extractor developers may not be aware of the range of page formats. Also, I believe that the site is quite assiduous in barring downloaders.

One thing you could try is setting the User-Agent header to match the browser from which you set the cookies (see the full results at https://hidester.com/browser-fingerprint/, eg) with the --user-agent ... command-line option, or to some other value like just 'MOzilla/5.0'.

jack-lopes commented 2 years ago

I have the same problem giving user -u and password -p in command line

dirkf commented 2 years ago

I have the same problem giving user -u and password -p in command line

Definitely try using --cookies ... (read the manual for details) and omit the username and password options. This is issue #29410.

dirkf commented 2 years ago

Also see why a dedicated tool for Udemy was abandoned.

skupjoe commented 1 year ago

I can confirm that using cookies.txt is working. You must use netscape format cookies file

dirkf commented 1 year ago

@skupjoe, please post a verbose log showing your successful run, if you can. This would be a concrete example for other people and possibly for testing.

skupjoe commented 1 year ago

Here is a picture of logs showing successful run (however, note that DRM content cannot be downloaded (#31997 raised for this)

image

dirkf commented 1 year ago

Text would be more useful, though. By all means obscure any sensitive text.