mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-23 00:54:31 +01:00
[common] extract vbr, abr and fps for Unified Streaming Platform m3u8 manifests
This commit is contained in:
parent
51c2cd0b83
commit
00f4764cb7
@ -1207,6 +1207,7 @@ class InfoExtractor(object):
|
|||||||
'url': format_url(line.strip()),
|
'url': format_url(line.strip()),
|
||||||
'tbr': tbr,
|
'tbr': tbr,
|
||||||
'ext': ext,
|
'ext': ext,
|
||||||
|
'fps': float_or_none(last_info.get('FRAME-RATE')),
|
||||||
'protocol': entry_protocol,
|
'protocol': entry_protocol,
|
||||||
'preference': preference,
|
'preference': preference,
|
||||||
}
|
}
|
||||||
@ -1215,24 +1216,17 @@ class InfoExtractor(object):
|
|||||||
width_str, height_str = resolution.split('x')
|
width_str, height_str = resolution.split('x')
|
||||||
f['width'] = int(width_str)
|
f['width'] = int(width_str)
|
||||||
f['height'] = int(height_str)
|
f['height'] = int(height_str)
|
||||||
codecs = last_info.get('CODECS')
|
# Unified Streaming Platform
|
||||||
if codecs:
|
mobj = re.search(
|
||||||
vcodec, acodec = [None] * 2
|
r'audio.*?(?:%3D|=)(\d+)(?:-video.*?(?:%3D|=)(\d+))?', f['url'])
|
||||||
va_codecs = codecs.split(',')
|
if mobj:
|
||||||
if len(va_codecs) == 1:
|
abr, vbr = mobj.groups()
|
||||||
# Audio only entries usually come with single codec and
|
abr, vbr = float_or_none(abr, 1000), float_or_none(vbr, 1000)
|
||||||
# no resolution. For more robustness we also check it to
|
|
||||||
# be mp4 audio.
|
|
||||||
if not resolution and va_codecs[0].startswith('mp4a'):
|
|
||||||
vcodec, acodec = 'none', va_codecs[0]
|
|
||||||
else:
|
|
||||||
vcodec = va_codecs[0]
|
|
||||||
else:
|
|
||||||
vcodec, acodec = va_codecs[:2]
|
|
||||||
f.update({
|
f.update({
|
||||||
'acodec': acodec,
|
'vbr': vbr,
|
||||||
'vcodec': vcodec,
|
'abr': abr,
|
||||||
})
|
})
|
||||||
|
f.update(parse_codecs(last_info.get('CODECS')))
|
||||||
if last_media is not None:
|
if last_media is not None:
|
||||||
f['m3u8_media'] = last_media
|
f['m3u8_media'] = last_media
|
||||||
last_media = None
|
last_media = None
|
||||||
|
@ -9,7 +9,6 @@ from ..utils import (
|
|||||||
ExtractorError,
|
ExtractorError,
|
||||||
unified_strdate,
|
unified_strdate,
|
||||||
HEADRequest,
|
HEADRequest,
|
||||||
float_or_none,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -95,16 +94,7 @@ class WatIE(InfoExtractor):
|
|||||||
m3u8_url.replace('ios.', 'web.').replace('.m3u8', '.f4m'),
|
m3u8_url.replace('ios.', 'web.').replace('.m3u8', '.f4m'),
|
||||||
video_id, f4m_id='hds', fatal=False))
|
video_id, f4m_id='hds', fatal=False))
|
||||||
for m3u8_format in m3u8_formats:
|
for m3u8_format in m3u8_formats:
|
||||||
mobj = re.search(
|
vbr, abr = m3u8_format.get('vbr'), m3u8_format.get('abr')
|
||||||
r'audio.*?%3D(\d+)(?:-video.*?%3D(\d+))?', m3u8_format['url'])
|
|
||||||
if not mobj:
|
|
||||||
continue
|
|
||||||
abr, vbr = mobj.groups()
|
|
||||||
abr, vbr = float_or_none(abr, 1000), float_or_none(vbr, 1000)
|
|
||||||
m3u8_format.update({
|
|
||||||
'vbr': vbr,
|
|
||||||
'abr': abr,
|
|
||||||
})
|
|
||||||
if not vbr or not abr:
|
if not vbr or not abr:
|
||||||
continue
|
continue
|
||||||
f = m3u8_format.copy()
|
f = m3u8_format.copy()
|
||||||
|
Loading…
Reference in New Issue
Block a user