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