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
132.63k stars 10.05k forks source link

Udemy: HTTP Error 403: FORBIDDEN #13074

Closed ghost closed 7 years ago

ghost commented 7 years ago

Please follow the guide below


Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2017.05.09. If it's not read this FAQ entry and update. Issues with outdated version will be rejected.

Before submitting an issue make sure you have:

What is the purpose of your issue?


The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your issue


If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:

Add -v flag to your command line you run youtube-dl with, copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):

"C:\Program Files\MPV\youtube-dl.exe" --output "B:\CG\%(playlist)s\%(playlist)s_%(playlist_index)s_%(title)s.%(ext)s" --cookies "C:\Program Files\MPV\cookies.txt" --all-subs --embed-subs --verbose -f=bestvideo+bestaudio/best https://www.udemy.com/unity-5-lighting-fundamentals/
[debug] System config: []
[debug] User config: ['--no-mtime']
[debug] Custom config: []
[debug] Command-line args: ['--output', 'B:\\CG\\%(playlist)s\\%(playlist)s_%(playlist_index)s_%(title)s.%(ext)s', '--cookies', 'C:\\Program Files\\MPV\\cookies.txt', '--all-subs', '--embed-subs', '--verbose', '-f=bestvideo+bestaudio/best', 'https://www.udemy.com/unity-5-lighting-fundamentals/']
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252
[debug] youtube-dl version 2017.05.09
[debug] Python version 3.4.4 - Windows-10-10.0.14393
[debug] exe versions: ffmpeg N-82117-gc117343, ffprobe N-79000-g66edd86, rtmpdump 2.3
[debug] Proxy map: {}
[udemy:course] unity-5-lighting-fundamentals: Downloading webpage
[udemy:course] 294: Downloading course curriculum
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\rg3\tmpup5muf90\build\youtube_dl\extractor\common.py", line 502, in _request_webpage
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpup5muf90\build\youtube_dl\YoutubeDL.py", line 2106, 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
...
<end of log>


Description of your issue, suggested solution and other information

Trying to download from Udemy, creditentials in cookies.

dstftw commented 7 years ago

Carefully read new issue template and provide all requested information.

ghost commented 7 years ago

same issue as: https://github.com/rg3/youtube-dl/issues/10881 and https://github.com/rg3/youtube-dl/issues/11202

dstftw commented 7 years ago

This course is not free. Have you purchased it in the first place? How did you export cookies?

ghost commented 7 years ago

of course I've bought it. exported using this: https://addons.mozilla.org/en-US/firefox/addon/export-cookies/

the cookies are fine

dstftw commented 7 years ago

For any further investigations you must provide account credentials.

ghost commented 7 years ago

You don't need any account credentials to test this, the same error occurs with free courses: (Example) https://www.udemy.com/learn-level-design-unity-basics-in-under-2-hours/

"C:\Program Files\MPV\youtube-dl.exe" --output "B:\CG\%(playlist)s\%(playlist)s_%(playlist_index)s_%(title)s.%(ext)s" --cookies "C:\Program Files\MPV\cookies.txt" --all-subs --embed-subs --verbose -f=bestvideo+bestaudio/best https://www.udemy.com/learn-level-design-unity-basics-in-under-2-hours/
[debug] System config: []
[debug] User config: ['--no-mtime']
[debug] Custom config: []
[debug] Command-line args: ['--output', 'B:\\CG\\%(playlist)s\\%(playlist)s_%(playlist_index)s_%(title)s.%(ext)s', '--cookies', 'C:\\Program Files\\MPV\\cookies.txt', '--all-subs', '--embed-subs', '--verbose', '-f=bestvideo+bestaudio/best', 'https://www.udemy.com/learn-level-design-unity-basics-in-under-2-hours/']
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252
[debug] youtube-dl version 2017.05.09
[debug] Python version 3.4.4 - Windows-10-10.0.14393
[debug] exe versions: ffmpeg N-82117-gc117343, ffprobe N-79000-g66edd86, rtmpdump 2.3
[debug] Proxy map: {}
[udemy:course] learn-level-design-unity-basics-in-under-2-hours: Downloading webpage
[udemy:course] 269: Enrolling in the course
[udemy:course] 269: Downloading course curriculum
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\rg3\tmpup5muf90\build\youtube_dl\extractor\common.py", line 502, in _request_webpage
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpup5muf90\build\youtube_dl\YoutubeDL.py", line 2106, 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
dstftw commented 7 years ago

Most likely your cookie file is invalid. Valid cookie:

> py -2.7 .\youtube_dl\__main__.py --cookies 'C:/Users/dst/Downloads/cookies.txt' https://www.udemy.com/learn-level-design-unity-basics-in-under-2-hours/
[udemy:course] learn-level-design-unity-basics-in-under-2-hours: Downloading webpage
[udemy:course] 1074250: Downloading course curriculum
[download] Downloading playlist: Learn Level Design: Unity Basics in Under 2 Hours
[udemy:course] playlist Learn Level Design: Unity Basics in Under 2 Hours: Collected 16 video ids (downloading 16 of them)
[download] Downloading video 1 of 16
[udemy] 6568718: Downloading webpage
[udemy] 6568718: Downloading lecture JSON
[download] Resuming download at byte 523264
[download] Destination: Welcome to the course!-7826436.mp4
[download]  26.1% of 3.82MiB at  1.31MiB/s ETA 00:02
ERROR: Interrupted by user

Empty cookie:

> py -2.7 .\youtube_dl\__main__.py --cookies 'C:/Users/dst/Downloads/cookies-empty.txt' https://www.udemy.com/learn-level-design-unity-basics-in-under-2-hours/
[udemy:course] learn-level-design-unity-basics-in-under-2-hours: Downloading webpage
[udemy:course] 269: Enrolling in the course
[udemy:course] 269: Downloading course curriculum
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; 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.
ghost commented 7 years ago

can I ask what you used to export cookies?

dstftw commented 7 years ago

https://github.com/rg3/youtube-dl#how-do-i-pass-cookies-to-youtube-dl

ghost commented 7 years ago

I was using the same exact addon, but I also had a second cookie exporting addon, I had firefox setup using a custom privacy setting (even though the cookies were present at the time of export and were actually exported)

I removed both cookie exporters, reset firefox privacy settings, then installed the cookie exporter again, and now youtube-dl works. This is a weird thing but I guess it's not related to youtube-dl, though it would be great if it wasn't so picky with its specific taste in cookie format.

dstftw commented 7 years ago

It has nothing to do with cookie file format (the error is different in this case) but cookie file contents namely missing or expired cookies or so.