1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2026-05-02 11:43:30 +00:00
Files
youtube-dl/youtube_dl/extractor/motorsport.py
T

50 lines
1.8 KiB
Python
Raw Normal View History

2014-04-04 00:05:43 +02:00
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
2014-12-13 12:24:42 +01:00
from ..compat import (
compat_urlparse,
2014-04-04 00:05:43 +02:00
)
class MotorsportIE(InfoExtractor):
IE_DESC = 'motorsport.com'
2016-09-08 18:29:05 +07:00
_VALID_URL = r'https?://(?:www\.)?motorsport\.com/[^/?#]+/video/(?:[^/?#]+/)(?P<id>[^/]+)/?(?:$|[?#])'
2014-04-04 00:05:43 +02:00
_TEST = {
'url': 'http://www.motorsport.com/f1/video/main-gallery/red-bull-racing-2014-rules-explained/',
'info_dict': {
'id': '2-T3WuR-KMM',
2014-04-04 00:05:43 +02:00
'ext': 'mp4',
'title': 'Red Bull Racing: 2014 Rules Explained',
'duration': 208,
2014-04-04 00:05:43 +02:00
'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.',
'uploader': 'mcomstaff',
'uploader_id': 'UC334JIYKkVnyFoNCclfZtHQ',
'upload_date': '20140903',
'thumbnail': r're:^https?://.+\.jpg$'
},
'add_ie': ['Youtube'],
'params': {
'skip_download': True,
},
2014-04-04 00:05:43 +02:00
}
def _real_extract(self, url):
2014-12-13 12:24:42 +01:00
display_id = self._match_id(url)
2014-04-04 00:05:43 +02:00
webpage = self._download_webpage(url, display_id)
2014-12-13 12:24:42 +01:00
iframe_path = self._html_search_regex(
r'<iframe id="player_iframe"[^>]+src="([^"]+)"', webpage,
'iframe path')
iframe = self._download_webpage(
compat_urlparse.urljoin(url, iframe_path), display_id,
'Downloading iframe')
youtube_id = self._search_regex(
r'www.youtube.com/embed/(.{11})', iframe, 'youtube id')
2014-04-04 00:05:43 +02:00
return {
'_type': 'url_transparent',
2014-04-04 00:05:43 +02:00
'display_id': display_id,
'url': 'https://youtube.com/watch?v=%s' % youtube_id,
2014-04-04 00:05:43 +02:00
}