2014-01-17 03:21:22 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2013-07-29 21:13:12 +00:00
|
|
|
import re
|
2013-11-06 20:47:02 +00:00
|
|
|
import hashlib
|
2013-07-29 21:13:12 +00:00
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
|
2013-11-06 20:47:02 +00:00
|
|
|
_md5 = lambda s: hashlib.md5(s.encode('utf-8')).hexdigest()
|
2013-07-29 21:13:12 +00:00
|
|
|
|
2014-01-17 03:21:22 +00:00
|
|
|
|
2013-07-29 21:13:12 +00:00
|
|
|
class KankanIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'https?://(?:.*?\.)?kankan\.com/.+?/(?P<id>\d+)\.shtml'
|
|
|
|
|
|
|
|
_TEST = {
|
2014-01-17 03:21:22 +00:00
|
|
|
'url': 'http://yinyue.kankan.com/vod/48/48863.shtml',
|
|
|
|
'file': '48863.flv',
|
|
|
|
'md5': '29aca1e47ae68fc28804aca89f29507e',
|
|
|
|
'info_dict': {
|
|
|
|
'title': 'Ready To Go',
|
2013-07-29 21:13:12 +00:00
|
|
|
},
|
2014-01-17 03:21:54 +00:00
|
|
|
'skip': 'Only available from China',
|
2013-07-29 21:13:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
mobj = re.match(self._VALID_URL, url)
|
|
|
|
video_id = mobj.group('id')
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
|
2014-01-17 03:21:22 +00:00
|
|
|
title = self._search_regex(r'(?:G_TITLE=|G_MOVIE_TITLE = )[\'"](.+?)[\'"]', webpage, 'video title')
|
2013-08-02 07:26:11 +00:00
|
|
|
surls = re.search(r'surls:\[\'.+?\'\]|lurl:\'.+?\.flv\'', webpage).group(0)
|
|
|
|
gcids = re.findall(r"http://.+?/.+?/(.+?)/", surls)
|
|
|
|
gcid = gcids[-1]
|
2013-07-29 21:13:12 +00:00
|
|
|
|
2014-01-17 03:21:22 +00:00
|
|
|
info_url = 'http://p2s.cl.kankan.com/getCdnresource_flv?gcid=%s' % gcid
|
|
|
|
video_info_page = self._download_webpage(
|
|
|
|
info_url, video_id, 'Downloading video url info')
|
|
|
|
ip = self._search_regex(r'ip:"(.+?)"', video_info_page, 'video url ip')
|
|
|
|
path = self._search_regex(r'path:"(.+?)"', video_info_page, 'video url path')
|
|
|
|
param1 = self._search_regex(r'param1:(\d+)', video_info_page, 'param1')
|
|
|
|
param2 = self._search_regex(r'param2:(\d+)', video_info_page, 'param2')
|
2013-11-06 20:47:02 +00:00
|
|
|
key = _md5('xl_mp43651' + param1 + param2)
|
|
|
|
video_url = 'http://%s%s?key=%s&key1=%s' % (ip, path, key, param2)
|
2013-07-29 21:13:12 +00:00
|
|
|
|
2014-01-17 03:21:22 +00:00
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
|
|
|
'url': video_url,
|
|
|
|
}
|