1
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-03-09 12:50:23 -05:00

Made Lecturio poll the german API if a german URL is given

Formatting fixes
This commit is contained in:
Fridolin Kutterer 2023-06-29 11:16:35 +02:00
parent a2be9781fb
commit ff740b365e

View file

@ -16,16 +16,27 @@
class LecturioBaseIE(InfoExtractor):
_API_BASE_URL = 'https://app.lecturio.com/api/en/latest/html5/'
_DE_API_BASE_URL = 'https://lecturio.de/api/de/latest/html5/'
_LOGIN_URL = 'https://app.lecturio.com/en/login'
_DE_LOGIN_URL = 'https://www.lecturio.de/anmelden.html'
_NETRC_MACHINE = 'lecturio'
is_DE = None
# Find out if url is german before starting anything else
def extract(self, url):
self.is_DE = True if re.match(r"https://(?:www\.)?lecturio\.de/", url) else False
return super().extract(url)
def _perform_login(self, username, password):
login_url = self._DE_LOGIN_URL if self.is_DE else self._LOGIN_URL
# Sets some cookies
_, urlh = self._download_webpage_handle(
self._LOGIN_URL, None, 'Downloading login popup')
login_url, None, 'Downloading login popup')
def is_logged(url_handle):
return self._LOGIN_URL not in url_handle.geturl()
return login_url not in url_handle.geturl()
# Already logged in
if is_logged(urlh):
@ -38,7 +49,7 @@ def is_logged(url_handle):
}
response, urlh = self._download_webpage_handle(
self._LOGIN_URL, None, 'Logging in',
login_url, None, 'Logging in',
data=urlencode_postdata(login_form))
# Logged in successfully
@ -98,8 +109,9 @@ def _real_extract(self, url):
lecture_id = mobj.group('id')
display_id = nt or lecture_id
api_path = 'lectures/' + lecture_id if lecture_id else 'lecture/' + nt + '.json'
video = self._download_json(
self._API_BASE_URL + api_path, display_id)
(self._DE_API_BASE_URL if self.is_DE else self._API_BASE_URL) + api_path, display_id)
title = video['title'].strip()
if not lecture_id:
pid = video.get('productId') or video.get('uid')