]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/motorsport.py
Tidy the changelog.
[youtubedl] / youtube_dl / extractor / motorsport.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..compat import (
6 compat_urlparse,
7 )
8
9
10 class MotorsportIE(InfoExtractor):
11 IE_DESC = 'motorsport.com'
12 _VALID_URL = r'http://www\.motorsport\.com/[^/?#]+/video/(?:[^/?#]+/)(?P<id>[^/]+)/?(?:$|[?#])'
13 _TEST = {
14 'url': 'http://www.motorsport.com/f1/video/main-gallery/red-bull-racing-2014-rules-explained/',
15 'info_dict': {
16 'id': '2-T3WuR-KMM',
17 'ext': 'mp4',
18 'title': 'Red Bull Racing: 2014 Rules Explained',
19 'duration': 208,
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.',
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 },
30 }
31
32 def _real_extract(self, url):
33 display_id = self._match_id(url)
34 webpage = self._download_webpage(url, display_id)
35
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')
44
45 return {
46 '_type': 'url_transparent',
47 'display_id': display_id,
48 'url': 'https://youtube.com/watch?v=%s' % youtube_id,
49 }