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.

63 lines
2.3 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. ExtractorError,
  6. compat_urlparse
  7. )
  8. class NovamovIE(InfoExtractor):
  9. _VALID_URL = r'http://(?:(?:www\.)?novamov\.com/video/|(?:(?:embed|www)\.)novamov\.com/embed\.php\?v=)(?P<videoid>[a-z\d]{13})'
  10. _TEST = {
  11. 'url': 'http://www.novamov.com/video/4rurhn9x446jj',
  12. 'file': '4rurhn9x446jj.flv',
  13. 'md5': '7205f346a52bbeba427603ba10d4b935',
  14. 'info_dict': {
  15. 'title': 'search engine optimization',
  16. 'description': 'search engine optimization is used to rank the web page in the google search engine'
  17. },
  18. 'skip': '"Invalid token" errors abound (in web interface as well as youtube-dl, there is nothing we can do about it.)'
  19. }
  20. def _real_extract(self, url):
  21. mobj = re.match(self._VALID_URL, url)
  22. video_id = mobj.group('videoid')
  23. page = self._download_webpage('http://www.novamov.com/video/%s' % video_id,
  24. video_id, 'Downloading video page')
  25. if re.search(r'This file no longer exists on our servers!</h2>', page) is not None:
  26. raise ExtractorError(u'Video %s does not exist' % video_id, expected=True)
  27. filekey = self._search_regex(
  28. r'flashvars\.filekey="(?P<filekey>[^"]+)";', page, 'filekey')
  29. title = self._html_search_regex(
  30. r'(?s)<div class="v_tab blockborder rounded5" id="v_tab1">\s*<h3>([^<]+)</h3>',
  31. page, 'title', fatal=False)
  32. description = self._html_search_regex(
  33. r'(?s)<div class="v_tab blockborder rounded5" id="v_tab1">\s*<h3>[^<]+</h3><p>([^<]+)</p>',
  34. page, 'description', fatal=False)
  35. api_response = self._download_webpage(
  36. 'http://www.novamov.com/api/player.api.php?key=%s&file=%s' % (filekey, video_id),
  37. video_id, 'Downloading video api response')
  38. response = compat_urlparse.parse_qs(api_response)
  39. if 'error_msg' in response:
  40. raise ExtractorError('novamov returned error: %s' % response['error_msg'][0], expected=True)
  41. video_url = response['url'][0]
  42. return {
  43. 'id': video_id,
  44. 'url': video_url,
  45. 'title': title,
  46. 'description': description
  47. }