Extract additional dash formats

This commit is contained in:
sepro 2024-05-08 22:53:00 +02:00
parent 311b9885e2
commit 505080082c
1 changed files with 8 additions and 4 deletions

View File

@ -451,6 +451,7 @@ class VKIE(VKBaseIE):
info_page, 'view count', default=None)) info_page, 'view count', default=None))
formats = [] formats = []
subtitles = {}
for format_id, format_url in data.items(): for format_id, format_url in data.items():
format_url = url_or_none(format_url) format_url = url_or_none(format_url)
if not format_url or not format_url.startswith(('http', '//', 'rtmp')): if not format_url or not format_url.startswith(('http', '//', 'rtmp')):
@ -463,15 +464,18 @@ class VKIE(VKBaseIE):
'format_id': format_id, 'format_id': format_id,
'url': format_url, 'url': format_url,
'ext': 'mp4', 'ext': 'mp4',
'source_preference': 1,
'height': height, 'height': height,
}) })
elif format_id == 'hls': elif format_id == 'hls':
formats.extend(self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
format_url, video_id, 'mp4', 'm3u8_native', format_url, video_id, 'mp4', 'm3u8_native',
m3u8_id=format_id, fatal=False, live=is_live)) m3u8_id=format_id, fatal=False, live=is_live))
elif format_id == 'dash_sep': elif format_id.startswith('dash_'):
formats.extend(self._extract_mpd_formats( fmts, subs = self._extract_mpd_formats_and_subtitles(
format_url, video_id, mpd_id='dash', fatal=False)) format_url, video_id, mpd_id=format_id, fatal=False)
formats.extend(fmts)
self._merge_subtitles(subs, target=subtitles)
elif format_id == 'rtmp': elif format_id == 'rtmp':
formats.append({ formats.append({
'format_id': format_id, 'format_id': format_id,
@ -479,7 +483,6 @@ class VKIE(VKBaseIE):
'ext': 'flv', 'ext': 'flv',
}) })
subtitles = {}
for sub in data.get('subs') or {}: for sub in data.get('subs') or {}:
subtitles.setdefault(sub.get('lang', 'en'), []).append({ subtitles.setdefault(sub.get('lang', 'en'), []).append({
'ext': sub.get('title', '.srt').split('.')[-1], 'ext': sub.get('title', '.srt').split('.')[-1],
@ -500,6 +503,7 @@ class VKIE(VKBaseIE):
'comment_count': int_or_none(mv_data.get('commcount')), 'comment_count': int_or_none(mv_data.get('commcount')),
'is_live': is_live, 'is_live': is_live,
'subtitles': subtitles, 'subtitles': subtitles,
'_format_sort_fields': ('res', 'source'),
} }