mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-14 21:23:05 +00:00
merge upstream
This commit is contained in:
parent
d9ab668223
commit
b68122d9aa
@ -1,10 +1,7 @@
|
|||||||
import re
|
import re
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import (
|
|
||||||
compat_str,
|
|
||||||
compat_urlparse,
|
|
||||||
)
|
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
parse_duration,
|
parse_duration,
|
||||||
@ -42,7 +39,7 @@ class FrontendMastersBaseIE(InfoExtractor):
|
|||||||
|
|
||||||
login_form.update({
|
login_form.update({
|
||||||
'username': username,
|
'username': username,
|
||||||
'password': password
|
'password': password,
|
||||||
})
|
})
|
||||||
|
|
||||||
post_url = self._search_regex(
|
post_url = self._search_regex(
|
||||||
@ -50,7 +47,7 @@ class FrontendMastersBaseIE(InfoExtractor):
|
|||||||
'post_url', default=self._LOGIN_URL, group='url')
|
'post_url', default=self._LOGIN_URL, group='url')
|
||||||
|
|
||||||
if not post_url.startswith('http'):
|
if not post_url.startswith('http'):
|
||||||
post_url = compat_urlparse.urljoin(self._LOGIN_URL, post_url)
|
post_url = urllib.parse.urljoin(self._LOGIN_URL, post_url)
|
||||||
|
|
||||||
response = self._download_webpage(
|
response = self._download_webpage(
|
||||||
post_url, None, 'Logging in', data=urlencode_postdata(login_form),
|
post_url, None, 'Logging in', data=urlencode_postdata(login_form),
|
||||||
@ -65,14 +62,14 @@ class FrontendMastersBaseIE(InfoExtractor):
|
|||||||
r'class=(["\'])(?:(?!\1).)*\bMessageAlert\b(?:(?!\1).)*\1[^>]*>(?P<error>[^<]+)<',
|
r'class=(["\'])(?:(?!\1).)*\bMessageAlert\b(?:(?!\1).)*\1[^>]*>(?P<error>[^<]+)<',
|
||||||
response, 'error message', default=None, group='error')
|
response, 'error message', default=None, group='error')
|
||||||
if error:
|
if error:
|
||||||
raise ExtractorError('Unable to login: %s' % error, expected=True)
|
raise ExtractorError(f'Unable to login: {error}', expected=True)
|
||||||
raise ExtractorError('Unable to log in')
|
raise ExtractorError('Unable to log in')
|
||||||
|
|
||||||
|
|
||||||
class FrontendMastersPageBaseIE(FrontendMastersBaseIE):
|
class FrontendMastersPageBaseIE(FrontendMastersBaseIE):
|
||||||
def _download_course(self, course_name, url):
|
def _download_course(self, course_name, url):
|
||||||
return self._download_json(
|
return self._download_json(
|
||||||
'%s/courses/%s' % (self._API_BASE, course_name), course_name,
|
f'{self._API_BASE}/courses/{course_name}', course_name,
|
||||||
'Downloading course JSON', headers={'Referer': url})
|
'Downloading course JSON', headers={'Referer': url})
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -101,7 +98,7 @@ class FrontendMastersPageBaseIE(FrontendMastersBaseIE):
|
|||||||
|
|
||||||
duration = None
|
duration = None
|
||||||
timestamp = lesson.get('timestamp')
|
timestamp = lesson.get('timestamp')
|
||||||
if isinstance(timestamp, compat_str):
|
if isinstance(timestamp, str):
|
||||||
mobj = re.search(
|
mobj = re.search(
|
||||||
r'(?P<start>\d{1,2}:\d{1,2}:\d{1,2})\s*-(?P<end>\s*\d{1,2}:\d{1,2}:\d{1,2})',
|
r'(?P<start>\d{1,2}:\d{1,2}:\d{1,2})\s*-(?P<end>\s*\d{1,2}:\d{1,2}:\d{1,2})',
|
||||||
timestamp)
|
timestamp)
|
||||||
@ -111,7 +108,7 @@ class FrontendMastersPageBaseIE(FrontendMastersBaseIE):
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
'_type': 'url_transparent',
|
'_type': 'url_transparent',
|
||||||
'url': 'frontendmasters:%s' % lesson_id,
|
'url': f'frontendmasters:{lesson_id}',
|
||||||
'ie_key': FrontendMastersIE.ie_key(),
|
'ie_key': FrontendMastersIE.ie_key(),
|
||||||
'id': lesson_id,
|
'id': lesson_id,
|
||||||
'display_id': display_id,
|
'display_id': display_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user