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.

46 lines
1.6 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. embed_url = 'http://embed.nowvideo.ch/embed.php?v=' + video_id
  19. webpage = self._download_webpage(webpage_url, video_id)
  20. embed_page = self._download_webpage(embed_url, video_id,
  21. u'Downloading embed page')
  22. self.report_extraction(video_id)
  23. video_title = self._html_search_regex(r'<h4>(.*)</h4>',
  24. webpage, u'video title')
  25. video_key = self._search_regex(r'var fkzd="(.*)";',
  26. embed_page, u'video key')
  27. api_call = "http://www.nowvideo.ch/api/player.api.php?file={0}&numOfErrors=0&cid=1&key={1}".format(video_id, video_key)
  28. api_response = self._download_webpage(api_call, video_id,
  29. u'Downloading API page')
  30. video_url = compat_urlparse.parse_qs(api_response)[u'url'][0]
  31. return [{
  32. 'id': video_id,
  33. 'url': video_url,
  34. 'ext': 'flv',
  35. 'title': video_title,
  36. }]