projects
/
youtube-dl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[cnn] add support for money.cnn.com videos(closes #2797)
[youtube-dl]
/
youtube_dl
/
downloader
/
hls.py
diff --git
a/youtube_dl/downloader/hls.py
b/youtube_dl/downloader/hls.py
index 1d5f178a036cdffc60b00b6a2b6284cc7fb20c89..8d7971e5d7042e5917deaf589cdebac7d488cd10 100644
(file)
--- a/
youtube_dl/downloader/hls.py
+++ b/
youtube_dl/downloader/hls.py
@@
-20,6
+20,7
@@
from ..utils import (
encodeFilename,
sanitize_open,
parse_m3u8_attributes,
encodeFilename,
sanitize_open,
parse_m3u8_attributes,
+ update_url_query,
)
)
@@
-50,7
+51,7
@@
class HlsFD(FragmentFD):
# 4. https://tools.ietf.org/html/draft-pantos-http-live-streaming-17#section-4.3.3.5
)
check_results = [not re.search(feature, manifest) for feature in UNSUPPORTED_FEATURES]
# 4. https://tools.ietf.org/html/draft-pantos-http-live-streaming-17#section-4.3.3.5
)
check_results = [not re.search(feature, manifest) for feature in UNSUPPORTED_FEATURES]
- check_results.append(
not (re.search(r'#EXT-X-KEY:METHOD=AES-128', manifest) and not can_decrypt_frag)
)
+ check_results.append(
can_decrypt_frag or '#EXT-X-KEY:METHOD=AES-128' not in manifest
)
return all(check_results)
def real_download(self, filename, info_dict):
return all(check_results)
def real_download(self, filename, info_dict):
@@
-82,6
+83,7
@@
class HlsFD(FragmentFD):
self._prepare_and_start_frag_download(ctx)
self._prepare_and_start_frag_download(ctx)
+ extra_param_to_segment_url = info_dict.get('extra_param_to_segment_url')
i = 0
media_sequence = 0
decrypt_info = {'METHOD': 'NONE'}
i = 0
media_sequence = 0
decrypt_info = {'METHOD': 'NONE'}
@@
-95,6
+97,8
@@
class HlsFD(FragmentFD):
if re.match(r'^https?://', line)
else compat_urlparse.urljoin(man_url, line))
frag_filename = '%s-Frag%d' % (ctx['tmpfilename'], i)
if re.match(r'^https?://', line)
else compat_urlparse.urljoin(man_url, line))
frag_filename = '%s-Frag%d' % (ctx['tmpfilename'], i)
+ if extra_param_to_segment_url:
+ frag_url = update_url_query(frag_url, extra_param_to_segment_url)
success = ctx['dl'].download(frag_filename, {'url': frag_url})
if not success:
return False
success = ctx['dl'].download(frag_filename, {'url': frag_url})
if not success:
return False
@@
-102,8
+106,9
@@
class HlsFD(FragmentFD):
frag_content = down.read()
down.close()
if decrypt_info['METHOD'] == 'AES-128':
frag_content = down.read()
down.close()
if decrypt_info['METHOD'] == 'AES-128':
- iv = decrypt_info.get('IV') or compat_struct_pack(">8xq", media_sequence)
- frag_content = AES.new(decrypt_info['KEY'], AES.MODE_CBC, iv).decrypt(frag_content)
+ iv = decrypt_info.get('IV') or compat_struct_pack('>8xq', media_sequence)
+ frag_content = AES.new(
+ decrypt_info['KEY'], AES.MODE_CBC, iv).decrypt(frag_content)
ctx['dest_stream'].write(frag_content)
frags_filenames.append(frag_sanitized)
# We only download the first fragment during the test
ctx['dest_stream'].write(frag_content)
frags_filenames.append(frag_sanitized)
# We only download the first fragment during the test
@@
-117,7
+122,10
@@
class HlsFD(FragmentFD):
if 'IV' in decrypt_info:
decrypt_info['IV'] = binascii.unhexlify(decrypt_info['IV'][2:])
if not re.match(r'^https?://', decrypt_info['URI']):
if 'IV' in decrypt_info:
decrypt_info['IV'] = binascii.unhexlify(decrypt_info['IV'][2:])
if not re.match(r'^https?://', decrypt_info['URI']):
- decrypt_info['URI'] = compat_urlparse.urljoin(man_url, decrypt_info['URI'])
+ decrypt_info['URI'] = compat_urlparse.urljoin(
+ man_url, decrypt_info['URI'])
+ if extra_param_to_segment_url:
+ decrypt_info['URI'] = update_url_query(decrypt_info['URI'], extra_param_to_segment_url)
decrypt_info['KEY'] = self.ydl.urlopen(decrypt_info['URI']).read()
elif line.startswith('#EXT-X-MEDIA-SEQUENCE'):
media_sequence = int(line[22:])
decrypt_info['KEY'] = self.ydl.urlopen(decrypt_info['URI']).read()
elif line.startswith('#EXT-X-MEDIA-SEQUENCE'):
media_sequence = int(line[22:])