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.

38 lines
1.5 KiB

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