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.

43 lines
1.4 KiB

  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import compat_urlparse
  4. class NowVideoIE(InfoExtractor):
  5. _VALID_URL = r'(?:https?://)?(?:www\.)?nowvideo\.ch/video/(?P<id>\w+)'
  6. _TEST = {
  7. u'url': u'http://www.nowvideo.ch/video/0mw0yow7b6dxa',
  8. u'file': u'0mw0yow7b6dxa.flv',
  9. u'md5': u'f8fbbc8add72bd95b7850c6a02fc8817',
  10. u'info_dict': {
  11. u"title": u"youtubedl test video _BaW_jenozKc.mp4"
  12. }
  13. }
  14. def _real_extract(self, url):
  15. mobj = re.match(self._VALID_URL, url)
  16. video_id = mobj.group('id')
  17. webpage_url = 'http://www.nowvideo.ch/video/' + video_id
  18. webpage = self._download_webpage(webpage_url, video_id)
  19. self.report_extraction(video_id)
  20. video_title = self._html_search_regex(r'<h4>(.*)</h4>',
  21. webpage, u'video title')
  22. video_key = self._search_regex(r'var fkzd="(.*)";',
  23. webpage, u'video key')
  24. api_call = "http://www.nowvideo.ch/api/player.api.php?file={0}&numOfErrors=0&cid=1&key={1}".format(video_id, video_key)
  25. api_response = self._download_webpage(api_call, video_id,
  26. u'Downloading API page')
  27. video_url = compat_urlparse.parse_qs(api_response)[u'url'][0]
  28. return [{
  29. 'id': video_id,
  30. 'url': video_url,
  31. 'ext': 'flv',
  32. 'title': video_title,
  33. }]