]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/motorsport.py
Add support for https for all extractors as preventive and future-proof measure
[yt-dlp.git] / youtube_dl / extractor / motorsport.py
CommitLineData
6ff5f122
PH
1# coding: utf-8
2from __future__ import unicode_literals
3
6ff5f122 4from .common import InfoExtractor
1cc79574 5from ..compat import (
8f9529cd 6 compat_urlparse,
6ff5f122
PH
7)
8
9
10class MotorsportIE(InfoExtractor):
11 IE_DESC = 'motorsport.com'
5886b38d 12 _VALID_URL = r'https?://www\.motorsport\.com/[^/?#]+/video/(?:[^/?#]+/)(?P<id>[^/]+)/?(?:$|[?#])'
6ff5f122
PH
13 _TEST = {
14 'url': 'http://www.motorsport.com/f1/video/main-gallery/red-bull-racing-2014-rules-explained/',
6ff5f122 15 'info_dict': {
8f9529cd 16 'id': '2-T3WuR-KMM',
6ff5f122
PH
17 'ext': 'mp4',
18 'title': 'Red Bull Racing: 2014 Rules Explained',
8f9529cd 19 'duration': 208,
6ff5f122 20 '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
21 'uploader': 'mcomstaff',
22 'uploader_id': 'UC334JIYKkVnyFoNCclfZtHQ',
23 'upload_date': '20140903',
24 'thumbnail': r're:^https?://.+\.jpg$'
25 },
26 'add_ie': ['Youtube'],
27 'params': {
28 'skip_download': True,
29 },
6ff5f122
PH
30 }
31
32 def _real_extract(self, url):
1cc79574 33 display_id = self._match_id(url)
6ff5f122 34 webpage = self._download_webpage(url, display_id)
1cc79574 35
8f9529cd
JMF
36 iframe_path = self._html_search_regex(
37 r'<iframe id="player_iframe"[^>]+src="([^"]+)"', webpage,
38 'iframe path')
39 iframe = self._download_webpage(
40 compat_urlparse.urljoin(url, iframe_path), display_id,
41 'Downloading iframe')
42 youtube_id = self._search_regex(
43 r'www.youtube.com/embed/(.{11})', iframe, 'youtube id')
6ff5f122
PH
44
45 return {
8f9529cd 46 '_type': 'url_transparent',
6ff5f122 47 'display_id': display_id,
8f9529cd 48 'url': 'https://youtube.com/watch?v=%s' % youtube_id,
6ff5f122 49 }