diff options
author | Sergey M․ <dstftw@gmail.com> | 2019-02-17 00:58:13 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2019-02-17 00:58:13 +0700 |
commit | ae65c93a26f2b3cf806477a3ee891aa461b5c6b0 (patch) | |
tree | 01ace8426ce28c1f9b7034950cae8deed3fc8f90 | |
parent | ba2e3730d125eab952eded3bb7749d479a2262d3 (diff) |
[udemy] Update User-Agent and detect captcha (closes #14713, closes #15839, closes #18126)
-rw-r--r-- | youtube_dl/extractor/udemy.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/youtube_dl/extractor/udemy.py b/youtube_dl/extractor/udemy.py index 105826e9b..89a7f6ade 100644 --- a/youtube_dl/extractor/udemy.py +++ b/youtube_dl/extractor/udemy.py @@ -123,10 +123,22 @@ class UdemyIE(InfoExtractor): def _download_webpage_handle(self, *args, **kwargs): headers = kwargs.get('headers', {}).copy() - headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4' + headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36' kwargs['headers'] = headers - return super(UdemyIE, self)._download_webpage_handle( + ret = super(UdemyIE, self)._download_webpage_handle( *args, **compat_kwargs(kwargs)) + if not ret: + return ret + webpage, _ = ret + if any(p in webpage for p in ( + '>Please verify you are a human', + 'Access to this page has been denied because we believe you are using automation tools to browse the website', + '"_pxCaptcha"')): + raise ExtractorError( + 'Udemy asks you to solve a CAPTCHA. Login with browser, ' + 'solve CAPTCHA, then export cookies and pass cookie file to ' + 'youtube-dl with --cookies.', expected=True) + return ret def _download_json(self, url_or_request, *args, **kwargs): headers = { |