merge upstream

This commit is contained in:
Conner Luker 2024-08-03 10:51:29 -07:00
parent d9ab668223
commit b68122d9aa

View File

@ -1,10 +1,7 @@
import re
import urllib.parse
from .common import InfoExtractor
from ..compat import (
compat_str,
compat_urlparse,
)
from ..utils import (
ExtractorError,
parse_duration,
@ -42,7 +39,7 @@ def _perform_login(self, username, password):
login_form.update({
'username': username,
'password': password
'password': password,
})
post_url = self._search_regex(
@ -50,7 +47,7 @@ def _perform_login(self, username, password):
'post_url', default=self._LOGIN_URL, group='url')
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(
post_url, None, 'Logging in', data=urlencode_postdata(login_form),
@ -65,14 +62,14 @@ def _perform_login(self, username, password):
r'class=(["\'])(?:(?!\1).)*\bMessageAlert\b(?:(?!\1).)*\1[^>]*>(?P<error>[^<]+)<',
response, 'error message', default=None, group='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')
class FrontendMastersPageBaseIE(FrontendMastersBaseIE):
def _download_course(self, course_name, url):
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})
@staticmethod
@ -101,7 +98,7 @@ def _extract_lesson(chapters, lesson_id, lesson, subtitles):
duration = None
timestamp = lesson.get('timestamp')
if isinstance(timestamp, compat_str):
if isinstance(timestamp, str):
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})',
timestamp)
@ -111,7 +108,7 @@ def _extract_lesson(chapters, lesson_id, lesson, subtitles):
return {
'_type': 'url_transparent',
'url': 'frontendmasters:%s' % lesson_id,
'url': f'frontendmasters:{lesson_id}',
'ie_key': FrontendMastersIE.ie_key(),
'id': lesson_id,
'display_id': display_id,