[udemy] Use custom User-Agent (closes #15571)

This commit is contained in:
Sergey M․ 2018-02-26 04:12:28 +07:00
parent eaa3172672
commit abe8766c35
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D

View file

@ -5,6 +5,7 @@
from .common import InfoExtractor from .common import InfoExtractor
from ..compat import ( from ..compat import (
compat_HTTPError, compat_HTTPError,
compat_kwargs,
compat_str, compat_str,
compat_urllib_request, compat_urllib_request,
compat_urlparse, compat_urlparse,
@ -114,6 +115,11 @@ def _handle_error(self, response):
error_str += ' - %s' % error_data.get('formErrors') error_str += ' - %s' % error_data.get('formErrors')
raise ExtractorError(error_str, expected=True) raise ExtractorError(error_str, expected=True)
def _download_webpage(self, *args, **kwargs):
kwargs.setdefault('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'
return super(UdemyIE, self)._download_webpage(
*args, **compat_kwargs(kwargs))
def _download_json(self, url_or_request, *args, **kwargs): def _download_json(self, url_or_request, *args, **kwargs):
headers = { headers = {
'X-Udemy-Snail-Case': 'true', 'X-Udemy-Snail-Case': 'true',