mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-14 19:31:26 +01:00
Compare commits
No commits in common. "6c25ca9d0eff25f1bfaa1cf01b9aba204c365280" and "0e74f985b8d3d8471ef451417599829f75d6dc52" have entirely different histories.
6c25ca9d0e
...
0e74f985b8
|
@ -3,6 +3,7 @@ import hashlib
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
|
dict_get,
|
||||||
traverse_obj,
|
traverse_obj,
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
)
|
)
|
||||||
|
@ -19,12 +20,11 @@ class BrilliantpalaIE(InfoExtractor):
|
||||||
self._CONTENT_API = f'{self._HOMEPAGE}/api/v2.4/contents/{{content_id}}/'
|
self._CONTENT_API = f'{self._HOMEPAGE}/api/v2.4/contents/{{content_id}}/'
|
||||||
self._HLS_AES_URI = f'{self._HOMEPAGE}/api/v2.5/video_contents/{{content_id}}/key/'
|
self._HLS_AES_URI = f'{self._HOMEPAGE}/api/v2.5/video_contents/{{content_id}}/key/'
|
||||||
|
|
||||||
def _get_logged_in_username(self, url, video_id):
|
def _get_logged_in_username(self, webpage):
|
||||||
webpage, urlh = self._download_webpage_handle(url, video_id)
|
if self._LOGIN_API == self._og_search_property('url', webpage):
|
||||||
if self._LOGIN_API == urlh.url:
|
|
||||||
self.raise_login_required()
|
self.raise_login_required()
|
||||||
return self._html_search_regex(
|
return self._html_search_regex(
|
||||||
r'"username"\s*:\s*"(?P<username>[^"]+)"', webpage, 'stream page info', 'username')
|
r'"username":\s*"(?P<username>[^"]+)"', webpage, 'stream page info', 'username')
|
||||||
|
|
||||||
def _perform_login(self, username, password):
|
def _perform_login(self, username, password):
|
||||||
login_form = self._hidden_inputs(self._download_webpage(
|
login_form = self._hidden_inputs(self._download_webpage(
|
||||||
|
@ -40,11 +40,13 @@ class BrilliantpalaIE(InfoExtractor):
|
||||||
data=urlencode_postdata(login_form))
|
data=urlencode_postdata(login_form))
|
||||||
|
|
||||||
if self._html_search_regex(
|
if self._html_search_regex(
|
||||||
r'(Your username / email and password)', logged_page, 'auth fail', default=None):
|
r'(?P<warning>Your username / email and password)', logged_page,
|
||||||
|
'authentication failure warning', group='warning', fatal=False, default=''):
|
||||||
raise ExtractorError('wrong username or password', expected=True)
|
raise ExtractorError('wrong username or password', expected=True)
|
||||||
|
|
||||||
if self._html_search_regex(
|
if self._html_search_regex(
|
||||||
r'(Logout Other Devices)', logged_page, 'logout devices button', default=None):
|
r'(?P<button_text>Logout Other Devices)', logged_page, 'logout device button',
|
||||||
|
group='button_text', fatal=False, default=''):
|
||||||
logout_device_form = self._hidden_inputs(logged_page)
|
logout_device_form = self._hidden_inputs(logged_page)
|
||||||
self._download_webpage(
|
self._download_webpage(
|
||||||
self._LOGOUT_DEVICES_API, None, headers={'Referer': self._LOGIN_API},
|
self._LOGOUT_DEVICES_API, None, headers={'Referer': self._LOGIN_API},
|
||||||
|
@ -54,25 +56,28 @@ class BrilliantpalaIE(InfoExtractor):
|
||||||
course_id, content_id = self._match_valid_url(url).group('course_id', 'content_id')
|
course_id, content_id = self._match_valid_url(url).group('course_id', 'content_id')
|
||||||
video_id = f'{course_id}-{content_id}'
|
video_id = f'{course_id}-{content_id}'
|
||||||
|
|
||||||
username = self._get_logged_in_username(url, video_id)
|
username = self._get_logged_in_username(self._download_webpage(url, video_id))
|
||||||
|
|
||||||
content_json = self._download_json(
|
content_json = self._download_json(
|
||||||
self._CONTENT_API.format(content_id=content_id), video_id,
|
self._CONTENT_API.format(content_id=content_id), video_id,
|
||||||
note='Fetching content info', errnote='Unable to fetch content info')
|
note='Fetching content info', errnote='Unable to fetch content info')
|
||||||
|
|
||||||
entries = []
|
entries = []
|
||||||
for stream in traverse_obj(content_json, ('video', 'streams', lambda _, v: v['id'] and v['url'])):
|
for stream in traverse_obj(content_json, ('video', 'streams')):
|
||||||
formats = self._extract_m3u8_formats(stream['url'], video_id, fatal=False)
|
formats = self._extract_m3u8_formats(
|
||||||
if not formats:
|
m3u8_url=stream['url'], video_id=video_id)
|
||||||
continue
|
for format in formats:
|
||||||
entries.append({
|
format['hls_aes'] = {
|
||||||
|
'uri': self._HLS_AES_URI.format(content_id=content_id)}
|
||||||
|
entry = {
|
||||||
'id': str(stream['id']),
|
'id': str(stream['id']),
|
||||||
'title': content_json.get('title'),
|
'title': dict_get(content_json, 'title', ''),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'hls_aes': {'uri': self._HLS_AES_URI.format(content_id=content_id)},
|
|
||||||
'http_headers': {'X-Key': hashlib.sha256(username.encode('ascii')).hexdigest()},
|
'http_headers': {'X-Key': hashlib.sha256(username.encode('ascii')).hexdigest()},
|
||||||
'thumbnail': content_json.get('cover_image'),
|
'thumbnail': content_json.get('cover_image'),
|
||||||
})
|
'live_status': 'not_live',
|
||||||
|
}
|
||||||
|
entries.append(entry)
|
||||||
|
|
||||||
return self.playlist_result(
|
return self.playlist_result(
|
||||||
entries, playlist_id=video_id, playlist_title=content_json.get('title'))
|
entries, playlist_id=video_id, playlist_title=content_json.get('title'))
|
||||||
|
@ -99,7 +104,11 @@ class BrilliantpalaElearnIE(BrilliantpalaIE):
|
||||||
},
|
},
|
||||||
}]
|
}]
|
||||||
|
|
||||||
_DOMAIN = BrilliantpalaIE._DOMAIN.format(subdomain='elearn')
|
_SUBDOMIAN = 'elearn'
|
||||||
|
|
||||||
|
def _initialize_pre_login(self):
|
||||||
|
self._DOMAIN = super()._DOMAIN.format(subdomain=self._SUBDOMIAN)
|
||||||
|
super()._initialize_pre_login()
|
||||||
|
|
||||||
|
|
||||||
class BrilliantpalaClassesIE(BrilliantpalaIE):
|
class BrilliantpalaClassesIE(BrilliantpalaIE):
|
||||||
|
@ -123,4 +132,8 @@ class BrilliantpalaClassesIE(BrilliantpalaIE):
|
||||||
},
|
},
|
||||||
}]
|
}]
|
||||||
|
|
||||||
_DOMAIN = BrilliantpalaIE._DOMAIN.format(subdomain='classes')
|
_SUBDOMIAN = 'classes'
|
||||||
|
|
||||||
|
def _initialize_pre_login(self):
|
||||||
|
self._DOMAIN = super()._DOMAIN.format(subdomain=self._SUBDOMIAN)
|
||||||
|
super()._initialize_pre_login()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user