From 5c8b2ee9ecf8773eb463b4ae218f8313a6626b2f Mon Sep 17 00:00:00 2001 From: Lesmiscore Date: Sat, 24 Sep 2022 18:30:58 +0900 Subject: [PATCH] [extractor/RUTV] Fix warnings for livestreams (#5016) Authored by: Lesmiscore --- yt_dlp/extractor/rutv.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/yt_dlp/extractor/rutv.py b/yt_dlp/extractor/rutv.py index 0b07dc5ad..75da01f7d 100644 --- a/yt_dlp/extractor/rutv.py +++ b/yt_dlp/extractor/rutv.py @@ -141,7 +141,7 @@ def _real_extract(self, url): if media['errors']: raise ExtractorError('%s said: %s' % (self.IE_NAME, media['errors']), expected=True) - view_count = playlist.get('count_views') + view_count = int_or_none(playlist.get('count_views')) priority_transport = playlist['priority_transport'] thumbnail = media['picture'] @@ -152,6 +152,7 @@ def _real_extract(self, url): duration = int_or_none(media.get('duration')) formats = [] + subtitles = {} for transport, links in media['sources'].items(): for quality, url in links.items(): @@ -171,8 +172,10 @@ def _real_extract(self, url): 'vbr': str_to_int(quality), } elif transport == 'm3u8': - formats.extend(self._extract_m3u8_formats( - url, video_id, 'mp4', quality=preference, m3u8_id='hls')) + fmt, subs = self._extract_m3u8_formats_and_subtitles( + url, video_id, 'mp4', quality=preference, m3u8_id='hls') + formats.extend(fmt) + self._merge_subtitles(subs, target=subtitles) continue else: fmt = { @@ -186,7 +189,7 @@ def _real_extract(self, url): }) formats.append(fmt) - self._sort_formats(formats) + self._sort_formats(formats, ('source', )) return { 'id': video_id, @@ -196,5 +199,6 @@ def _real_extract(self, url): 'view_count': view_count, 'duration': duration, 'formats': formats, + 'subtitles': subtitles, 'is_live': is_live, }