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.

37 lines
1.3 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=[\'"](.+?)[\'"]', webpage, u'video title')
  19. gcid = self._search_regex(r'lurl:[\'"]http://.+?/.+?/(.+?)/', webpage, u'gcid')
  20. video_info_page = self._download_webpage('http://p2s.cl.kankan.com/getCdnresource_flv?gcid=%s' % gcid,
  21. video_id, u'Downloading video url info')
  22. ip = self._search_regex(r'ip:"(.+?)"', video_info_page, u'video url ip')
  23. path = self._search_regex(r'path:"(.+?)"', video_info_page, u'video url path')
  24. video_url = 'http://%s%s' % (ip, path)
  25. return {'id': video_id,
  26. 'title': title,
  27. 'url': video_url,
  28. 'ext': determine_ext(video_url),
  29. }