mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-08 22:17:07 +01:00
[udemy] Modernize
This commit is contained in:
parent
aabdc83d6e
commit
75b81df3af
@ -5,7 +5,6 @@
|
|||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
compat_HTTPError,
|
compat_HTTPError,
|
||||||
compat_urllib_parse_urlencode,
|
|
||||||
compat_urllib_request,
|
compat_urllib_request,
|
||||||
compat_urlparse,
|
compat_urlparse,
|
||||||
)
|
)
|
||||||
@ -91,12 +90,12 @@ def combine_url(base_url, url):
|
|||||||
|
|
||||||
def _download_lecture(self, course_id, lecture_id):
|
def _download_lecture(self, course_id, lecture_id):
|
||||||
return self._download_json(
|
return self._download_json(
|
||||||
'https://www.udemy.com/api-2.0/users/me/subscribed-courses/%s/lectures/%s?%s' % (
|
'https://www.udemy.com/api-2.0/users/me/subscribed-courses/%s/lectures/%s?'
|
||||||
course_id, lecture_id, compat_urllib_parse_urlencode({
|
% (course_id, lecture_id),
|
||||||
'fields[lecture]': 'title,description,view_html,asset',
|
lecture_id, 'Downloading lecture JSON', query={
|
||||||
'fields[asset]': 'asset_type,stream_url,thumbnail_url,download_urls,data',
|
'fields[lecture]': 'title,description,view_html,asset',
|
||||||
})),
|
'fields[asset]': 'asset_type,stream_url,thumbnail_url,download_urls,data',
|
||||||
lecture_id, 'Downloading lecture JSON')
|
})
|
||||||
|
|
||||||
def _handle_error(self, response):
|
def _handle_error(self, response):
|
||||||
if not isinstance(response, dict):
|
if not isinstance(response, dict):
|
||||||
@ -156,13 +155,13 @@ def is_logged(webpage):
|
|||||||
'password': password,
|
'password': password,
|
||||||
})
|
})
|
||||||
|
|
||||||
request = sanitized_Request(
|
|
||||||
self._LOGIN_URL, urlencode_postdata(login_form))
|
|
||||||
request.add_header('Referer', self._ORIGIN_URL)
|
|
||||||
request.add_header('Origin', self._ORIGIN_URL)
|
|
||||||
|
|
||||||
response = self._download_webpage(
|
response = self._download_webpage(
|
||||||
request, None, 'Logging in as %s' % username)
|
self._LOGIN_URL, None, 'Logging in as %s' % username,
|
||||||
|
data=urlencode_postdata(login_form),
|
||||||
|
headers={
|
||||||
|
'Referer': self._ORIGIN_URL,
|
||||||
|
'Origin': self._ORIGIN_URL,
|
||||||
|
})
|
||||||
|
|
||||||
if not is_logged(response):
|
if not is_logged(response):
|
||||||
error = self._html_search_regex(
|
error = self._html_search_regex(
|
||||||
|
Loading…
Reference in New Issue
Block a user