mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-28 07:36:52 +01:00
[generic] Improve KVS player extraction (#2328)
Closes #2281 Authored by: trassshhub
This commit is contained in:
parent
a4a426023d
commit
11c861702d
@ -28,6 +28,7 @@
|
|||||||
mimetype2ext,
|
mimetype2ext,
|
||||||
orderedSet,
|
orderedSet,
|
||||||
parse_duration,
|
parse_duration,
|
||||||
|
parse_resolution,
|
||||||
sanitized_Request,
|
sanitized_Request,
|
||||||
smuggle_url,
|
smuggle_url,
|
||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
@ -3774,20 +3775,21 @@ def filter_video(urls):
|
|||||||
protocol, _, _ = url.partition('/')
|
protocol, _, _ = url.partition('/')
|
||||||
thumbnail = protocol + thumbnail
|
thumbnail = protocol + thumbnail
|
||||||
|
|
||||||
|
url_keys = list(filter(re.compile(r'video_url|video_alt_url\d+').fullmatch, flashvars.keys()))
|
||||||
formats = []
|
formats = []
|
||||||
for key in ('video_url', 'video_alt_url', 'video_alt_url2'):
|
for key in url_keys:
|
||||||
if key in flashvars and '/get_file/' in flashvars[key]:
|
if '/get_file/' not in flashvars[key]:
|
||||||
next_format = {
|
continue
|
||||||
|
format_id = flashvars.get(f'{key}_text', key)
|
||||||
|
formats.append({
|
||||||
'url': self._kvs_getrealurl(flashvars[key], flashvars['license_code']),
|
'url': self._kvs_getrealurl(flashvars[key], flashvars['license_code']),
|
||||||
'format_id': flashvars.get(key + '_text', key),
|
'format_id': format_id,
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
}
|
**(parse_resolution(format_id) or parse_resolution(flashvars[key]))
|
||||||
height = re.search(r'%s_(\d+)p\.mp4(?:/[?].*)?$' % flashvars['video_id'], flashvars[key])
|
})
|
||||||
if height:
|
if not formats[-1].get('height'):
|
||||||
next_format['height'] = int(height.group(1))
|
formats[-1]['quality'] = 1
|
||||||
else:
|
|
||||||
next_format['quality'] = 1
|
|
||||||
formats.append(next_format)
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user