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.

39 lines
1.4 KiB

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