|
|
|
@ -16,16 +16,27 @@ from ..utils import (
|
|
|
|
|
|
|
|
|
|
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 @@ class LecturioBaseIE(InfoExtractor):
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 @@ class LecturioIE(LecturioBaseIE):
|
|
|
|
|
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')
|
|
|
|
|