logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

kankan.py (1738B)


  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. 'md5': '29aca1e47ae68fc28804aca89f29507e',
  11. 'info_dict': {
  12. 'id': '48863',
  13. 'ext': 'flv',
  14. 'title': 'Ready To Go',
  15. },
  16. 'skip': 'Only available from China',
  17. }
  18. def _real_extract(self, url):
  19. video_id = self._match_id(url)
  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. }