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.

62 lines
2.2 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. }
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. video_id = mobj.group('videoid')
  22. page = self._download_webpage('http://www.novamov.com/video/%s' % video_id,
  23. video_id, 'Downloading video page')
  24. if re.search(r'This file no longer exists on our servers!</h2>', page) is not None:
  25. raise ExtractorError(u'Video %s does not exist' % video_id, expected=True)
  26. filekey = self._search_regex(
  27. r'flashvars\.filekey="(?P<filekey>[^"]+)";', page, 'filekey')
  28. title = self._html_search_regex(
  29. r'(?s)<div class="v_tab blockborder rounded5" id="v_tab1">\s*<h3>([^<]+)</h3>',
  30. page, 'title', fatal=False)
  31. description = self._html_search_regex(
  32. r'(?s)<div class="v_tab blockborder rounded5" id="v_tab1">\s*<h3>[^<]+</h3><p>([^<]+)</p>',
  33. page, 'description', fatal=False)
  34. api_response = self._download_webpage(
  35. 'http://www.novamov.com/api/player.api.php?key=%s&file=%s' % (filekey, video_id),
  36. video_id, 'Downloading video api response')
  37. response = compat_urlparse.parse_qs(api_response)
  38. if 'error_msg' in response:
  39. raise ExtractorError('novamov returned error: %s' % response['error_msg'][0], expected=True)
  40. video_url = response['url'][0]
  41. return {
  42. 'id': video_id,
  43. 'url': video_url,
  44. 'title': title,
  45. 'description': description
  46. }