1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-02 17:22:31 +01:00

[extractor/common] improve Akamai HTTP format extraction

- Allow m3u8 manifest without an additional audio format
- Fix extraction for qualities starting with a number
Solution provided by @nixxo based on: https://stackoverflow.com/a/5984688
This commit is contained in:
Remita Amine 2020-12-02 21:37:14 +01:00 committed by nixxo
parent 98e248faa4
commit 0827033479
No known key found for this signature in database
GPG Key ID: E0DE62EF9A9BFAB2

View File

@ -2624,7 +2624,7 @@ def _extract_akamai_formats(self, manifest_url, video_id, hosts={}):
REPL_REGEX = r'https://[^/]+/i/([^,]+),([^/]+),([^/]+).csmil/.+'
qualities = re.match(REPL_REGEX, m3u8_url).group(2).split(',')
qualities_length = len(qualities)
if len(formats) in (qualities_length + 1, qualities_length * 2 + 1):
if len(formats) in (qualities_length, qualities_length + 1, qualities_length * 2, qualities_length * 2 + 1):
i = 0
http_formats = []
for f in formats:
@ -2633,7 +2633,7 @@ def _extract_akamai_formats(self, manifest_url, video_id, hosts={}):
http_f = f.copy()
del http_f['manifest_url']
http_url = re.sub(
REPL_REGEX, protocol + r'://%s/\1%s\3' % (http_host, qualities[i]), f['url'])
REPL_REGEX, protocol + r'://%s/\g<1>%s\3' % (http_host, qualities[i]), f['url'])
http_f.update({
'format_id': http_f['format_id'].replace('hls-', protocol + '-'),
'url': http_url,