Skip to content

Commit

Permalink
[ie/zaiko] Support JWT video URLs (yt-dlp#10130)
Browse files Browse the repository at this point in the history
Closes yt-dlp#9798
Authored by: pzhlkj6612
  • Loading branch information
pzhlkj6612 authored Jul 2, 2024
1 parent 7509791 commit 7799e51
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions yt_dlp/extractor/zaiko.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ def _real_extract(self, url):
stream_meta['stream-access']['video_source'], video_id,
'Downloading player page', headers={'referer': 'https://zaiko.io/'})
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 = traverse_obj(player_meta, ('initial_event_info', {dict})) or {}

status = traverse_obj(initial_event_info, ('status', {str}))
live_status, msg, expected = {
'vod': ('was_live', 'No VOD stream URL was found', False),
'archiving': ('post_live', 'Event VOD is still being processed', True),
Expand All @@ -80,14 +82,20 @@ def _real_extract(self, url):
'cancelled': ('not_live', 'Event has been cancelled', True),
}.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(
initial_event_info['jwt_token_url'], video_id, 'Downloading JWT-protected stream URL',
'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(
stream_url, video_id, live=True, fatal=False) if stream_url else []
if not formats:
self.raise_no_formats(msg, expected=expected)

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(
f'https://zaiko.io/event/{video_id}', video_id, 'Downloading event page', fatal=False) or ''),
]
Expand All @@ -103,9 +111,7 @@ def _real_extract(self, url):
'release_timestamp': ('stream', 'start', 'timestamp', {int_or_none}),
'categories': ('event', 'genres', ..., {lambda x: x or None}),
}),
**traverse_obj(player_meta, ('initial_event_info', {
'alt_title': ('title', {str}),
})),
'alt_title': traverse_obj(initial_event_info, ('title', {str})),
'thumbnails': [{'url': url, 'id': url_basename(url)} for url in thumbnail_urls if url_or_none(url)],
}

Expand Down

0 comments on commit 7799e51

Please sign in to comment.