From c42100b18d448901e66715b93e2a222f635e2884 Mon Sep 17 00:00:00 2001 From: ufukk <5383665+ufukk@users.noreply.github.com> Date: Sun, 3 Dec 2023 01:09:15 +0300 Subject: [PATCH] Update yt_dlp/extractor/trtworld.py Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com> --- yt_dlp/extractor/trtworld.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/yt_dlp/extractor/trtworld.py b/yt_dlp/extractor/trtworld.py index 8e1c261cf9..d82a749231 100644 --- a/yt_dlp/extractor/trtworld.py +++ b/yt_dlp/extractor/trtworld.py @@ -31,10 +31,23 @@ class TrtWorldIE(InfoExtractor): def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) - nuxtjs_data = self._search_nuxt_data(webpage, display_id) - video_url = traverse_obj(nuxtjs_data, ('videoData', 'content', 'platforms', 'website', 'metadata', 'hls_url', )) - published_date_str = traverse_obj(nuxtjs_data, ('videoData', 'content', 'published', 'date', )) - formats, subtitles = self._extract_m3u8_formats_and_subtitles(video_url, display_id) + nuxtjs_data = self._search_nuxt_data(webpage, display_id)['videoData']['content'] + formats = [] + for media_url in traverse_obj(nuxtjs_data, ( + '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 { 'id': str(display_id), 'formats': formats,