mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-10-31 07:50:11 +01:00
[ie/vk] Improve format extraction (#9885)
Closes #5675 Authored by: seproDev
This commit is contained in:
parent
b38018b781
commit
df5c9e733a
@ -451,6 +451,7 @@ def _real_extract(self, url):
|
|||||||
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')):
|
||||||
@ -462,12 +463,21 @@ def _real_extract(self, url):
|
|||||||
formats.append({
|
formats.append({
|
||||||
'format_id': format_id,
|
'format_id': format_id,
|
||||||
'url': format_url,
|
'url': format_url,
|
||||||
|
'ext': 'mp4',
|
||||||
|
'source_preference': 1,
|
||||||
'height': height,
|
'height': height,
|
||||||
})
|
})
|
||||||
elif format_id == 'hls':
|
elif format_id == 'hls':
|
||||||
formats.extend(self._extract_m3u8_formats(
|
fmts, subs = self._extract_m3u8_formats_and_subtitles(
|
||||||
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)
|
||||||
|
formats.extend(fmts)
|
||||||
|
self._merge_subtitles(subs, target=subtitles)
|
||||||
|
elif format_id.startswith('dash_'):
|
||||||
|
fmts, subs = self._extract_mpd_formats_and_subtitles(
|
||||||
|
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,
|
||||||
@ -475,7 +485,6 @@ def _real_extract(self, url):
|
|||||||
'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],
|
||||||
@ -496,6 +505,7 @@ def _real_extract(self, url):
|
|||||||
'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'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user