1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-12-23 16:36:48 +00:00

[youku] Add cn_verification_proxy support and add a georestricted test case

This commit is contained in:
Yen Chi Hsuan 2015-06-16 00:06:23 +08:00
parent 04e7596680
commit 5228b756af

View File

@ -9,6 +9,7 @@ from ..utils import ExtractorError
from ..compat import ( from ..compat import (
compat_urllib_parse, compat_urllib_parse,
compat_ord, compat_ord,
compat_urllib_request,
) )
@ -39,6 +40,14 @@ class YoukuIE(InfoExtractor):
'title': '武媚娘传奇 85', 'title': '武媚娘传奇 85',
}, },
'playlist_count': 11, 'playlist_count': 11,
}, {
'url': 'http://v.youku.com/v_show/id_XMTI1OTczNDM5Mg==.html',
'info_dict': {
'id': 'XMTI1OTczNDM5Mg',
'title': '花千骨 04',
},
'playlist_count': 13,
'skip': 'Available in China only',
}] }]
def construct_video_urls(self, data1, data2): def construct_video_urls(self, data1, data2):
@ -165,14 +174,23 @@ class YoukuIE(InfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
# request basic data def retrieve_data(req_url, note):
data1_url = 'http://v.youku.com/player/getPlayList/VideoIDS/%s' % video_id req = compat_urllib_request.Request(req_url)
data2_url = 'http://v.youku.com/player/getPlayList/VideoIDS/%s/Pf/4/ctype/12/ev/1' % video_id
raw_data1 = self._download_json(data1_url, video_id) cn_verification_proxy = self._downloader.params.get('cn_verification_proxy')
raw_data2 = self._download_json(data2_url, video_id) if cn_verification_proxy:
data1 = raw_data1['data'][0] req.add_header('Ytdl-request-proxy', cn_verification_proxy)
data2 = raw_data2['data'][0]
raw_data = self._download_json(req, video_id, note=note)
return raw_data['data'][0]
# request basic data
data1 = retrieve_data(
'http://v.youku.com/player/getPlayList/VideoIDS/%s' % video_id,
'Downloading JSON metadata 1')
data2 = retrieve_data(
'http://v.youku.com/player/getPlayList/VideoIDS/%s/Pf/4/ctype/12/ev/1' % video_id,
'Downloading JSON metadata 2')
error_code = data1.get('error_code') error_code = data1.get('error_code')
if error_code: if error_code: