A feature-rich command-line audio/video downloader
[iqiyi] Cache encryption keys
Yen Chi Hsuanb5a3c7f10927
diff --git a/youtube_dl/extractor/iqiyi.py b/youtube_dl/extractor/iqiyi.pyindex 15481b84b7..9106dd0749 100644--- a/youtube_dl/extractor/iqiyi.py+++ b/youtube_dl/extractor/iqiyi.py@@ -3,6 +3,7 @@ from __future__ import unicode_literalsimport hashlibimport math+import os.pathimport randomimport reimport time@@ -11,7 +12,10 @@ import zlibfrom .common import InfoExtractorfrom ..compat import compat_urllib_parse-from ..utils import ExtractorError+from ..utils import (+ ExtractorError,+ url_basename,+)class IqiyiIE(InfoExtractor):@@ -207,12 +211,20 @@ class IqiyiIE(InfoExtractor):return raw_datadef get_enc_key(self, swf_url, video_id):+ filename, _ = os.path.splitext(url_basename(swf_url))+ enc_key_json = self._downloader.cache.load('iqiyi-enc-key', filename)+ if enc_key_json is not None:+ return enc_key_json[0]+req = self._request_webpage(swf_url, video_id, note='download swf content')cn = req.read()cn = zlib.decompress(cn[8:])pt = re.compile(b'MixerRemote\x08(?P<enc_key>.+?)\$&vv')enc_key = self._search_regex(pt, cn, 'enc_key').decode('utf8')++ self._downloader.cache.store('iqiyi-enc-key', filename, [enc_key])+return enc_keydef _real_extract(self, url):