mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-27 21:59:17 +01:00
[generic] Improve KVS player extraction (#2328)
Closes #2281 Authored by: trassshhub
This commit is contained in:
parent
a4a426023d
commit
11c861702d
1 changed files with 15 additions and 13 deletions
|
@ -28,6 +28,7 @@ from ..utils import (
|
||||||
mimetype2ext,
|
mimetype2ext,
|
||||||
orderedSet,
|
orderedSet,
|
||||||
parse_duration,
|
parse_duration,
|
||||||
|
parse_resolution,
|
||||||
sanitized_Request,
|
sanitized_Request,
|
||||||
smuggle_url,
|
smuggle_url,
|
||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
|
@ -3774,20 +3775,21 @@ class GenericIE(InfoExtractor):
|
||||||
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
|
||||||
'url': self._kvs_getrealurl(flashvars[key], flashvars['license_code']),
|
format_id = flashvars.get(f'{key}_text', key)
|
||||||
'format_id': flashvars.get(key + '_text', key),
|
formats.append({
|
||||||
'ext': 'mp4',
|
'url': self._kvs_getrealurl(flashvars[key], flashvars['license_code']),
|
||||||
}
|
'format_id': format_id,
|
||||||
height = re.search(r'%s_(\d+)p\.mp4(?:/[?].*)?$' % flashvars['video_id'], flashvars[key])
|
'ext': 'mp4',
|
||||||
if height:
|
**(parse_resolution(format_id) or parse_resolution(flashvars[key]))
|
||||||
next_format['height'] = int(height.group(1))
|
})
|
||||||
else:
|
if not formats[-1].get('height'):
|
||||||
next_format['quality'] = 1
|
formats[-1]['quality'] = 1
|
||||||
formats.append(next_format)
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue