]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/space.py
Prepare for release.
[youtubedl] / youtube_dl / extractor / space.py
1 from __future__ import unicode_literals
2
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):
11 _VALID_URL = r'https?://(?:(?:www|m)\.)?space\.com/\d+-(?P<title>[^/\.\?]*?)-video\.html'
12 _TEST = {
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',
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:
36 raise ExtractorError(
37 'The webpage does not contain a video', expected=True)
38 return self.url_result(brightcove_url, BrightcoveIE.ie_key())