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.

35 lines
1.4 KiB

  1. import re
  2. from .common import InfoExtractor
  3. from .brightcove import BrightcoveIE
  4. from ..utils import RegexNotFoundError, ExtractorError
  5. class SpaceIE(InfoExtractor):
  6. _VALID_URL = r'https?://www\.space\.com/\d+-(?P<title>[^/\.\?]*?)-video.html'
  7. _TEST = {
  8. u'add_ie': ['Brightcove'],
  9. u'url': u'http://www.space.com/23373-huge-martian-landforms-detail-revealed-by-european-probe-video.html',
  10. u'info_dict': {
  11. u'id': u'2780937028001',
  12. u'ext': u'mp4',
  13. u'title': u'Huge Martian Landforms\' Detail Revealed By European Probe | Video',
  14. u'description': u'md5:db81cf7f3122f95ed234b631a6ea1e61',
  15. u'uploader': u'TechMedia Networks',
  16. },
  17. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. title = mobj.group('title')
  21. webpage = self._download_webpage(url, title)
  22. try:
  23. # Some videos require the playerKey field, which isn't define in
  24. # the BrightcoveExperience object
  25. brightcove_url = self._og_search_video_url(webpage)
  26. except RegexNotFoundError:
  27. # Other videos works fine with the info from the object
  28. brightcove_url = BrightcoveIE._extract_brightcove_url(webpage)
  29. if brightcove_url is None:
  30. raise ExtractorError(u'The webpage does not contain a video', expected=True)
  31. return self.url_result(brightcove_url, BrightcoveIE.ie_key())