2017-03-04 16:25:09 +00:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2017-03-15 00:40:54 +00:00
|
|
|
from ..compat import compat_HTTPError
|
2017-03-04 16:25:09 +00:00
|
|
|
from ..utils import (
|
|
|
|
float_or_none,
|
2017-03-15 00:40:54 +00:00
|
|
|
ExtractorError,
|
2017-03-04 16:25:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class RedBullTVIE(InfoExtractor):
|
2019-05-01 14:36:19 +00:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?redbull(?:\.tv|\.com(?:/[^/]+)?(?:/tv)?)(?:/events/[^/]+)?/(?:videos?|live)/(?P<id>AP-\w+)'
|
2017-03-04 16:25:09 +00:00
|
|
|
_TESTS = [{
|
|
|
|
# film
|
2018-02-03 14:42:57 +00:00
|
|
|
'url': 'https://www.redbull.tv/video/AP-1Q6XCDTAN1W11',
|
2017-03-15 00:40:54 +00:00
|
|
|
'md5': 'fb0445b98aa4394e504b413d98031d1f',
|
2017-03-04 16:25:09 +00:00
|
|
|
'info_dict': {
|
2018-02-03 14:42:57 +00:00
|
|
|
'id': 'AP-1Q6XCDTAN1W11',
|
2017-03-04 16:25:09 +00:00
|
|
|
'ext': 'mp4',
|
2018-02-03 14:42:57 +00:00
|
|
|
'title': 'ABC of... WRC - ABC of... S1E6',
|
2017-03-04 16:25:09 +00:00
|
|
|
'description': 'md5:5c7ed8f4015c8492ecf64b6ab31e7d31',
|
|
|
|
'duration': 1582.04,
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
# episode
|
2018-02-03 14:42:57 +00:00
|
|
|
'url': 'https://www.redbull.tv/video/AP-1PMHKJFCW1W11',
|
2017-03-04 16:25:09 +00:00
|
|
|
'info_dict': {
|
2018-02-03 14:42:57 +00:00
|
|
|
'id': 'AP-1PMHKJFCW1W11',
|
2017-03-04 16:25:09 +00:00
|
|
|
'ext': 'mp4',
|
2018-02-03 14:42:57 +00:00
|
|
|
'title': 'Grime - Hashtags S2E4',
|
|
|
|
'description': 'md5:b5f522b89b72e1e23216e5018810bb25',
|
2017-03-04 16:25:09 +00:00
|
|
|
'duration': 904.6,
|
|
|
|
},
|
2017-06-24 18:09:12 +00:00
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
2018-08-12 04:31:18 +00:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.redbull.com/int-en/tv/video/AP-1UWHCAR9S1W11/rob-meets-sam-gaze?playlist=playlists::3f81040a-2f31-4832-8e2e-545b1d39d173',
|
|
|
|
'only_matching': True,
|
2019-05-01 14:36:19 +00:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.redbull.com/us-en/videos/AP-1YM9QCYE52111',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.redbull.com/us-en/events/AP-1XV2K61Q51W11/live/AP-1XUJ86FDH1W11',
|
|
|
|
'only_matching': True,
|
2017-03-04 16:25:09 +00:00
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
2017-03-15 00:40:54 +00:00
|
|
|
session = self._download_json(
|
2018-02-03 14:42:57 +00:00
|
|
|
'https://api.redbull.tv/v3/session', video_id,
|
2017-03-04 16:25:09 +00:00
|
|
|
note='Downloading access token', query={
|
2017-03-15 00:40:54 +00:00
|
|
|
'category': 'personal_computer',
|
|
|
|
'os_family': 'http',
|
|
|
|
})
|
|
|
|
if session.get('code') == 'error':
|
|
|
|
raise ExtractorError('%s said: %s' % (
|
|
|
|
self.IE_NAME, session['message']))
|
2018-02-03 14:42:57 +00:00
|
|
|
token = session['token']
|
2017-03-04 16:25:09 +00:00
|
|
|
|
2017-03-15 00:40:54 +00:00
|
|
|
try:
|
2018-02-03 14:42:57 +00:00
|
|
|
video = self._download_json(
|
|
|
|
'https://api.redbull.tv/v3/products/' + video_id,
|
2017-03-15 00:40:54 +00:00
|
|
|
video_id, note='Downloading video information',
|
2018-02-03 14:42:57 +00:00
|
|
|
headers={'Authorization': token}
|
2017-03-15 00:40:54 +00:00
|
|
|
)
|
|
|
|
except ExtractorError as e:
|
|
|
|
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 404:
|
|
|
|
error_message = self._parse_json(
|
2018-02-03 14:42:57 +00:00
|
|
|
e.cause.read().decode(), video_id)['error']
|
2017-03-15 00:40:54 +00:00
|
|
|
raise ExtractorError('%s said: %s' % (
|
|
|
|
self.IE_NAME, error_message), expected=True)
|
|
|
|
raise
|
2017-03-04 16:25:09 +00:00
|
|
|
|
2018-02-03 14:42:57 +00:00
|
|
|
title = video['title'].strip()
|
2017-03-04 16:25:09 +00:00
|
|
|
|
|
|
|
formats = self._extract_m3u8_formats(
|
2018-02-03 14:42:57 +00:00
|
|
|
'https://dms.redbull.tv/v3/%s/%s/playlist.m3u8' % (video_id, token),
|
|
|
|
video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls')
|
2017-03-15 00:40:54 +00:00
|
|
|
self._sort_formats(formats)
|
2017-03-04 16:25:09 +00:00
|
|
|
|
|
|
|
subtitles = {}
|
2018-02-03 14:42:57 +00:00
|
|
|
for resource in video.get('resources', []):
|
|
|
|
if resource.startswith('closed_caption_'):
|
|
|
|
splitted_resource = resource.split('_')
|
|
|
|
if splitted_resource[2]:
|
|
|
|
subtitles.setdefault('en', []).append({
|
|
|
|
'url': 'https://resources.redbull.tv/%s/%s' % (video_id, resource),
|
|
|
|
'ext': splitted_resource[2],
|
|
|
|
})
|
2017-03-04 16:25:09 +00:00
|
|
|
|
2018-02-03 14:42:57 +00:00
|
|
|
subheading = video.get('subheading')
|
2017-03-04 16:25:09 +00:00
|
|
|
if subheading:
|
|
|
|
title += ' - %s' % subheading
|
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
2018-02-03 14:42:57 +00:00
|
|
|
'description': video.get('long_description') or video.get(
|
2017-03-04 16:25:09 +00:00
|
|
|
'short_description'),
|
|
|
|
'duration': float_or_none(video.get('duration'), scale=1000),
|
|
|
|
'formats': formats,
|
|
|
|
'subtitles': subtitles,
|
|
|
|
}
|
2019-06-07 16:48:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
class RedBullTVRrnContentIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?redbull(?:\.tv|\.com(?:/[^/]+)?(?:/tv)?)/(?:video|live)/rrn:content:[^:]+:(?P<id>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})'
|
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://www.redbull.com/int-en/tv/video/rrn:content:live-videos:e3e6feb4-e95f-50b7-962a-c70f8fd13c73/mens-dh-finals-fort-william',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.redbull.com/int-en/tv/video/rrn:content:videos:a36a0f36-ff1b-5db8-a69d-ee11a14bf48b/tn-ts-style?playlist=rrn:content:event-profiles:83f05926-5de8-5389-b5e4-9bb312d715e8:extras',
|
|
|
|
'only_matching': True,
|
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
display_id = self._match_id(url)
|
|
|
|
|
|
|
|
webpage = self._download_webpage(url, display_id)
|
|
|
|
|
|
|
|
video_url = self._og_search_url(webpage)
|
|
|
|
|
|
|
|
return self.url_result(
|
|
|
|
video_url, ie=RedBullTVIE.ie_key(),
|
|
|
|
video_id=RedBullTVIE._match_id(video_url))
|