X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fiqiyi.py;h=5df674daf142fa5c8365bc0cb524e28afd248827;hb=HEAD;hp=754e6057c986f37049281a67a63d2618916938d5;hpb=2644e911bebcace4fbac7ddd3ea8c71936b1b3e9;p=youtube-dl diff --git a/youtube_dl/extractor/iqiyi.py b/youtube_dl/extractor/iqiyi.py index 754e6057c..5df674daf 100644 --- a/youtube_dl/extractor/iqiyi.py +++ b/youtube_dl/extractor/iqiyi.py @@ -150,7 +150,7 @@ class IqiyiSDKInterpreter(object): elif function in other_functions: other_functions[function]() else: - raise ExtractorError('Unknown funcion %s' % function) + raise ExtractorError('Unknown function %s' % function) return sdk.target @@ -165,7 +165,7 @@ class IqiyiIE(InfoExtractor): _TESTS = [{ 'url': 'http://www.iqiyi.com/v_19rrojlavg.html', - 'md5': '5b0591f55961117155430b5d544fdb01', + # MD5 checksum differs on my machine and Travis CI 'info_dict': { 'id': '9c1fb1b99d192b21c559e5a1a2cb3c73', 'ext': 'mp4', @@ -173,11 +173,12 @@ class IqiyiIE(InfoExtractor): } }, { 'url': 'http://www.iqiyi.com/v_19rrhnnclk.html', - 'md5': '667171934041350c5de3f5015f7f1152', + 'md5': 'b7dc800a4004b1b57749d9abae0472da', 'info_dict': { 'id': 'e3f585b550a280af23c98b6cb2be19fb', 'ext': 'mp4', - 'title': '名侦探柯南 国语版:第752集 迫近灰原秘密的黑影 下篇', + # This can be either Simplified Chinese or Traditional Chinese + 'title': r're:^(?:名侦探柯南 国语版:第752集 迫近灰原秘密的黑影 下篇|名偵探柯南 國語版:第752集 迫近灰原秘密的黑影 下篇)$', }, 'skip': 'Geo-restricted to China', }, { @@ -188,7 +189,11 @@ class IqiyiIE(InfoExtractor): 'only_matching': True, }, { 'url': 'http://yule.iqiyi.com/pcb.html', - 'only_matching': True, + 'info_dict': { + 'id': '4a0af228fddb55ec96398a364248ed7f', + 'ext': 'mp4', + 'title': '第2017-04-21期 女艺人频遭极端粉丝骚扰', + }, }, { # VIP-only video. The first 2 parts (6 minutes) are available without login # MD5 sums omitted as values are different on Travis CI and my machine @@ -234,7 +239,7 @@ class IqiyiIE(InfoExtractor): return ohdave_rsa_encrypt(data, e, N) def _login(self): - (username, password) = self._get_login_info() + username, password = self._get_login_info() # No authentication to be performed if not username: @@ -293,14 +298,10 @@ class IqiyiIE(InfoExtractor): 't': tm, } - headers = {} - cn_verification_proxy = self._downloader.params.get('cn_verification_proxy') - if cn_verification_proxy: - headers['Ytdl-request-proxy'] = cn_verification_proxy return self._download_json( 'http://cache.m.iqiyi.com/jp/tmts/%s/%s/' % (tvid, video_id), video_id, transform_source=lambda s: remove_start(s, 'var tvInfoJs='), - query=params, headers=headers) + query=params, headers=self.geo_verification_headers()) def _extract_playlist(self, webpage): PAGE_SIZE = 50 @@ -340,15 +341,18 @@ class IqiyiIE(InfoExtractor): url, 'temp_id', note='download video page') # There's no simple way to determine whether an URL is a playlist or not - # So detect it - playlist_result = self._extract_playlist(webpage) - if playlist_result: - return playlist_result - + # Sometimes there are playlist links in individual videos, so treat it + # as a single video first tvid = self._search_regex( - r'data-player-tvid\s*=\s*[\'"](\d+)', webpage, 'tvid') + r'data-(?:player|shareplattrigger)-tvid\s*=\s*[\'"](\d+)', webpage, 'tvid', default=None) + if tvid is None: + playlist_result = self._extract_playlist(webpage) + if playlist_result: + return playlist_result + raise ExtractorError('Can\'t find any video') + video_id = self._search_regex( - r'data-player-videoid\s*=\s*[\'"]([a-f\d]+)', webpage, 'video_id') + r'data-(?:player|shareplattrigger)-videoid\s*=\s*[\'"]([a-f\d]+)', webpage, 'video_id') formats = [] for _ in range(5): @@ -379,8 +383,9 @@ class IqiyiIE(InfoExtractor): self._sleep(5, video_id) self._sort_formats(formats) - title = (get_element_by_id('widget-videotitle', webpage) or - clean_html(get_element_by_attribute('class', 'mod-play-tit', webpage))) + title = (get_element_by_id('widget-videotitle', webpage) + or clean_html(get_element_by_attribute('class', 'mod-play-tit', webpage)) + or self._html_search_regex(r']+data-videochanged-title="word"[^>]*>([^<]+)', webpage, 'title')) return { 'id': video_id,