1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-23 00:54:31 +01:00

[extractor/common] Allow protocols to be skipped in _extract_akamai_formats

This commit is contained in:
Jeremie J. Jarosh 2019-08-31 15:49:15 -05:00
parent 36e98a143c
commit 400dcfe257

View File

@ -2547,27 +2547,29 @@ class InfoExtractor(object):
entries.append(media_info) entries.append(media_info)
return entries return entries
def _extract_akamai_formats(self, manifest_url, video_id, hosts={}): def _extract_akamai_formats(self, manifest_url, video_id, hosts={}, skip_protocols=[]):
formats = [] formats = []
hdcore_sign = 'hdcore=3.7.0' if 'f4m' not in skip_protocols:
f4m_url = re.sub(r'(https?://[^/]+)/i/', r'\1/z/', manifest_url).replace('/master.m3u8', '/manifest.f4m') hdcore_sign = 'hdcore=3.7.0'
hds_host = hosts.get('hds') f4m_url = re.sub(r'(https?://[^/]+)/i/', r'\1/z/', manifest_url).replace('/master.m3u8', '/manifest.f4m')
if hds_host: hds_host = hosts.get('hds')
f4m_url = re.sub(r'(https?://)[^/]+', r'\1' + hds_host, f4m_url) if hds_host:
if 'hdcore=' not in f4m_url: f4m_url = re.sub(r'(https?://)[^/]+', r'\1' + hds_host, f4m_url)
f4m_url += ('&' if '?' in f4m_url else '?') + hdcore_sign if 'hdcore=' not in f4m_url:
f4m_formats = self._extract_f4m_formats( f4m_url += ('&' if '?' in f4m_url else '?') + hdcore_sign
f4m_url, video_id, f4m_id='hds', fatal=False) f4m_formats = self._extract_f4m_formats(
for entry in f4m_formats: f4m_url, video_id, f4m_id='hds', fatal=False)
entry.update({'extra_param_to_segment_url': hdcore_sign}) for entry in f4m_formats:
formats.extend(f4m_formats) entry.update({'extra_param_to_segment_url': hdcore_sign})
m3u8_url = re.sub(r'(https?://[^/]+)/z/', r'\1/i/', manifest_url).replace('/manifest.f4m', '/master.m3u8') formats.extend(f4m_formats)
hls_host = hosts.get('hls') if 'm3u8' not in skip_protocols:
if hls_host: m3u8_url = re.sub(r'(https?://[^/]+)/z/', r'\1/i/', manifest_url).replace('/manifest.f4m', '/master.m3u8')
m3u8_url = re.sub(r'(https?://)[^/]+', r'\1' + hls_host, m3u8_url) hls_host = hosts.get('hls')
formats.extend(self._extract_m3u8_formats( if hls_host:
m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_url = re.sub(r'(https?://)[^/]+', r'\1' + hls_host, m3u8_url)
m3u8_id='hls', fatal=False)) formats.extend(self._extract_m3u8_formats(
m3u8_url, video_id, 'mp4', 'm3u8_native',
m3u8_id='hls', fatal=False))
return formats return formats
def _extract_wowza_formats(self, url, video_id, m3u8_entry_protocol='m3u8_native', skip_protocols=[]): def _extract_wowza_formats(self, url, video_id, m3u8_entry_protocol='m3u8_native', skip_protocols=[]):