]>
Commit | Line | Data |
---|---|---|
6ff5f122 | 1 | from .common import InfoExtractor |
1cc79574 | 2 | from ..compat import ( |
8f9529cd | 3 | compat_urlparse, |
6ff5f122 PH |
4 | ) |
5 | ||
6 | ||
7 | class MotorsportIE(InfoExtractor): | |
df773c3d | 8 | _WORKING = False |
6ff5f122 | 9 | IE_DESC = 'motorsport.com' |
92519402 | 10 | _VALID_URL = r'https?://(?:www\.)?motorsport\.com/[^/?#]+/video/(?:[^/?#]+/)(?P<id>[^/]+)/?(?:$|[?#])' |
6ff5f122 PH |
11 | _TEST = { |
12 | 'url': 'http://www.motorsport.com/f1/video/main-gallery/red-bull-racing-2014-rules-explained/', | |
6ff5f122 | 13 | 'info_dict': { |
8f9529cd | 14 | 'id': '2-T3WuR-KMM', |
6ff5f122 PH |
15 | 'ext': 'mp4', |
16 | 'title': 'Red Bull Racing: 2014 Rules Explained', | |
8f9529cd | 17 | 'duration': 208, |
6ff5f122 | 18 | 'description': 'A new clip from Red Bull sees Daniel Ricciardo and Sebastian Vettel explain the 2014 Formula One regulations – which are arguably the most complex the sport has ever seen.', |
8f9529cd JMF |
19 | 'uploader': 'mcomstaff', |
20 | 'uploader_id': 'UC334JIYKkVnyFoNCclfZtHQ', | |
21 | 'upload_date': '20140903', | |
22 | 'thumbnail': r're:^https?://.+\.jpg$' | |
23 | }, | |
24 | 'add_ie': ['Youtube'], | |
25 | 'params': { | |
26 | 'skip_download': True, | |
27 | }, | |
6ff5f122 PH |
28 | } |
29 | ||
30 | def _real_extract(self, url): | |
1cc79574 | 31 | display_id = self._match_id(url) |
6ff5f122 | 32 | webpage = self._download_webpage(url, display_id) |
1cc79574 | 33 | |
8f9529cd | 34 | iframe_path = self._html_search_regex( |
5469a4ab | 35 | r'<iframe id="player_iframe"[^>]+src="([^"]+)"', webpage, 'iframe path', default=None) |
36 | ||
37 | if iframe_path is None: | |
38 | iframe_path = self._html_search_regex( | |
39 | r'<iframe [^>]*\bsrc="(https://motorsport\.tv/embed/[^"]+)', webpage, 'embed iframe path') | |
40 | return self.url_result(iframe_path) | |
41 | ||
8f9529cd JMF |
42 | iframe = self._download_webpage( |
43 | compat_urlparse.urljoin(url, iframe_path), display_id, | |
44 | 'Downloading iframe') | |
45 | youtube_id = self._search_regex( | |
46 | r'www.youtube.com/embed/(.{11})', iframe, 'youtube id') | |
6ff5f122 PH |
47 | |
48 | return { | |
8f9529cd | 49 | '_type': 'url_transparent', |
6ff5f122 | 50 | 'display_id': display_id, |
8f9529cd | 51 | 'url': 'https://youtube.com/watch?v=%s' % youtube_id, |
6ff5f122 | 52 | } |