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