From: Sergey M․ Date: Wed, 26 Nov 2014 15:00:18 +0000 (+0600) Subject: [udemy] Set session cookies to API requests (Closes #4124, closes #4219, closes ... X-Git-Url: http://git.oshgnacknak.de/?a=commitdiff_plain;h=e293711802c010e2720f8df00fde34d0af5f6ac3;p=youtube-dl [udemy] Set session cookies to API requests (Closes #4124, closes #4219, closes #4308) --- diff --git a/youtube_dl/extractor/udemy.py b/youtube_dl/extractor/udemy.py index 1a7d01c67..cf7bd0ae5 100644 --- a/youtube_dl/extractor/udemy.py +++ b/youtube_dl/extractor/udemy.py @@ -45,6 +45,19 @@ class UdemyIE(InfoExtractor): self._handle_error(response) return response + def _download_json_cookies(self, url, video_id, note): + headers = { + 'X-Udemy-Snail-Case': 'true', + 'X-Requested-With': 'XMLHttpRequest', + } + for cookie in self._downloader.cookiejar: + if cookie.name == 'client_id': + headers['X-Udemy-Client-Id'] = cookie.value + elif cookie.name == 'access_token': + headers['X-Udemy-Bearer-Token'] = cookie.value + request = compat_urllib_request.Request(url, headers=headers) + return self._download_json(request, video_id, note) + def _real_initialize(self): self._login() @@ -62,7 +75,9 @@ class UdemyIE(InfoExtractor): if login_popup == '
': return - csrf = self._html_search_regex(r'