aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/iqiyi.py
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2015-06-07 02:47:36 +0800
committerYen Chi Hsuan <yan12125@gmail.com>2015-06-07 02:47:36 +0800
commitb5a3c7f10927c9d55f6fdad5f5c002e02338642e (patch)
treee55d82c52031f636155b855ccde58ae5c43bd80e /youtube_dl/extractor/iqiyi.py
parent9c5f685ef14a8b44d17b897ba8ae2da051011c35 (diff)
downloadyoutube-dl-b5a3c7f10927c9d55f6fdad5f5c002e02338642e.tar.xz
[iqiyi] Cache encryption keys
Diffstat (limited to 'youtube_dl/extractor/iqiyi.py')
-rw-r--r--youtube_dl/extractor/iqiyi.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/youtube_dl/extractor/iqiyi.py b/youtube_dl/extractor/iqiyi.py
index 15481b84b..9106dd074 100644
--- a/youtube_dl/extractor/iqiyi.py
+++ b/youtube_dl/extractor/iqiyi.py
@@ -3,6 +3,7 @@ from __future__ import unicode_literals
import hashlib
import math
+import os.path
import random
import re
import time
@@ -11,7 +12,10 @@ import zlib
from .common import InfoExtractor
from ..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_data
def 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_key
def _real_extract(self, url):