summaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/vk.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:10:23 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:10:23 +0000
commit96011c9a0b8a4f10e6e06f76acc380d6a802bbee (patch)
tree30ded50e296e5d936800d19ada594982f10111d6 /yt_dlp/extractor/vk.py
parentAdding debian version 2024.04.09-1. (diff)
downloadyt-dlp-96011c9a0b8a4f10e6e06f76acc380d6a802bbee.tar.xz
yt-dlp-96011c9a0b8a4f10e6e06f76acc380d6a802bbee.zip
Merging upstream version 2024.05.26.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'yt_dlp/extractor/vk.py')
-rw-r--r--yt_dlp/extractor/vk.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/yt_dlp/extractor/vk.py b/yt_dlp/extractor/vk.py
index 7e3a3a9..9a3c75b 100644
--- a/yt_dlp/extractor/vk.py
+++ b/yt_dlp/extractor/vk.py
@@ -20,6 +20,7 @@ from ..utils import (
parse_resolution,
str_or_none,
str_to_int,
+ traverse_obj,
try_call,
unescapeHTML,
unified_timestamp,
@@ -27,7 +28,6 @@ from ..utils import (
url_or_none,
urlencode_postdata,
urljoin,
- traverse_obj,
)
@@ -451,6 +451,7 @@ class VKIE(VKBaseIE):
info_page, 'view count', default=None))
formats = []
+ subtitles = {}
for format_id, format_url in data.items():
format_url = url_or_none(format_url)
if not format_url or not format_url.startswith(('http', '//', 'rtmp')):
@@ -462,12 +463,21 @@ class VKIE(VKBaseIE):
formats.append({
'format_id': format_id,
'url': format_url,
+ 'ext': 'mp4',
+ 'source_preference': 1,
'height': height,
})
- elif format_id == 'hls':
- formats.extend(self._extract_m3u8_formats(
+ elif format_id.startswith('hls') and format_id != 'hls_live_playback':
+ fmts, subs = self._extract_m3u8_formats_and_subtitles(
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') and format_id not in ('dash_live_playback', 'dash_uni'):
+ 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':
formats.append({
'format_id': format_id,
@@ -475,7 +485,6 @@ class VKIE(VKBaseIE):
'ext': 'flv',
})
- subtitles = {}
for sub in data.get('subs') or {}:
subtitles.setdefault(sub.get('lang', 'en'), []).append({
'ext': sub.get('title', '.srt').split('.')[-1],
@@ -496,6 +505,7 @@ class VKIE(VKBaseIE):
'comment_count': int_or_none(mv_data.get('commcount')),
'is_live': is_live,
'subtitles': subtitles,
+ '_format_sort_fields': ('res', 'source'),
}