From ff740b365e83f0967c1dff807dde434baf1967a2 Mon Sep 17 00:00:00 2001 From: Fridolin Kutterer Date: Thu, 29 Jun 2023 11:16:35 +0200 Subject: [PATCH] Made Lecturio poll the german API if a german URL is given Formatting fixes --- yt_dlp/extractor/lecturio.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/yt_dlp/extractor/lecturio.py b/yt_dlp/extractor/lecturio.py index 973764c63..e9b7d8b9a 100644 --- a/yt_dlp/extractor/lecturio.py +++ b/yt_dlp/extractor/lecturio.py @@ -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')