From 6797de75e059ec02ed91548ec8bfed8c89578344 Mon Sep 17 00:00:00 2001 From: Remita Amine Date: Tue, 3 Dec 2019 11:37:30 +0100 Subject: [PATCH 1/3] [vzaar] add support for AES HLS manifests(closes #17521)(closes #23299) --- youtube_dl/extractor/vzaar.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/vzaar.py b/youtube_dl/extractor/vzaar.py index 3336e6c15..b43975ead 100644 --- a/youtube_dl/extractor/vzaar.py +++ b/youtube_dl/extractor/vzaar.py @@ -32,6 +32,15 @@ class VzaarIE(InfoExtractor): 'ext': 'mp3', 'title': 'MP3', }, + }, { + # hlsAes = true + 'url': 'https://view.vzaar.com/10165560/player', + 'md5': '5f66f121fb28b9d16cce3d4f3df7e72e', + 'info_dict': { + 'id': '10165560', + 'ext': 'mp4', + 'title': 'Video Demo vzaar Secure.mp4', + }, }, { # with null videoTitle 'url': 'https://view.vzaar.com/20313539/download', @@ -58,6 +67,7 @@ class VzaarIE(InfoExtractor): f = { 'url': source_url, 'format_id': 'http', + 'preference': 1, } if 'audio' in source_url: f.update({ @@ -75,12 +85,13 @@ class VzaarIE(InfoExtractor): video_guid = video_data.get('guid') usp = video_data.get('usp') - if isinstance(video_guid, compat_str) and isinstance(usp, dict): - m3u8_url = ('http://fable.vzaar.com/v4/usp/%s/%s.ism/.m3u8?' - % (video_guid, video_id)) + '&'.join( + if video_data.get('uspEnabled') and isinstance(video_guid, compat_str) and isinstance(usp, dict): + hls_aes = video_data.get('hlsAes') + m3u8_url = ('http://fable.vzaar.com/v5/usp%s/%s/%s.ism/.m3u8?' + % ('aes' if hls_aes else '', video_guid, video_id)) + '&'.join( '%s=%s' % (k, v) for k, v in usp.items()) formats.extend(self._extract_m3u8_formats( - m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native', + m3u8_url, video_id, 'mp4', 'm3u8' if hls_aes else 'm3u8_native', m3u8_id='hls', fatal=False)) self._sort_formats(formats) From c712b16dc41b792757ee8e13a59bce9ab3b4e5b4 Mon Sep 17 00:00:00 2001 From: Remita Amine Date: Tue, 3 Dec 2019 12:23:08 +0100 Subject: [PATCH 2/3] [vzaar] override AES decryption key URL(closes #17521) --- youtube_dl/downloader/hls.py | 4 ++-- youtube_dl/extractor/vzaar.py | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/youtube_dl/downloader/hls.py b/youtube_dl/downloader/hls.py index b59aad73f..84bc34928 100644 --- a/youtube_dl/downloader/hls.py +++ b/youtube_dl/downloader/hls.py @@ -64,7 +64,7 @@ class HlsFD(FragmentFD): s = urlh.read().decode('utf-8', 'ignore') if not self.can_download(s, info_dict): - if info_dict.get('extra_param_to_segment_url'): + if info_dict.get('extra_param_to_segment_url') or info_dict.get('_decryption_key_url'): self.report_error('pycrypto not found. Please install it.') return False self.report_warning( @@ -169,7 +169,7 @@ class HlsFD(FragmentFD): if decrypt_info['METHOD'] == 'AES-128': iv = decrypt_info.get('IV') or compat_struct_pack('>8xq', media_sequence) decrypt_info['KEY'] = decrypt_info.get('KEY') or self.ydl.urlopen( - self._prepare_url(info_dict, decrypt_info['URI'])).read() + self._prepare_url(info_dict, info_dict.get('_decryption_key_url') or decrypt_info['URI'])).read() frag_content = AES.new( decrypt_info['KEY'], AES.MODE_CBC, iv).decrypt(frag_content) self._append_fragment(ctx, frag_content) diff --git a/youtube_dl/extractor/vzaar.py b/youtube_dl/extractor/vzaar.py index b43975ead..f02e8530b 100644 --- a/youtube_dl/extractor/vzaar.py +++ b/youtube_dl/extractor/vzaar.py @@ -87,12 +87,15 @@ class VzaarIE(InfoExtractor): usp = video_data.get('usp') if video_data.get('uspEnabled') and isinstance(video_guid, compat_str) and isinstance(usp, dict): hls_aes = video_data.get('hlsAes') - m3u8_url = ('http://fable.vzaar.com/v5/usp%s/%s/%s.ism/.m3u8?' - % ('aes' if hls_aes else '', video_guid, video_id)) + '&'.join( - '%s=%s' % (k, v) for k, v in usp.items()) - formats.extend(self._extract_m3u8_formats( - m3u8_url, video_id, 'mp4', 'm3u8' if hls_aes else 'm3u8_native', - m3u8_id='hls', fatal=False)) + qs = '&'.join('%s=%s' % (k, v) for k, v in usp.items()) + url_templ = 'http://%%s.vzaar.com/v5/usp%s/%s/%s.ism%%s?' % ('aes' if hls_aes else '', video_guid, video_id) + m3u8_formats = self._extract_m3u8_formats( + url_templ % ('fable', '/.m3u8') + qs, video_id, 'mp4', 'm3u8_native', + m3u8_id='hls', fatal=False) + if hls_aes: + for f in m3u8_formats: + f['_decryption_key_url'] = url_templ % ('goose', '') + qs + formats.extend(m3u8_formats) self._sort_formats(formats) From 63fe44eb4dc91e2a9755a5cf23b9d39cbd36dae7 Mon Sep 17 00:00:00 2001 From: Remita Amine Date: Tue, 3 Dec 2019 12:31:16 +0100 Subject: [PATCH 3/3] [vzaar] update test --- youtube_dl/extractor/vzaar.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/vzaar.py b/youtube_dl/extractor/vzaar.py index f02e8530b..b7d02fca3 100644 --- a/youtube_dl/extractor/vzaar.py +++ b/youtube_dl/extractor/vzaar.py @@ -34,12 +34,15 @@ class VzaarIE(InfoExtractor): }, }, { # hlsAes = true - 'url': 'https://view.vzaar.com/10165560/player', - 'md5': '5f66f121fb28b9d16cce3d4f3df7e72e', + 'url': 'https://view.vzaar.com/11379930/player', 'info_dict': { - 'id': '10165560', + 'id': '11379930', 'ext': 'mp4', - 'title': 'Video Demo vzaar Secure.mp4', + 'title': 'Videoaula', + }, + 'params': { + # m3u8 download + 'skip_download': True, }, }, { # with null videoTitle