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
131.89k stars 10k forks source link

[udemy] Unable to download webpage: HTTP Error 403: Unauthorized #17986

Closed Tchakatak closed 5 years ago

Tchakatak commented 5 years ago

Please follow the guide below


Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2018.10.05. 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 the -v flag to your command line you run youtube-dl with (youtube-dl -v <your command line>), copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):

[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKcj']
[debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
[debug] youtube-dl version 2018.10.05
[debug] Python version 2.7.11 - Windows-2003Server-5.2.3790-SP2
[debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4
[debug] Proxy map: {}
...
<end of log>

If the purpose of this issue is a site support request please provide all kinds of example URLs support for which should be included (replace following example URLs by yours):

Note that youtube-dl does not support sites dedicated to copyright infringement. In order for site support request to be accepted all provided example URLs should not violate any copyrights.


Description of your issue, suggested solution and other information

Explanation of your issue in arbitrary form goes here. Please make sure the description is worded well enough to be understood. Provide as much context and examples as possible. If work on your issue requires account credentials please provide them or explain how one can obtain them.


DESCRIPTION

youtube-dl crash randomly with a 403 Unauthorized wile crawling into udemy course. I have been able to download successly 35/150 videos about my course, but after a "first run", youtube-dl crash around 30, and on the second run, i cant even access to the homepage.

It look like udemy has implemented a system to detect the usage of this script, maybe a pause between 2 downloads could help to bypass this system;


LOG


youtube-dl -u ***USERNAME***  -p ***PASSWORD***  -v https://www.udemy.com/***COURSE***
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-u', u'PRIVATE', u'-p', u'PRIVATE', u'-v', u'https://www.udemy.com/***COURSE***/']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2018.10.05
[debug] Python version 2.7.15rc1 (CPython) - Linux-4.18.16-041816-generic-x86_64-with-Ubuntu-18.04-bionic
[debug] exe versions: ffmpeg 3.4.4-0ubuntu0.18.04.1, ffprobe 3.4.4-0ubuntu0.18.04.1
[debug] Proxy map: {}
[udemy:course] Downloading login popup
ERROR: Unable to download webpage: HTTP Error 403: Unauthorized (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 604, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 2211, 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)

...
<end of log>
...
Tchakatak commented 5 years ago

Can you give me the bug witch is duplicated? I am working on a fix.

TCarmine commented 5 years ago

I am getting the same Traceback.

If this can help for udemy-dl I am getting :

Traceback (most recent call last): File "/usr/local/bin/udemy-dl", line 7, in main() File "/usr/local/lib/python2.7/dist-packages/udemy_dl/udemy_dl.py", line 837, in main udemy_dl(username, password, link, lecture_start, lecture_end, save_links, safe_file_names, just_list, output_dest) File "/usr/local/lib/python2.7/dist-packages/udemy_dl/udemy_dl.py", line 658, in udemy_dl login(username, password) File "/usr/local/lib/python2.7/dist-packages/udemy_dl/udemy_dl.py", line 109, in login csrf_token = get_csrf_token() File "/usr/local/lib/python2.7/dist-packages/udemy_dl/udemy_dl.py", line 102, in get_csrf_token return match.group(1) AttributeError: 'NoneType' object has no attribute 'group'

So looking at it seems authorization issue. For the case of udemy-dl is about the csrf_token

kalinali commented 5 years ago

https://github.com/rg3/youtube-dl/issues/15839

thumusandeep commented 5 years ago

Any update on this issue. And is this being tracked in https://github.com/rg3/youtube-dl/issues/18126