mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-28 07:36:52 +01:00
[turner] fix secure m3u8 formats downloading
This commit is contained in:
parent
5bc8a73af6
commit
b8079a40bc
@ -83,7 +83,10 @@ def real_download(self, filename, info_dict):
|
|||||||
|
|
||||||
self._prepare_and_start_frag_download(ctx)
|
self._prepare_and_start_frag_download(ctx)
|
||||||
|
|
||||||
|
extra_query = None
|
||||||
extra_param_to_segment_url = info_dict.get('extra_param_to_segment_url')
|
extra_param_to_segment_url = info_dict.get('extra_param_to_segment_url')
|
||||||
|
if extra_param_to_segment_url:
|
||||||
|
extra_query = compat_urlparse.parse_qs(extra_param_to_segment_url)
|
||||||
i = 0
|
i = 0
|
||||||
media_sequence = 0
|
media_sequence = 0
|
||||||
decrypt_info = {'METHOD': 'NONE'}
|
decrypt_info = {'METHOD': 'NONE'}
|
||||||
@ -97,8 +100,8 @@ def real_download(self, filename, info_dict):
|
|||||||
if re.match(r'^https?://', line)
|
if re.match(r'^https?://', line)
|
||||||
else compat_urlparse.urljoin(man_url, line))
|
else compat_urlparse.urljoin(man_url, line))
|
||||||
frag_filename = '%s-Frag%d' % (ctx['tmpfilename'], i)
|
frag_filename = '%s-Frag%d' % (ctx['tmpfilename'], i)
|
||||||
if extra_param_to_segment_url:
|
if extra_query:
|
||||||
frag_url = update_url_query(frag_url, extra_param_to_segment_url)
|
frag_url = update_url_query(frag_url, extra_query)
|
||||||
success = ctx['dl'].download(frag_filename, {'url': frag_url})
|
success = ctx['dl'].download(frag_filename, {'url': frag_url})
|
||||||
if not success:
|
if not success:
|
||||||
return False
|
return False
|
||||||
@ -124,8 +127,8 @@ def real_download(self, filename, info_dict):
|
|||||||
if not re.match(r'^https?://', decrypt_info['URI']):
|
if not re.match(r'^https?://', decrypt_info['URI']):
|
||||||
decrypt_info['URI'] = compat_urlparse.urljoin(
|
decrypt_info['URI'] = compat_urlparse.urljoin(
|
||||||
man_url, decrypt_info['URI'])
|
man_url, decrypt_info['URI'])
|
||||||
if extra_param_to_segment_url:
|
if extra_query:
|
||||||
decrypt_info['URI'] = update_url_query(decrypt_info['URI'], extra_param_to_segment_url)
|
decrypt_info['URI'] = update_url_query(decrypt_info['URI'], extra_query)
|
||||||
decrypt_info['KEY'] = self.ydl.urlopen(decrypt_info['URI']).read()
|
decrypt_info['KEY'] = self.ydl.urlopen(decrypt_info['URI']).read()
|
||||||
elif line.startswith('#EXT-X-MEDIA-SEQUENCE'):
|
elif line.startswith('#EXT-X-MEDIA-SEQUENCE'):
|
||||||
media_sequence = int(line[22:])
|
media_sequence = int(line[22:])
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
parse_duration,
|
parse_duration,
|
||||||
xpath_attr,
|
xpath_attr,
|
||||||
update_url_query,
|
update_url_query,
|
||||||
|
compat_urlparse,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -87,8 +88,18 @@ def _extract_cvp_info(self, data_src, video_id, path_data={}):
|
|||||||
if ext == 'smil':
|
if ext == 'smil':
|
||||||
formats.extend(self._extract_smil_formats(video_url, video_id, fatal=False))
|
formats.extend(self._extract_smil_formats(video_url, video_id, fatal=False))
|
||||||
elif ext == 'm3u8':
|
elif ext == 'm3u8':
|
||||||
formats.extend(self._extract_m3u8_formats(
|
m3u8_formats = self._extract_m3u8_formats(
|
||||||
video_url, video_id, 'mp4', m3u8_id=format_id, fatal=False))
|
video_url, video_id, 'mp4', m3u8_id=format_id, fatal=False)
|
||||||
|
if m3u8_formats:
|
||||||
|
# Sometimes final URLs inside m3u8 are unsigned, let's fix this
|
||||||
|
# ourselves
|
||||||
|
qs = compat_urlparse.urlparse(video_url).query
|
||||||
|
if qs:
|
||||||
|
query = compat_urlparse.parse_qs(qs)
|
||||||
|
for m3u8_format in m3u8_formats:
|
||||||
|
m3u8_format['url'] = update_url_query(m3u8_format['url'], query)
|
||||||
|
m3u8_format['extra_param_to_segment_url'] = qs
|
||||||
|
formats.extend(m3u8_formats)
|
||||||
elif ext == 'f4m':
|
elif ext == 'f4m':
|
||||||
formats.extend(self._extract_f4m_formats(
|
formats.extend(self._extract_f4m_formats(
|
||||||
update_url_query(video_url, {'hdcore': '3.7.0'}),
|
update_url_query(video_url, {'hdcore': '3.7.0'}),
|
||||||
|
@ -33,9 +33,7 @@ def _extract_uplynk_info(self, uplynk_content_url):
|
|||||||
formats = self._extract_m3u8_formats('http://content.uplynk.com/%s.m3u8' % path, display_id, 'mp4')
|
formats = self._extract_m3u8_formats('http://content.uplynk.com/%s.m3u8' % path, display_id, 'mp4')
|
||||||
if session_id:
|
if session_id:
|
||||||
for f in formats:
|
for f in formats:
|
||||||
f['extra_param_to_segment_url'] = {
|
f['extra_param_to_segment_url'] = 'pbs=' + session_id
|
||||||
'pbs': session_id,
|
|
||||||
}
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
asset = self._download_json('http://content.uplynk.com/player/assetinfo/%s.json' % path, display_id)
|
asset = self._download_json('http://content.uplynk.com/player/assetinfo/%s.json' % path, display_id)
|
||||||
if asset.get('error') == 1:
|
if asset.get('error') == 1:
|
||||||
|
Loading…
Reference in New Issue
Block a user