mirror of https://github.com/yt-dlp/yt-dlp.git
[generic] Improve KVS player extraction (#2328)
Closes #2281 Authored by: trassshhub
This commit is contained in:
parent
a4a426023d
commit
11c861702d
|
@ -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
|
||||||
|
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