mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-13 23:02:34 +00:00
#79 Fix HLS AES-128 with multiple keys in external downloaders
Authored-by: shirtjs <2660574+shirtjs@users.noreply.github.com>
This commit is contained in:
parent
068693675e
commit
7620cd46c3
2 changed files with 12 additions and 5 deletions
|
@ -126,11 +126,13 @@ class ExternalFD(FileDownloader):
|
||||||
for [i, url] in enumerate(info_dict['url_list']):
|
for [i, url] in enumerate(info_dict['url_list']):
|
||||||
tmpsegmentname = '%s_%s.frag' % (tmpfilename, i)
|
tmpsegmentname = '%s_%s.frag' % (tmpfilename, i)
|
||||||
file_list.append(tmpsegmentname)
|
file_list.append(tmpsegmentname)
|
||||||
|
key_list = info_dict.get('key_list')
|
||||||
|
decrypt_info = None
|
||||||
dest, _ = sanitize_open(tmpfilename, 'wb')
|
dest, _ = sanitize_open(tmpfilename, 'wb')
|
||||||
for i in file_list:
|
for i, file in enumerate(file_list):
|
||||||
src, _ = sanitize_open(i, 'rb')
|
src, _ = sanitize_open(file, 'rb')
|
||||||
if 'decrypt_info' in info_dict:
|
if key_list:
|
||||||
decrypt_info = info_dict['decrypt_info']
|
decrypt_info = next((x for x in key_list if x['INDEX'] == i), decrypt_info)
|
||||||
if decrypt_info['METHOD'] == 'AES-128':
|
if decrypt_info['METHOD'] == 'AES-128':
|
||||||
iv = decrypt_info.get('IV')
|
iv = decrypt_info.get('IV')
|
||||||
decrypt_info['KEY'] = decrypt_info.get('KEY') or self.ydl.urlopen(
|
decrypt_info['KEY'] = decrypt_info.get('KEY') or self.ydl.urlopen(
|
||||||
|
|
|
@ -134,6 +134,7 @@ class HlsFD(FragmentFD):
|
||||||
i = 0
|
i = 0
|
||||||
media_sequence = 0
|
media_sequence = 0
|
||||||
decrypt_info = {'METHOD': 'NONE'}
|
decrypt_info = {'METHOD': 'NONE'}
|
||||||
|
key_list = []
|
||||||
byte_range = {}
|
byte_range = {}
|
||||||
frag_index = 0
|
frag_index = 0
|
||||||
ad_frag_next = False
|
ad_frag_next = False
|
||||||
|
@ -215,6 +216,10 @@ class HlsFD(FragmentFD):
|
||||||
decrypt_info['URI'] = update_url_query(decrypt_info['URI'], extra_query)
|
decrypt_info['URI'] = update_url_query(decrypt_info['URI'], extra_query)
|
||||||
if decrypt_url != decrypt_info['URI']:
|
if decrypt_url != decrypt_info['URI']:
|
||||||
decrypt_info['KEY'] = None
|
decrypt_info['KEY'] = None
|
||||||
|
key_data = decrypt_info.copy()
|
||||||
|
key_data['INDEX'] = frag_index
|
||||||
|
key_list.append(key_data)
|
||||||
|
|
||||||
elif line.startswith('#EXT-X-MEDIA-SEQUENCE'):
|
elif line.startswith('#EXT-X-MEDIA-SEQUENCE'):
|
||||||
media_sequence = int(line[22:])
|
media_sequence = int(line[22:])
|
||||||
elif line.startswith('#EXT-X-BYTERANGE'):
|
elif line.startswith('#EXT-X-BYTERANGE'):
|
||||||
|
@ -232,7 +237,7 @@ class HlsFD(FragmentFD):
|
||||||
if real_downloader:
|
if real_downloader:
|
||||||
info_copy = info_dict.copy()
|
info_copy = info_dict.copy()
|
||||||
info_copy['url_list'] = fragment_urls
|
info_copy['url_list'] = fragment_urls
|
||||||
info_copy['decrypt_info'] = decrypt_info
|
info_copy['key_list'] = key_list
|
||||||
fd = real_downloader(self.ydl, self.params)
|
fd = real_downloader(self.ydl, self.params)
|
||||||
# TODO: Make progress updates work without hooking twice
|
# TODO: Make progress updates work without hooking twice
|
||||||
# for ph in self._progress_hooks:
|
# for ph in self._progress_hooks:
|
||||||
|
|
Loading…
Reference in a new issue