]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/kankan.py
update changelog.
[youtubedl] / youtube_dl / extractor / kankan.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import determine_ext
5
6
7 class KankanIE(InfoExtractor):
8 _VALID_URL = r'https?://(?:.*?\.)?kankan\.com/.+?/(?P<id>\d+)\.shtml'
9
10 _TEST = {
11 u'url': u'http://yinyue.kankan.com/vod/48/48863.shtml',
12 u'file': u'48863.flv',
13 u'md5': u'29aca1e47ae68fc28804aca89f29507e',
14 u'info_dict': {
15 u'title': u'Ready To Go',
16 },
17 }
18
19 def _real_extract(self, url):
20 mobj = re.match(self._VALID_URL, url)
21 video_id = mobj.group('id')
22 webpage = self._download_webpage(url, video_id)
23
24 title = self._search_regex(r'(?:G_TITLE=|G_MOVIE_TITLE = )[\'"](.+?)[\'"]', webpage, u'video title')
25 surls = re.search(r'surls:\[\'.+?\'\]|lurl:\'.+?\.flv\'', webpage).group(0)
26 gcids = re.findall(r"http://.+?/.+?/(.+?)/", surls)
27 gcid = gcids[-1]
28
29 video_info_page = self._download_webpage('http://p2s.cl.kankan.com/getCdnresource_flv?gcid=%s' % gcid,
30 video_id, u'Downloading video url info')
31 ip = self._search_regex(r'ip:"(.+?)"', video_info_page, u'video url ip')
32 path = self._search_regex(r'path:"(.+?)"', video_info_page, u'video url path')
33 video_url = 'http://%s%s' % (ip, path)
34
35 return {'id': video_id,
36 'title': title,
37 'url': video_url,
38 'ext': determine_ext(video_url),
39 }