You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.7 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. import hashlib
  4. from .common import InfoExtractor
  5. _md5 = lambda s: hashlib.md5(s.encode('utf-8')).hexdigest()
  6. class KankanIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:.*?\.)?kankan\.com/.+?/(?P<id>\d+)\.shtml'
  8. _TEST = {
  9. 'url': 'http://yinyue.kankan.com/vod/48/48863.shtml',
  10. 'file': '48863.flv',
  11. 'md5': '29aca1e47ae68fc28804aca89f29507e',
  12. 'info_dict': {
  13. 'title': 'Ready To Go',
  14. },
  15. 'skip': 'Only available from China',
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. video_id = mobj.group('id')
  20. webpage = self._download_webpage(url, video_id)
  21. title = self._search_regex(r'(?:G_TITLE=|G_MOVIE_TITLE = )[\'"](.+?)[\'"]', webpage, 'video title')
  22. surls = re.search(r'surls:\[\'.+?\'\]|lurl:\'.+?\.flv\'', webpage).group(0)
  23. gcids = re.findall(r"http://.+?/.+?/(.+?)/", surls)
  24. gcid = gcids[-1]
  25. info_url = 'http://p2s.cl.kankan.com/getCdnresource_flv?gcid=%s' % gcid
  26. video_info_page = self._download_webpage(
  27. info_url, video_id, 'Downloading video url info')
  28. ip = self._search_regex(r'ip:"(.+?)"', video_info_page, 'video url ip')
  29. path = self._search_regex(r'path:"(.+?)"', video_info_page, 'video url path')
  30. param1 = self._search_regex(r'param1:(\d+)', video_info_page, 'param1')
  31. param2 = self._search_regex(r'param2:(\d+)', video_info_page, 'param2')
  32. key = _md5('xl_mp43651' + param1 + param2)
  33. video_url = 'http://%s%s?key=%s&key1=%s' % (ip, path, key, param2)
  34. return {
  35. 'id': video_id,
  36. 'title': title,
  37. 'url': video_url,
  38. }