mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-10-06 17:37:08 +02:00
[ie/zaiko] Add support jwt-protected video urls; clean code
This commit is contained in:
parent
db50f19d76
commit
c01cb600f5
@ -66,7 +66,9 @@ def _real_extract(self, url):
|
|||||||
stream_meta['stream-access']['video_source'], video_id,
|
stream_meta['stream-access']['video_source'], video_id,
|
||||||
'Downloading player page', headers={'referer': 'https://zaiko.io/'})
|
'Downloading player page', headers={'referer': 'https://zaiko.io/'})
|
||||||
player_meta = self._parse_vue_element_attr('player', player_page, video_id)
|
player_meta = self._parse_vue_element_attr('player', player_page, video_id)
|
||||||
status = traverse_obj(player_meta, ('initial_event_info', 'status', {str}))
|
initial_event_info = player_meta['initial_event_info']
|
||||||
|
|
||||||
|
status = traverse_obj(initial_event_info, ('status', {str}))
|
||||||
live_status, msg, expected = {
|
live_status, msg, expected = {
|
||||||
'vod': ('was_live', 'No VOD stream URL was found', False),
|
'vod': ('was_live', 'No VOD stream URL was found', False),
|
||||||
'archiving': ('post_live', 'Event VOD is still being processed', True),
|
'archiving': ('post_live', 'Event VOD is still being processed', True),
|
||||||
@ -80,14 +82,21 @@ def _real_extract(self, url):
|
|||||||
'cancelled': ('not_live', 'Event has been cancelled', True),
|
'cancelled': ('not_live', 'Event has been cancelled', True),
|
||||||
}.get(status) or ('not_live', f'Unknown event status "{status}"', False)
|
}.get(status) or ('not_live', f'Unknown event status "{status}"', False)
|
||||||
|
|
||||||
stream_url = traverse_obj(player_meta, ('initial_event_info', 'endpoint', {url_or_none}))
|
if traverse_obj(initial_event_info, ('is_jwt_protected', {bool})):
|
||||||
|
stream_url = self._download_json(traverse_obj(
|
||||||
|
initial_event_info, ('jwt_token_url', {url_or_none})), video_id,
|
||||||
|
note='Downloading jwt-protected stream url',
|
||||||
|
errnote='Failed to download jwt-protected stream url')['playback_url']
|
||||||
|
else:
|
||||||
|
stream_url = traverse_obj(initial_event_info, ('endpoint', {url_or_none}))
|
||||||
|
|
||||||
formats = self._extract_m3u8_formats(
|
formats = self._extract_m3u8_formats(
|
||||||
stream_url, video_id, live=True, fatal=False) if stream_url else []
|
stream_url, video_id, live=True, fatal=False) if stream_url else []
|
||||||
if not formats:
|
if not formats:
|
||||||
self.raise_no_formats(msg, expected=expected)
|
self.raise_no_formats(msg, expected=expected)
|
||||||
|
|
||||||
thumbnail_urls = [
|
thumbnail_urls = [
|
||||||
traverse_obj(player_meta, ('initial_event_info', 'poster_url')),
|
traverse_obj(initial_event_info, ('poster_url', {url_or_none})),
|
||||||
self._og_search_thumbnail(self._download_webpage(
|
self._og_search_thumbnail(self._download_webpage(
|
||||||
f'https://zaiko.io/event/{video_id}', video_id, 'Downloading event page', fatal=False) or ''),
|
f'https://zaiko.io/event/{video_id}', video_id, 'Downloading event page', fatal=False) or ''),
|
||||||
]
|
]
|
||||||
@ -103,9 +112,7 @@ def _real_extract(self, url):
|
|||||||
'release_timestamp': ('stream', 'start', 'timestamp', {int_or_none}),
|
'release_timestamp': ('stream', 'start', 'timestamp', {int_or_none}),
|
||||||
'categories': ('event', 'genres', ..., {lambda x: x or None}),
|
'categories': ('event', 'genres', ..., {lambda x: x or None}),
|
||||||
}),
|
}),
|
||||||
**traverse_obj(player_meta, ('initial_event_info', {
|
'alt_title': traverse_obj(initial_event_info, ('title', {str})),
|
||||||
'alt_title': ('title', {str}),
|
|
||||||
})),
|
|
||||||
'thumbnails': [{'url': url, 'id': url_basename(url)} for url in thumbnail_urls if url_or_none(url)]
|
'thumbnails': [{'url': url, 'id': url_basename(url)} for url in thumbnail_urls if url_or_none(url)]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user