Update yt_dlp/extractor/trtworld.py

Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com>
This commit is contained in:
ufukk 2023-12-03 01:09:15 +03:00 committed by GitHub
parent 733e01fc9a
commit c42100b18d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,10 +31,23 @@ class TrtWorldIE(InfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
display_id = self._match_id(url) display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id) webpage = self._download_webpage(url, display_id)
nuxtjs_data = self._search_nuxt_data(webpage, display_id) nuxtjs_data = self._search_nuxt_data(webpage, display_id)['videoData']['content']
video_url = traverse_obj(nuxtjs_data, ('videoData', 'content', 'platforms', 'website', 'metadata', 'hls_url', )) formats = []
published_date_str = traverse_obj(nuxtjs_data, ('videoData', 'content', 'published', 'date', )) for media_url in traverse_obj(nuxtjs_data, (
formats, subtitles = self._extract_m3u8_formats_and_subtitles(video_url, display_id) 'platforms', ('website', 'ott'), 'metadata', ('hls_url', 'url'), {url_or_none})):
# Website sometimes serves mp4 files under `hls_url` key
if media_url.endswith('.m3u8'):
formats.extend(self._extract_m3u8_formats(media_url, display_id, fatal=False))
else:
formats.append({
'format_id': 'http',
'url': media_url,
})
if not formats:
if youtube_id := traverse_obj(nuxtjs_data, ('platforms', 'youtube', 'metadata', 'youtubeId')):
return self.url_result(youtube_id, 'Youtube')
raise ExtractorError('No video found', expected=True)
return { return {
'id': str(display_id), 'id': str(display_id),
'formats': formats, 'formats': formats,