1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-23 02:32:16 +00:00

[kankan] Simplify

This commit is contained in:
Philipp Hagemeister 2014-01-17 04:21:22 +01:00
parent d0390a0c92
commit ca70d215cf

View file

@ -1,20 +1,22 @@
from __future__ import unicode_literals
import re import re
import hashlib import hashlib
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import determine_ext
_md5 = lambda s: hashlib.md5(s.encode('utf-8')).hexdigest() _md5 = lambda s: hashlib.md5(s.encode('utf-8')).hexdigest()
class KankanIE(InfoExtractor): class KankanIE(InfoExtractor):
_VALID_URL = r'https?://(?:.*?\.)?kankan\.com/.+?/(?P<id>\d+)\.shtml' _VALID_URL = r'https?://(?:.*?\.)?kankan\.com/.+?/(?P<id>\d+)\.shtml'
_TEST = { _TEST = {
u'url': u'http://yinyue.kankan.com/vod/48/48863.shtml', 'url': 'http://yinyue.kankan.com/vod/48/48863.shtml',
u'file': u'48863.flv', 'file': '48863.flv',
u'md5': u'29aca1e47ae68fc28804aca89f29507e', 'md5': '29aca1e47ae68fc28804aca89f29507e',
u'info_dict': { 'info_dict': {
u'title': u'Ready To Go', 'title': 'Ready To Go',
}, },
} }
@ -23,22 +25,23 @@ class KankanIE(InfoExtractor):
video_id = mobj.group('id') video_id = mobj.group('id')
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
title = self._search_regex(r'(?:G_TITLE=|G_MOVIE_TITLE = )[\'"](.+?)[\'"]', webpage, u'video title') title = self._search_regex(r'(?:G_TITLE=|G_MOVIE_TITLE = )[\'"](.+?)[\'"]', webpage, 'video title')
surls = re.search(r'surls:\[\'.+?\'\]|lurl:\'.+?\.flv\'', webpage).group(0) surls = re.search(r'surls:\[\'.+?\'\]|lurl:\'.+?\.flv\'', webpage).group(0)
gcids = re.findall(r"http://.+?/.+?/(.+?)/", surls) gcids = re.findall(r"http://.+?/.+?/(.+?)/", surls)
gcid = gcids[-1] gcid = gcids[-1]
video_info_page = self._download_webpage('http://p2s.cl.kankan.com/getCdnresource_flv?gcid=%s' % gcid, info_url = 'http://p2s.cl.kankan.com/getCdnresource_flv?gcid=%s' % gcid
video_id, u'Downloading video url info') video_info_page = self._download_webpage(
ip = self._search_regex(r'ip:"(.+?)"', video_info_page, u'video url ip') info_url, video_id, 'Downloading video url info')
path = self._search_regex(r'path:"(.+?)"', video_info_page, u'video url path') ip = self._search_regex(r'ip:"(.+?)"', video_info_page, 'video url ip')
param1 = self._search_regex(r'param1:(\d+)', video_info_page, u'param1') path = self._search_regex(r'path:"(.+?)"', video_info_page, 'video url path')
param2 = self._search_regex(r'param2:(\d+)', video_info_page, u'param2') param1 = self._search_regex(r'param1:(\d+)', video_info_page, 'param1')
param2 = self._search_regex(r'param2:(\d+)', video_info_page, 'param2')
key = _md5('xl_mp43651' + param1 + param2) key = _md5('xl_mp43651' + param1 + param2)
video_url = 'http://%s%s?key=%s&key1=%s' % (ip, path, key, param2) video_url = 'http://%s%s?key=%s&key1=%s' % (ip, path, key, param2)
return {'id': video_id, return {
'id': video_id,
'title': title, 'title': title,
'url': video_url, 'url': video_url,
'ext': determine_ext(video_url),
} }