]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/redbulltv.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
13 class RedBullTVIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?redbull\.tv/(?:video|film)/(?P<id>AP-\w+)'
17 'url': 'https://www.redbull.tv/video/AP-1Q756YYX51W11/abc-of-wrc',
18 'md5': '78e860f631d7a846e712fab8c5fe2c38',
20 'id': 'AP-1Q756YYX51W11',
22 'title': 'ABC of...WRC',
23 'description': 'md5:5c7ed8f4015c8492ecf64b6ab31e7d31',
25 'timestamp': 1488405786,
26 'upload_date': '20170301',
30 'url': 'https://www.redbull.tv/video/AP-1PMT5JCWH1W11/grime?playlist=shows:shows-playall:web',
32 'id': 'AP-1PMT5JCWH1W11',
34 'title': 'Grime - Hashtags S2 E4',
35 'description': 'md5:334b741c8c1ce65be057eab6773c1cf5',
37 'timestamp': 1487290093,
38 'upload_date': '20170217',
44 'url': 'https://www.redbull.tv/film/AP-1MSKKF5T92111/in-motion',
45 'only_matching': True,
48 def _real_extract(self
, url
):
49 video_id
= self
._match
_id
(url
)
51 access_token
= self
._download
_json
(
52 'https://api-v2.redbull.tv/start', video_id
,
53 note
='Downloading access token', query
={
55 'category': 'smartphone',
57 'os_family': 'android',
58 })['auth']['access_token']
60 info
= self
._download
_json
(
61 'https://api-v2.redbull.tv/views/%s' % video_id
,
62 video_id
, note
='Downloading video information',
63 headers
={'Authorization': 'Bearer ' + access_token
}
64 )['blocks'][0]['top'][0]
66 video
= info
['video_product']
68 title
= info
['title'].strip()
69 m3u8_url
= video
['url']
71 formats
= self
._extract
_m
3u8_formats
(
72 m3u8_url
, video_id
, 'mp4', entry_protocol
='m3u8_native',
76 for _
, captions
in (try_get(
77 video
, lambda x
: x
['attachments']['captions'],
79 if not captions
or not isinstance(captions
, list):
81 for caption
in captions
:
82 caption_url
= caption
.get('url')
85 subtitles
.setdefault(caption
.get('lang') or 'en', []).append({
87 'ext': caption
.get('format'),
90 subheading
= info
.get('subheading')
92 title
+= ' - %s' % subheading
97 'description': info
.get('long_description') or info
.get(
99 'duration': float_or_none(video
.get('duration'), scale
=1000),
100 'timestamp': unified_timestamp(info
.get('published')),
101 'series': info
.get('show_title'),
102 'season_number': int_or_none(info
.get('season_number')),
103 'episode_number': int_or_none(info
.get('episode_number')),
105 'subtitles': subtitles
,