0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-22 02:15:12 +00:00

[ie/olympics] Fix extraction (#10625)

Bugfix for 2f1ddfe12a

Closes #10592
Authored by: bashonly
This commit is contained in:
bashonly 2024-08-01 15:25:46 -05:00 committed by GitHub
parent 0088c6de23
commit 919540a964
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,7 +4,9 @@
ExtractorError, ExtractorError,
int_or_none, int_or_none,
parse_iso8601, parse_iso8601,
parse_qs,
try_get, try_get,
update_url,
url_or_none, url_or_none,
) )
from ..utils.traversal import traverse_obj from ..utils.traversal import traverse_obj
@ -24,9 +26,6 @@ class OlympicsReplayIE(InfoExtractor):
'thumbnail': 'https://img.olympics.com/images/image/private/t_1-1_1280/primary/nua4o7zwyaznoaejpbk2', 'thumbnail': 'https://img.olympics.com/images/image/private/t_1-1_1280/primary/nua4o7zwyaznoaejpbk2',
'duration': 7017.0, 'duration': 7017.0,
}, },
'params': {
'skip_download': True,
},
}, { }, {
'url': 'https://olympics.com/en/original-series/episode/b-boys-and-b-girls-take-the-spotlight-breaking-life-road-to-paris-2024', 'url': 'https://olympics.com/en/original-series/episode/b-boys-and-b-girls-take-the-spotlight-breaking-life-road-to-paris-2024',
'info_dict': { 'info_dict': {
@ -74,7 +73,7 @@ def _extract_from_nextjs_data(self, webpage, video_id):
is_live = traverse_obj(data, ('streamingStatus', {str})) == 'LIVE' is_live = traverse_obj(data, ('streamingStatus', {str})) == 'LIVE'
m3u8_url = traverse_obj(data, ('videoUrl', {url_or_none})) or data['streamUrl'] m3u8_url = traverse_obj(data, ('videoUrl', {url_or_none})) or data['streamUrl']
tokenized_url = m3u8_url if is_live else self._tokenize_url(m3u8_url, video_id) tokenized_url = self._tokenize_url(m3u8_url, data['jwtToken'], is_live, video_id)
try: try:
formats, subtitles = self._extract_m3u8_formats_and_subtitles( formats, subtitles = self._extract_m3u8_formats_and_subtitles(
@ -95,10 +94,20 @@ def _extract_from_nextjs_data(self, webpage, video_id):
}), }),
} }
def _tokenize_url(self, url, video_id): def _tokenize_url(self, url, token, is_live, video_id):
return self._download_json(
'https://metering.olympics.com/tokengenerator', video_id,
'Downloading tokenized m3u8 url', query={
**parse_qs(url),
'url': update_url(url, query=None),
'service-id': 'live' if is_live else 'vod',
'user-auth': token,
})['data']['url']
def _legacy_tokenize_url(self, url, video_id):
return self._download_json( return self._download_json(
'https://olympics.com/tokenGenerator', video_id, 'https://olympics.com/tokenGenerator', video_id,
'Downloading tokenized m3u8 url', query={'url': url}) 'Downloading legacy tokenized m3u8 url', query={'url': url})
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
@ -130,7 +139,7 @@ def _real_extract(self, url):
}) })
formats, subtitles = self._extract_m3u8_formats_and_subtitles( formats, subtitles = self._extract_m3u8_formats_and_subtitles(
self._tokenize_url(m3u8_url, video_uuid), video_uuid, 'mp4', m3u8_id='hls') self._legacy_tokenize_url(m3u8_url, video_uuid), video_uuid, 'mp4', m3u8_id='hls')
return { return {
'id': video_uuid, 'id': video_uuid,