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:
parent
a2be9781fb
commit
ff740b365e
1 changed files with 16 additions and 4 deletions
|
@ -16,16 +16,27 @@
|
||||||
|
|
||||||
class LecturioBaseIE(InfoExtractor):
|
class LecturioBaseIE(InfoExtractor):
|
||||||
_API_BASE_URL = 'https://app.lecturio.com/api/en/latest/html5/'
|
_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'
|
_LOGIN_URL = 'https://app.lecturio.com/en/login'
|
||||||
|
_DE_LOGIN_URL = 'https://www.lecturio.de/anmelden.html'
|
||||||
_NETRC_MACHINE = 'lecturio'
|
_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):
|
def _perform_login(self, username, password):
|
||||||
|
|
||||||
|
login_url = self._DE_LOGIN_URL if self.is_DE else self._LOGIN_URL
|
||||||
# Sets some cookies
|
# Sets some cookies
|
||||||
_, urlh = self._download_webpage_handle(
|
_, urlh = self._download_webpage_handle(
|
||||||
self._LOGIN_URL, None, 'Downloading login popup')
|
login_url, None, 'Downloading login popup')
|
||||||
|
|
||||||
def is_logged(url_handle):
|
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
|
# Already logged in
|
||||||
if is_logged(urlh):
|
if is_logged(urlh):
|
||||||
|
@ -38,7 +49,7 @@ def is_logged(url_handle):
|
||||||
}
|
}
|
||||||
|
|
||||||
response, urlh = self._download_webpage_handle(
|
response, urlh = self._download_webpage_handle(
|
||||||
self._LOGIN_URL, None, 'Logging in',
|
login_url, None, 'Logging in',
|
||||||
data=urlencode_postdata(login_form))
|
data=urlencode_postdata(login_form))
|
||||||
|
|
||||||
# Logged in successfully
|
# Logged in successfully
|
||||||
|
@ -98,8 +109,9 @@ def _real_extract(self, url):
|
||||||
lecture_id = mobj.group('id')
|
lecture_id = mobj.group('id')
|
||||||
display_id = nt or lecture_id
|
display_id = nt or lecture_id
|
||||||
api_path = 'lectures/' + lecture_id if lecture_id else 'lecture/' + nt + '.json'
|
api_path = 'lectures/' + lecture_id if lecture_id else 'lecture/' + nt + '.json'
|
||||||
|
|
||||||
video = self._download_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()
|
title = video['title'].strip()
|
||||||
if not lecture_id:
|
if not lecture_id:
|
||||||
pid = video.get('productId') or video.get('uid')
|
pid = video.get('productId') or video.get('uid')
|
||||||
|
|
Loading…
Reference in a new issue