mirror of https://github.com/yt-dlp/yt-dlp.git
Compare commits
13 Commits
c0bbe204c6
...
4698b15cdf
Author | SHA1 | Date |
---|---|---|
DmitryScaletta | 4698b15cdf | |
sepro | 96da952504 | |
bashonly | bec9a59e8e | |
bashonly | 036e0d92c6 | |
DmitryScaletta | 64dabef205 | |
DmitryScaletta | 517fa5b37e | |
DmitryScaletta | 0d74df84af | |
DmitryScaletta | e64fd831b1 | |
DmitryScaletta | 1e090c6879 | |
DmitryScaletta | 64473bdee6 | |
DmitryScaletta | 72f451a029 | |
DmitryScaletta | fb8b7059f9 | |
DmitryScaletta | 452a1da090 |
|
@ -785,6 +785,25 @@ class TestHTTPImpersonateRequestHandler(TestRequestHandlerBase):
|
||||||
assert res.status == 200
|
assert res.status == 200
|
||||||
assert std_headers['user-agent'].lower() not in res.read().decode().lower()
|
assert std_headers['user-agent'].lower() not in res.read().decode().lower()
|
||||||
|
|
||||||
|
def test_response_extensions(self, handler):
|
||||||
|
with handler() as rh:
|
||||||
|
for target in rh.supported_targets:
|
||||||
|
request = Request(
|
||||||
|
f'http://127.0.0.1:{self.http_port}/gen_200', extensions={'impersonate': target})
|
||||||
|
res = validate_and_send(rh, request)
|
||||||
|
assert res.extensions['impersonate'] == rh._get_request_target(request)
|
||||||
|
|
||||||
|
def test_http_error_response_extensions(self, handler):
|
||||||
|
with handler() as rh:
|
||||||
|
for target in rh.supported_targets:
|
||||||
|
request = Request(
|
||||||
|
f'http://127.0.0.1:{self.http_port}/gen_404', extensions={'impersonate': target})
|
||||||
|
try:
|
||||||
|
validate_and_send(rh, request)
|
||||||
|
except HTTPError as e:
|
||||||
|
res = e.response
|
||||||
|
assert res.extensions['impersonate'] == rh._get_request_target(request)
|
||||||
|
|
||||||
|
|
||||||
class TestRequestHandlerMisc:
|
class TestRequestHandlerMisc:
|
||||||
"""Misc generic tests for request handlers, not related to request or validation testing"""
|
"""Misc generic tests for request handlers, not related to request or validation testing"""
|
||||||
|
|
|
@ -2136,6 +2136,11 @@ class YoutubeDL:
|
||||||
|
|
||||||
def _check_formats(self, formats):
|
def _check_formats(self, formats):
|
||||||
for f in formats:
|
for f in formats:
|
||||||
|
working = f.get('__working')
|
||||||
|
if working is not None:
|
||||||
|
if working:
|
||||||
|
yield f
|
||||||
|
continue
|
||||||
self.to_screen('[info] Testing format %s' % f['format_id'])
|
self.to_screen('[info] Testing format %s' % f['format_id'])
|
||||||
path = self.get_output_path('temp')
|
path = self.get_output_path('temp')
|
||||||
if not self._ensure_dir_exists(f'{path}/'):
|
if not self._ensure_dir_exists(f'{path}/'):
|
||||||
|
@ -2152,33 +2157,44 @@ class YoutubeDL:
|
||||||
os.remove(temp_file.name)
|
os.remove(temp_file.name)
|
||||||
except OSError:
|
except OSError:
|
||||||
self.report_warning('Unable to delete temporary file "%s"' % temp_file.name)
|
self.report_warning('Unable to delete temporary file "%s"' % temp_file.name)
|
||||||
|
f['__working'] = success
|
||||||
if success:
|
if success:
|
||||||
yield f
|
yield f
|
||||||
else:
|
else:
|
||||||
self.to_screen('[info] Unable to download format %s. Skipping...' % f['format_id'])
|
self.to_screen('[info] Unable to download format %s. Skipping...' % f['format_id'])
|
||||||
|
|
||||||
|
def _select_formats(self, formats, selector):
|
||||||
|
return list(selector({
|
||||||
|
'formats': formats,
|
||||||
|
'has_merged_format': any('none' not in (f.get('acodec'), f.get('vcodec')) for f in formats),
|
||||||
|
'incomplete_formats': (all(f.get('vcodec') == 'none' for f in formats) # No formats with video
|
||||||
|
or all(f.get('acodec') == 'none' for f in formats)), # OR, No formats with audio
|
||||||
|
}))
|
||||||
|
|
||||||
def _default_format_spec(self, info_dict, download=True):
|
def _default_format_spec(self, info_dict, download=True):
|
||||||
|
download = download and not self.params.get('simulate')
|
||||||
|
prefer_best = download and (
|
||||||
|
self.params['outtmpl']['default'] == '-'
|
||||||
|
or info_dict.get('is_live') and not self.params.get('live_from_start'))
|
||||||
|
|
||||||
def can_merge():
|
def can_merge():
|
||||||
merger = FFmpegMergerPP(self)
|
merger = FFmpegMergerPP(self)
|
||||||
return merger.available and merger.can_merge()
|
return merger.available and merger.can_merge()
|
||||||
|
|
||||||
prefer_best = (
|
if not prefer_best and download and not can_merge():
|
||||||
not self.params.get('simulate')
|
prefer_best = True
|
||||||
and download
|
formats = self._get_formats(info_dict)
|
||||||
and (
|
evaluate_formats = lambda spec: self._select_formats(formats, self.build_format_selector(spec))
|
||||||
not can_merge()
|
if evaluate_formats('b/bv+ba') != evaluate_formats('bv*+ba/b'):
|
||||||
or info_dict.get('is_live') and not self.params.get('live_from_start')
|
self.report_warning('ffmpeg not found. The downloaded format may not be the best available. '
|
||||||
or self.params['outtmpl']['default'] == '-'))
|
'Installing ffmpeg is strongly recommended: https://github.com/yt-dlp/yt-dlp#dependencies')
|
||||||
compat = (
|
|
||||||
prefer_best
|
|
||||||
or self.params.get('allow_multiple_audio_streams', False)
|
|
||||||
or 'format-spec' in self.params['compat_opts'])
|
|
||||||
|
|
||||||
return (
|
compat = (self.params.get('allow_multiple_audio_streams')
|
||||||
'best/bestvideo+bestaudio' if prefer_best
|
or 'format-spec' in self.params['compat_opts'])
|
||||||
else 'bestvideo*+bestaudio/best' if not compat
|
|
||||||
else 'bestvideo+bestaudio/best')
|
return ('best/bestvideo+bestaudio' if prefer_best
|
||||||
|
else 'bestvideo+bestaudio/best' if compat
|
||||||
|
else 'bestvideo*+bestaudio/best')
|
||||||
|
|
||||||
def build_format_selector(self, format_spec):
|
def build_format_selector(self, format_spec):
|
||||||
def syntax_error(note, start):
|
def syntax_error(note, start):
|
||||||
|
@ -2928,12 +2944,7 @@ class YoutubeDL:
|
||||||
self.write_debug(f'Default format spec: {req_format}')
|
self.write_debug(f'Default format spec: {req_format}')
|
||||||
format_selector = self.build_format_selector(req_format)
|
format_selector = self.build_format_selector(req_format)
|
||||||
|
|
||||||
formats_to_download = list(format_selector({
|
formats_to_download = self._select_formats(formats, format_selector)
|
||||||
'formats': formats,
|
|
||||||
'has_merged_format': any('none' not in (f.get('acodec'), f.get('vcodec')) for f in formats),
|
|
||||||
'incomplete_formats': (all(f.get('vcodec') == 'none' for f in formats) # No formats with video
|
|
||||||
or all(f.get('acodec') == 'none' for f in formats)), # OR, No formats with audio
|
|
||||||
}))
|
|
||||||
if interactive_format_selection and not formats_to_download:
|
if interactive_format_selection and not formats_to_download:
|
||||||
self.report_error('Requested format is not available', tb=False, is_error=False)
|
self.report_error('Requested format is not available', tb=False, is_error=False)
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -1607,6 +1607,9 @@ from .redbulltv import (
|
||||||
RedBullEmbedIE,
|
RedBullEmbedIE,
|
||||||
RedBullTVRrnContentIE,
|
RedBullTVRrnContentIE,
|
||||||
RedBullIE,
|
RedBullIE,
|
||||||
|
RedBullChannelIE,
|
||||||
|
RedBullEventIE,
|
||||||
|
RedBullShowIE,
|
||||||
)
|
)
|
||||||
from .reddit import RedditIE
|
from .reddit import RedditIE
|
||||||
from .redge import RedCDNLivxIE
|
from .redge import RedCDNLivxIE
|
||||||
|
|
|
@ -219,7 +219,29 @@ class PatreonIE(PatreonBaseIE):
|
||||||
'thumbnail': r're:^https?://.+',
|
'thumbnail': r're:^https?://.+',
|
||||||
},
|
},
|
||||||
'params': {'skip_download': 'm3u8'},
|
'params': {'skip_download': 'm3u8'},
|
||||||
|
}, {
|
||||||
|
# multiple attachments/embeds
|
||||||
|
'url': 'https://www.patreon.com/posts/holy-wars-solos-100601977',
|
||||||
|
'playlist_count': 3,
|
||||||
|
'info_dict': {
|
||||||
|
'id': '100601977',
|
||||||
|
'title': '"Holy Wars" (Megadeth) Solos Transcription & Lesson/Analysis',
|
||||||
|
'description': 'md5:d099ab976edfce6de2a65c2b169a88d3',
|
||||||
|
'uploader': 'Bradley Hall',
|
||||||
|
'uploader_id': '24401883',
|
||||||
|
'uploader_url': 'https://www.patreon.com/bradleyhallguitar',
|
||||||
|
'channel_id': '3193932',
|
||||||
|
'channel_url': 'https://www.patreon.com/bradleyhallguitar',
|
||||||
|
'channel_follower_count': int,
|
||||||
|
'timestamp': 1710777855,
|
||||||
|
'upload_date': '20240318',
|
||||||
|
'like_count': int,
|
||||||
|
'comment_count': int,
|
||||||
|
'thumbnail': r're:^https?://.+',
|
||||||
|
},
|
||||||
|
'skip': 'Patron-only content',
|
||||||
}]
|
}]
|
||||||
|
_RETURN_TYPE = 'video'
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
@ -234,58 +256,54 @@ class PatreonIE(PatreonBaseIE):
|
||||||
'include': 'audio,user,user_defined_tags,campaign,attachments_media',
|
'include': 'audio,user,user_defined_tags,campaign,attachments_media',
|
||||||
})
|
})
|
||||||
attributes = post['data']['attributes']
|
attributes = post['data']['attributes']
|
||||||
title = attributes['title'].strip()
|
info = traverse_obj(attributes, {
|
||||||
image = attributes.get('image') or {}
|
'title': ('title', {str.strip}),
|
||||||
info = {
|
'description': ('content', {clean_html}),
|
||||||
'id': video_id,
|
'thumbnail': ('image', ('large_url', 'url'), {url_or_none}, any),
|
||||||
'title': title,
|
'timestamp': ('published_at', {parse_iso8601}),
|
||||||
'description': clean_html(attributes.get('content')),
|
'like_count': ('like_count', {int_or_none}),
|
||||||
'thumbnail': image.get('large_url') or image.get('url'),
|
'comment_count': ('comment_count', {int_or_none}),
|
||||||
'timestamp': parse_iso8601(attributes.get('published_at')),
|
})
|
||||||
'like_count': int_or_none(attributes.get('like_count')),
|
|
||||||
'comment_count': int_or_none(attributes.get('comment_count')),
|
|
||||||
}
|
|
||||||
can_view_post = traverse_obj(attributes, 'current_user_can_view')
|
|
||||||
if can_view_post and info['comment_count']:
|
|
||||||
info['__post_extractor'] = self.extract_comments(video_id)
|
|
||||||
|
|
||||||
for i in post.get('included', []):
|
entries = []
|
||||||
i_type = i.get('type')
|
idx = 0
|
||||||
if i_type == 'media':
|
for include in traverse_obj(post, ('included', lambda _, v: v['type'])):
|
||||||
media_attributes = i.get('attributes') or {}
|
include_type = include['type']
|
||||||
download_url = media_attributes.get('download_url')
|
if include_type == 'media':
|
||||||
|
media_attributes = traverse_obj(include, ('attributes', {dict})) or {}
|
||||||
|
download_url = url_or_none(media_attributes.get('download_url'))
|
||||||
ext = mimetype2ext(media_attributes.get('mimetype'))
|
ext = mimetype2ext(media_attributes.get('mimetype'))
|
||||||
|
|
||||||
# if size_bytes is None, this media file is likely unavailable
|
# if size_bytes is None, this media file is likely unavailable
|
||||||
# See: https://github.com/yt-dlp/yt-dlp/issues/4608
|
# See: https://github.com/yt-dlp/yt-dlp/issues/4608
|
||||||
size_bytes = int_or_none(media_attributes.get('size_bytes'))
|
size_bytes = int_or_none(media_attributes.get('size_bytes'))
|
||||||
if download_url and ext in KNOWN_EXTENSIONS and size_bytes is not None:
|
if download_url and ext in KNOWN_EXTENSIONS and size_bytes is not None:
|
||||||
# XXX: what happens if there are multiple attachments?
|
idx += 1
|
||||||
return {
|
entries.append({
|
||||||
**info,
|
'id': f'{video_id}-{idx}',
|
||||||
'ext': ext,
|
'ext': ext,
|
||||||
'filesize': size_bytes,
|
'filesize': size_bytes,
|
||||||
'url': download_url,
|
'url': download_url,
|
||||||
}
|
|
||||||
elif i_type == 'user':
|
|
||||||
user_attributes = i.get('attributes')
|
|
||||||
if user_attributes:
|
|
||||||
info.update({
|
|
||||||
'uploader': user_attributes.get('full_name'),
|
|
||||||
'uploader_id': str_or_none(i.get('id')),
|
|
||||||
'uploader_url': user_attributes.get('url'),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
elif i_type == 'post_tag':
|
elif include_type == 'user':
|
||||||
info.setdefault('tags', []).append(traverse_obj(i, ('attributes', 'value')))
|
info.update(traverse_obj(include, {
|
||||||
|
'uploader': ('attributes', 'full_name', {str}),
|
||||||
|
'uploader_id': ('id', {str_or_none}),
|
||||||
|
'uploader_url': ('attributes', 'url', {url_or_none}),
|
||||||
|
}))
|
||||||
|
|
||||||
elif i_type == 'campaign':
|
elif include_type == 'post_tag':
|
||||||
info.update({
|
if post_tag := traverse_obj(include, ('attributes', 'value', {str})):
|
||||||
'channel': traverse_obj(i, ('attributes', 'title')),
|
info.setdefault('tags', []).append(post_tag)
|
||||||
'channel_id': str_or_none(i.get('id')),
|
|
||||||
'channel_url': traverse_obj(i, ('attributes', 'url')),
|
elif include_type == 'campaign':
|
||||||
'channel_follower_count': int_or_none(traverse_obj(i, ('attributes', 'patron_count'))),
|
info.update(traverse_obj(include, {
|
||||||
})
|
'channel': ('attributes', 'title', {str}),
|
||||||
|
'channel_id': ('id', {str_or_none}),
|
||||||
|
'channel_url': ('attributes', 'url', {url_or_none}),
|
||||||
|
'channel_follower_count': ('attributes', 'patron_count', {int_or_none}),
|
||||||
|
}))
|
||||||
|
|
||||||
# handle Vimeo embeds
|
# handle Vimeo embeds
|
||||||
if traverse_obj(attributes, ('embed', 'provider')) == 'Vimeo':
|
if traverse_obj(attributes, ('embed', 'provider')) == 'Vimeo':
|
||||||
|
@ -296,36 +314,50 @@ class PatreonIE(PatreonBaseIE):
|
||||||
v_url, video_id, 'Checking Vimeo embed URL',
|
v_url, video_id, 'Checking Vimeo embed URL',
|
||||||
headers={'Referer': 'https://patreon.com/'},
|
headers={'Referer': 'https://patreon.com/'},
|
||||||
fatal=False, errnote=False):
|
fatal=False, errnote=False):
|
||||||
return self.url_result(
|
entries.append(self.url_result(
|
||||||
VimeoIE._smuggle_referrer(v_url, 'https://patreon.com/'),
|
VimeoIE._smuggle_referrer(v_url, 'https://patreon.com/'),
|
||||||
VimeoIE, url_transparent=True, **info)
|
VimeoIE, url_transparent=True))
|
||||||
|
|
||||||
embed_url = traverse_obj(attributes, ('embed', 'url', {url_or_none}))
|
embed_url = traverse_obj(attributes, ('embed', 'url', {url_or_none}))
|
||||||
if embed_url and self._request_webpage(embed_url, video_id, 'Checking embed URL', fatal=False, errnote=False):
|
if embed_url and self._request_webpage(embed_url, video_id, 'Checking embed URL', fatal=False, errnote=False):
|
||||||
return self.url_result(embed_url, **info)
|
entries.append(self.url_result(embed_url))
|
||||||
|
|
||||||
post_file = traverse_obj(attributes, 'post_file')
|
post_file = traverse_obj(attributes, ('post_file', {dict}))
|
||||||
if post_file:
|
if post_file:
|
||||||
name = post_file.get('name')
|
name = post_file.get('name')
|
||||||
ext = determine_ext(name)
|
ext = determine_ext(name)
|
||||||
if ext in KNOWN_EXTENSIONS:
|
if ext in KNOWN_EXTENSIONS:
|
||||||
return {
|
entries.append({
|
||||||
**info,
|
'id': video_id,
|
||||||
'ext': ext,
|
'ext': ext,
|
||||||
'url': post_file['url'],
|
'url': post_file['url'],
|
||||||
}
|
})
|
||||||
elif name == 'video' or determine_ext(post_file.get('url')) == 'm3u8':
|
elif name == 'video' or determine_ext(post_file.get('url')) == 'm3u8':
|
||||||
formats, subtitles = self._extract_m3u8_formats_and_subtitles(post_file['url'], video_id)
|
formats, subtitles = self._extract_m3u8_formats_and_subtitles(post_file['url'], video_id)
|
||||||
return {
|
entries.append({
|
||||||
**info,
|
'id': video_id,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'subtitles': subtitles,
|
'subtitles': subtitles,
|
||||||
}
|
})
|
||||||
|
|
||||||
if can_view_post is False:
|
can_view_post = traverse_obj(attributes, 'current_user_can_view')
|
||||||
|
comments = None
|
||||||
|
if can_view_post and info.get('comment_count'):
|
||||||
|
comments = self.extract_comments(video_id)
|
||||||
|
|
||||||
|
if not entries and can_view_post is False:
|
||||||
self.raise_no_formats('You do not have access to this post', video_id=video_id, expected=True)
|
self.raise_no_formats('You do not have access to this post', video_id=video_id, expected=True)
|
||||||
else:
|
elif not entries:
|
||||||
self.raise_no_formats('No supported media found in this post', video_id=video_id, expected=True)
|
self.raise_no_formats('No supported media found in this post', video_id=video_id, expected=True)
|
||||||
|
elif len(entries) == 1:
|
||||||
|
info.update(entries[0])
|
||||||
|
else:
|
||||||
|
for entry in entries:
|
||||||
|
entry.update(info)
|
||||||
|
return self.playlist_result(entries, video_id, **info, __post_extractor=comments)
|
||||||
|
|
||||||
|
info['id'] = video_id
|
||||||
|
info['__post_extractor'] = comments
|
||||||
return info
|
return info
|
||||||
|
|
||||||
def _get_comments(self, post_id):
|
def _get_comments(self, post_id):
|
||||||
|
|
|
@ -1,42 +1,89 @@
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..networking.exceptions import HTTPError
|
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
float_or_none,
|
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
|
clean_html,
|
||||||
|
extract_attributes,
|
||||||
|
float_or_none,
|
||||||
|
get_element_by_class,
|
||||||
|
get_element_html_by_class,
|
||||||
|
get_element_text_and_html_by_tag,
|
||||||
|
parse_duration,
|
||||||
|
parse_iso8601,
|
||||||
|
traverse_obj,
|
||||||
|
url_or_none,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class RedBullBaseIE(InfoExtractor):
|
||||||
|
_INT_FALLBACK_LIST = ['de', 'en', 'es', 'fr']
|
||||||
|
_LAT_FALLBACK_MAP = ['ar', 'bo', 'car', 'cl', 'co', 'mx', 'pe']
|
||||||
|
_SCHEMAS = {
|
||||||
|
'page_config': 'v1:pageConfig',
|
||||||
|
'structured_data': 'v1:structuredData',
|
||||||
|
'video_hero': 'v1:videoHero',
|
||||||
|
}
|
||||||
|
|
||||||
|
def _get_locale(self, region, lang):
|
||||||
|
regions = [region.upper()]
|
||||||
|
if region != 'int':
|
||||||
|
if region in self._LAT_FALLBACK_MAP:
|
||||||
|
regions.append('LAT')
|
||||||
|
if lang in self._INT_FALLBACK_LIST:
|
||||||
|
regions.append('INT')
|
||||||
|
return '>'.join(['%s-%s' % (lang, reg) for reg in regions])
|
||||||
|
|
||||||
|
def _call_api(self, schema, type, slug, region, lang):
|
||||||
|
locale = self._get_locale(region, lang)
|
||||||
|
res = self._download_json(
|
||||||
|
'https://www.redbull.com/v3/api/graphql/v1/v3/query/' + locale,
|
||||||
|
video_id=slug, note=f'Downloading {type[:-1]} metadata', query={
|
||||||
|
'filter[type]': type,
|
||||||
|
'filter[uriSlug]': slug,
|
||||||
|
'disableUsageRestrictions': 'true',
|
||||||
|
'rb3Schema': schema,
|
||||||
|
})
|
||||||
|
data = res['data']
|
||||||
|
if schema == self._SCHEMAS['structured_data']:
|
||||||
|
if len(data) == 0:
|
||||||
|
raise ExtractorError(f'{type[:-1]} not found', expected=True)
|
||||||
|
return data[0]
|
||||||
|
return data
|
||||||
|
|
||||||
|
def _get_video_resource(self, rrn_id):
|
||||||
|
return self._download_json(
|
||||||
|
'https://api-player.redbull.com/rbcom/videoresource',
|
||||||
|
video_id=rrn_id, note='Downloading video resource metadata', query={
|
||||||
|
'videoId': rrn_id,
|
||||||
|
})
|
||||||
|
|
||||||
|
def _extract_video_resource(self, rrn_id):
|
||||||
|
video_resource = self._get_video_resource(rrn_id)
|
||||||
|
|
||||||
|
playability_errors = traverse_obj(video_resource, ('playabilityErrors'))
|
||||||
|
if 'GEO_BLOCKED' in playability_errors:
|
||||||
|
raise ExtractorError('Geo-restricted', expected=True)
|
||||||
|
if playability_errors:
|
||||||
|
raise ExtractorError('Playability error', expected=True)
|
||||||
|
|
||||||
|
video_id = traverse_obj(video_resource, ('assetId', {str})) or rrn_id.split(':')[3]
|
||||||
|
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
||||||
|
video_resource['videoUrl'], video_id, 'mp4')
|
||||||
|
|
||||||
|
return {
|
||||||
|
'id': video_id,
|
||||||
|
'formats': formats,
|
||||||
|
'subtitles': subtitles,
|
||||||
|
'aspect_ratio': traverse_obj(video_resource, ('aspectRatio', {float_or_none})),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class RedBullTVIE(InfoExtractor):
|
class RedBullTVIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?redbull(?:\.tv|\.com(?:/[^/]+)?(?:/tv)?)(?:/events/[^/]+)?/(?:videos?|live|(?:film|episode)s)/(?P<id>AP-\w+)'
|
_VALID_URL = r'https?://(?:www\.)?redbull(?:\.tv|\.com(?:/[^/]+)?(?:/tv)?)(?:/events/[^/]+)?/(?:videos?|live|(?:film|episode)s)/(?P<id>AP-\w+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
# film
|
|
||||||
'url': 'https://www.redbull.tv/video/AP-1Q6XCDTAN1W11',
|
|
||||||
'md5': 'fb0445b98aa4394e504b413d98031d1f',
|
|
||||||
'info_dict': {
|
|
||||||
'id': 'AP-1Q6XCDTAN1W11',
|
|
||||||
'ext': 'mp4',
|
|
||||||
'title': 'ABC of... WRC - ABC of... S1E6',
|
|
||||||
'description': 'md5:5c7ed8f4015c8492ecf64b6ab31e7d31',
|
|
||||||
'duration': 1582.04,
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
# episode
|
|
||||||
'url': 'https://www.redbull.tv/video/AP-1PMHKJFCW1W11',
|
'url': 'https://www.redbull.tv/video/AP-1PMHKJFCW1W11',
|
||||||
'info_dict': {
|
|
||||||
'id': 'AP-1PMHKJFCW1W11',
|
|
||||||
'ext': 'mp4',
|
|
||||||
'title': 'Grime - Hashtags S2E4',
|
|
||||||
'description': 'md5:5546aa612958c08a98faaad4abce484d',
|
|
||||||
'duration': 904,
|
|
||||||
},
|
|
||||||
'params': {
|
|
||||||
'skip_download': True,
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
'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,
|
'only_matching': True,
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://www.redbull.com/us-en/videos/AP-1YM9QCYE52111',
|
'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,
|
'only_matching': True,
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://www.redbull.com/us-en/events/AP-1XV2K61Q51W11/live/AP-1XUJ86FDH1W11',
|
'url': 'https://www.redbull.com/us-en/events/AP-1XV2K61Q51W11/live/AP-1XUJ86FDH1W11',
|
||||||
|
@ -49,95 +96,31 @@ class RedBullTVIE(InfoExtractor):
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def extract_info(self, video_id):
|
|
||||||
session = self._download_json(
|
|
||||||
'https://api.redbull.tv/v3/session', video_id,
|
|
||||||
note='Downloading access token', query={
|
|
||||||
'category': 'personal_computer',
|
|
||||||
'os_family': 'http',
|
|
||||||
})
|
|
||||||
if session.get('code') == 'error':
|
|
||||||
raise ExtractorError('%s said: %s' % (
|
|
||||||
self.IE_NAME, session['message']))
|
|
||||||
token = session['token']
|
|
||||||
|
|
||||||
try:
|
|
||||||
video = self._download_json(
|
|
||||||
'https://api.redbull.tv/v3/products/' + video_id,
|
|
||||||
video_id, note='Downloading video information',
|
|
||||||
headers={'Authorization': token}
|
|
||||||
)
|
|
||||||
except ExtractorError as e:
|
|
||||||
if isinstance(e.cause, HTTPError) and e.cause.status == 404:
|
|
||||||
error_message = self._parse_json(
|
|
||||||
e.cause.response.read().decode(), video_id)['error']
|
|
||||||
raise ExtractorError('%s said: %s' % (
|
|
||||||
self.IE_NAME, error_message), expected=True)
|
|
||||||
raise
|
|
||||||
|
|
||||||
title = video['title'].strip()
|
|
||||||
|
|
||||||
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
|
||||||
'https://dms.redbull.tv/v3/%s/%s/playlist.m3u8' % (video_id, token),
|
|
||||||
video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls')
|
|
||||||
|
|
||||||
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],
|
|
||||||
})
|
|
||||||
|
|
||||||
subheading = video.get('subheading')
|
|
||||||
if subheading:
|
|
||||||
title += ' - %s' % subheading
|
|
||||||
|
|
||||||
return {
|
|
||||||
'id': video_id,
|
|
||||||
'title': title,
|
|
||||||
'description': video.get('long_description') or video.get(
|
|
||||||
'short_description'),
|
|
||||||
'duration': float_or_none(video.get('duration'), scale=1000),
|
|
||||||
'formats': formats,
|
|
||||||
'subtitles': subtitles,
|
|
||||||
}
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
return self.extract_info(video_id)
|
html = self._download_webpage(url, video_id)
|
||||||
|
try:
|
||||||
|
return self.url_result(self._og_search_url(html), RedBullIE, video_id)
|
||||||
|
except Exception:
|
||||||
|
raise ExtractorError('Failed to extract video URL', expected=True)
|
||||||
|
|
||||||
|
|
||||||
class RedBullEmbedIE(RedBullTVIE): # XXX: Do not subclass from concrete IE
|
class RedBullEmbedIE(RedBullBaseIE):
|
||||||
_VALID_URL = r'https?://(?:www\.)?redbull\.com/embed/(?P<id>rrn:content:[^:]+:[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}:[a-z]{2}-[A-Z]{2,3})'
|
_VALID_URL = r'https?://(?:www\.)?redbull\.com/embed/(?P<id>rrn:content:[^:]+:[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}:[a-z]{2}-[A-Z]{2,3})'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
# HLS manifest accessible only using assetId
|
|
||||||
'url': 'https://www.redbull.com/embed/rrn:content:episode-videos:f3021f4f-3ed4-51ac-915a-11987126e405:en-INT',
|
'url': 'https://www.redbull.com/embed/rrn:content:episode-videos:f3021f4f-3ed4-51ac-915a-11987126e405:en-INT',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.redbull.com/embed/rrn:content:videos:0c1d4526-2dfc-4491-bc24-239560dbdfff:en-INT',
|
||||||
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
_VIDEO_ESSENSE_TMPL = '''... on %s {
|
|
||||||
videoEssence {
|
|
||||||
attributes
|
|
||||||
}
|
|
||||||
}'''
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
rrn_id = self._match_id(url)
|
rrn_id = self._match_id(url)
|
||||||
asset_id = self._download_json(
|
video_resource = self._get_video_resource(rrn_id)
|
||||||
'https://edge-graphql.crepo-production.redbullaws.com/v1/graphql',
|
return self.url_result(
|
||||||
rrn_id, headers={
|
video_resource['url'], RedBullIE,
|
||||||
'Accept': 'application/json',
|
video_resource['assetId'], video_resource['title'])
|
||||||
'API-KEY': 'e90a1ff11335423998b100c929ecc866',
|
|
||||||
}, query={
|
|
||||||
'query': '''{
|
|
||||||
resource(id: "%s", enforceGeoBlocking: false) {
|
|
||||||
%s
|
|
||||||
%s
|
|
||||||
}
|
|
||||||
}''' % (rrn_id, self._VIDEO_ESSENSE_TMPL % 'LiveVideo', self._VIDEO_ESSENSE_TMPL % 'VideoResource'),
|
|
||||||
})['data']['resource']['videoEssence']['attributes']['assetId']
|
|
||||||
return self.extract_info(asset_id)
|
|
||||||
|
|
||||||
|
|
||||||
class RedBullTVRrnContentIE(InfoExtractor):
|
class RedBullTVRrnContentIE(InfoExtractor):
|
||||||
|
@ -158,67 +141,256 @@ class RedBullTVRrnContentIE(InfoExtractor):
|
||||||
rrn_id += ':%s-%s' % (lang, region.upper())
|
rrn_id += ':%s-%s' % (lang, region.upper())
|
||||||
return self.url_result(
|
return self.url_result(
|
||||||
'https://www.redbull.com/embed/' + rrn_id,
|
'https://www.redbull.com/embed/' + rrn_id,
|
||||||
RedBullEmbedIE.ie_key(), rrn_id)
|
RedBullEmbedIE, rrn_id)
|
||||||
|
|
||||||
|
|
||||||
class RedBullIE(InfoExtractor):
|
class RedBullIE(RedBullBaseIE):
|
||||||
_VALID_URL = r'https?://(?:www\.)?redbull\.com/(?P<region>[a-z]{2,3})-(?P<lang>[a-z]{2})/(?P<type>(?:episode|film|(?:(?:recap|trailer)-)?video)s|live)/(?!AP-|rrn:content:)(?P<id>[^/?#&]+)'
|
_VALID_URL = r'https?:\/\/(?:www\.)?redbull\.com\/(?P<region>[a-z]{2,3})-(?P<lang>[a-z]{2})\/(?P<type>videos|films|episodes|live|recap-videos|trailer-videos)\/(?P<slug>[a-z0-9-_]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
|
'url': 'https://www.redbull.com/int-en/videos/metal-on-streif-dominik-paris-in-kitzbuhel',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'AAMU3BN1Z0J04IFZVPJ1',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Metal on Streif: Dominik Paris in Kitzbühel',
|
||||||
|
'description': 'md5:b140b299dca20f5d7b3ca561fe5a5d24',
|
||||||
|
'upload_date': '20240209',
|
||||||
|
'timestamp': 1707472608,
|
||||||
|
'duration': 1977.0,
|
||||||
|
'thumbnail': r're:^https?://',
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.redbull.com/int-en/videos/swatch-nines-2023-best-performers?playlistId=rrn:content:videos:22c7c969-85b9-4d30-9b60-a7eda2432c06:en-INT',
|
||||||
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.redbull.com/int-en/films/moto-maverick',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'AA-21YW2JS5S1W12',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Moto Maverick',
|
||||||
|
'description': 'Ryan Sipes examines the current state of motocross racing through a stylised and cinematic lens.',
|
||||||
|
'upload_date': '20211224',
|
||||||
|
'timestamp': 1640332802,
|
||||||
|
'duration': 1425,
|
||||||
|
'thumbnail': r're:^https?://',
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.redbull.com/int-en/films/in-the-wings?autoplay=true',
|
||||||
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.redbull.com/int-en/episodes/more-than-a-dive-s1-e6',
|
||||||
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
'url': 'https://www.redbull.com/int-en/episodes/grime-hashtags-s02-e04',
|
'url': 'https://www.redbull.com/int-en/episodes/grime-hashtags-s02-e04',
|
||||||
'md5': 'db8271a7200d40053a1809ed0dd574ff',
|
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'AA-1MT8DQWA91W14',
|
'id': 'AA-1MT8DQWA91W14',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Grime - Hashtags S2E4',
|
'title': 'Grime',
|
||||||
'description': 'md5:5546aa612958c08a98faaad4abce484d',
|
'description': 'Evolving from hip-hop, electronic, and dancehall, grime is a murky musical movement full of passion.',
|
||||||
|
'upload_date': '20170221',
|
||||||
|
'timestamp': 1487660400,
|
||||||
|
'duration': 904.0,
|
||||||
|
'thumbnail': r're:^https?://',
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://www.redbull.com/int-en/films/kilimanjaro-mountain-of-greatness',
|
'url': 'https://www.redbull.com/int-en/live/mondo-classic-2024',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://www.redbull.com/int-en/recap-videos/uci-mountain-bike-world-cup-2017-mens-xco-finals-from-vallnord',
|
# as a part of a playlist
|
||||||
'only_matching': True,
|
'url': 'https://www.redbull.com/int-en/live/laax-open-2024-freeski-slopestyle',
|
||||||
|
'md5': 'cc5e51240689add2f39560ea7c4a4e91',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'AA2FV4NQNYSNBJXIEXPT',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Freeski Slopestyle',
|
||||||
|
'description': 'md5:86f51cb9624d359438e8988449b4621e',
|
||||||
|
'upload_date': '20231222',
|
||||||
|
'timestamp': 1703251679,
|
||||||
|
'thumbnail': r're:^https?://',
|
||||||
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://www.redbull.com/int-en/trailer-videos/kings-of-content',
|
'url': 'https://www.redbull.com/int-en/live/laax-open-2024-snowboard-slopestyle?playlistId=rrn:content:live-videos:c4c1b1c8-445a-4bcb-9fb8-d8c510ed69bc:en-INT',
|
||||||
'only_matching': True,
|
|
||||||
}, {
|
|
||||||
'url': 'https://www.redbull.com/int-en/videos/tnts-style-red-bull-dance-your-style-s1-e12',
|
|
||||||
'only_matching': True,
|
|
||||||
}, {
|
|
||||||
'url': 'https://www.redbull.com/int-en/live/mens-dh-finals-fort-william',
|
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}, {
|
}, {
|
||||||
# only available on the int-en website so a fallback is need for the API
|
# only available on the int-en website so a fallback is need for the API
|
||||||
# https://www.redbull.com/v3/api/graphql/v1/v3/query/en-GB>en-INT?filter[uriSlug]=fia-wrc-saturday-recap-estonia&rb3Schema=v1:hero
|
# https://www.redbull.com/v3/api/graphql/v1/v3/query/en-GB>en-INT?filter[uriSlug]=fia-wrc-saturday-recap-estonia&rb3Schema=v1:videoHero
|
||||||
'url': 'https://www.redbull.com/gb-en/live/fia-wrc-saturday-recap-estonia',
|
'url': 'https://www.redbull.com/gb-en/live/fia-wrc-saturday-recap-estonia',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.redbull.com/int-en/recap-videos/uci-mountain-bike-world-cup-2017-mens-xco-finals-from-vallnord',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'AA-1UM6YNYX92112',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Men\'s XCO finals from Vallnord',
|
||||||
|
'description': 'The world’s best men take on the gruelling cross-country course in Vallnord, Andorra.',
|
||||||
|
'upload_date': '20180201',
|
||||||
|
'timestamp': 1517468400,
|
||||||
|
'duration': 6761.0,
|
||||||
|
'thumbnail': r're:^https?://',
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.redbull.com/int-en/trailer-videos/kings-of-content',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'AA-1PRQ4VRAW1W12',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Kings of Content',
|
||||||
|
'description': 'md5:4af0f7d9938aef4db22115d3b56f02dd',
|
||||||
|
'upload_date': '20170411',
|
||||||
|
'timestamp': 1491901200,
|
||||||
|
'duration': 45.0,
|
||||||
|
'thumbnail': r're:^https?://',
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
|
},
|
||||||
}]
|
}]
|
||||||
_INT_FALLBACK_LIST = ['de', 'en', 'es', 'fr']
|
|
||||||
_LAT_FALLBACK_MAP = ['ar', 'bo', 'car', 'cl', 'co', 'mx', 'pe']
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
region, lang, filter_type, display_id = self._match_valid_url(url).groups()
|
region, lang, type, slug = self._match_valid_url(url).groups()
|
||||||
if filter_type == 'episodes':
|
if type == 'episodes':
|
||||||
filter_type = 'episode-videos'
|
type = 'episode-videos'
|
||||||
elif filter_type == 'live':
|
if type == 'live':
|
||||||
filter_type = 'live-videos'
|
type = 'live-videos'
|
||||||
|
|
||||||
regions = [region.upper()]
|
video_object = self._call_api(
|
||||||
if region != 'int':
|
self._SCHEMAS['structured_data'], type, slug, region, lang)
|
||||||
if region in self._LAT_FALLBACK_MAP:
|
if type == 'films' or type == 'episode-videos':
|
||||||
regions.append('LAT')
|
video_object = video_object['associatedMedia']
|
||||||
if lang in self._INT_FALLBACK_LIST:
|
|
||||||
regions.append('INT')
|
|
||||||
locale = '>'.join(['%s-%s' % (lang, reg) for reg in regions])
|
|
||||||
|
|
||||||
rrn_id = self._download_json(
|
rrn_id = video_object['embedUrl'].replace('https://www.redbull.com/embed/', '')
|
||||||
'https://www.redbull.com/v3/api/graphql/v1/v3/query/' + locale,
|
|
||||||
display_id, query={
|
|
||||||
'filter[type]': filter_type,
|
|
||||||
'filter[uriSlug]': display_id,
|
|
||||||
'rb3Schema': 'v1:hero',
|
|
||||||
})['data']['id']
|
|
||||||
|
|
||||||
return self.url_result(
|
return {
|
||||||
'https://www.redbull.com/embed/' + rrn_id,
|
**self._extract_video_resource(rrn_id),
|
||||||
RedBullEmbedIE.ie_key(), rrn_id)
|
**traverse_obj(video_object, {
|
||||||
|
'title': ('name', {str}),
|
||||||
|
'description': ('description', {str}),
|
||||||
|
'duration': ('duration', {parse_duration}),
|
||||||
|
'timestamp': ('uploadDate', {parse_iso8601}),
|
||||||
|
'thumbnail': ('thumbnailUrl', {url_or_none}),
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class RedBullChannelIE(RedBullBaseIE):
|
||||||
|
_VALID_URL = r'https?:\/\/(?:www\.)?redbull\.com\/(?P<region>[a-z]{2,3})-(?P<lang>[a-z]{2})\/channels\/(?P<slug>[a-z0-9-_]+)'
|
||||||
|
_TESTS = [{
|
||||||
|
'url': 'https://www.redbull.com/int-en/channels/best-of-red-bull-stream',
|
||||||
|
'only_matching': True,
|
||||||
|
}]
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
region, lang, slug = self._match_valid_url(url).groups()
|
||||||
|
# structured_data is not available for channels
|
||||||
|
video_hero = self._call_api(
|
||||||
|
self._SCHEMAS['video_hero'], 'video-channels', slug, region, lang)
|
||||||
|
return {
|
||||||
|
**self._extract_video_resource(video_hero['id']),
|
||||||
|
'title': traverse_obj(video_hero, ('title', {str})),
|
||||||
|
'is_live': True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class RedBullEventIE(RedBullBaseIE):
|
||||||
|
_VALID_URL = r'https?:\/\/(?:www\.)?redbull\.com\/(?P<region>[a-z]{2,3})-(?P<lang>[a-z]{2})\/events\/(?P<slug>[a-z0-9-_]+)'
|
||||||
|
_TESTS = [{
|
||||||
|
# one replay
|
||||||
|
'url': 'https://www.redbull.com/int-en/events/mondo-classic',
|
||||||
|
'md5': 'ca8ed1669b71907c68b00cce216cb506',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'AA3YMCCKHF7JGGUY8HY7',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Livestream',
|
||||||
|
'description': 'md5:deff294a59c0e692acfa51e2d02d4b5c',
|
||||||
|
'upload_date': '20240125',
|
||||||
|
'timestamp': 1706191087,
|
||||||
|
'thumbnail': r're:^https?://',
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
# multiple replays
|
||||||
|
'url': 'https://www.redbull.com/int-en/events/laax-open',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'laax-open',
|
||||||
|
'title': 'Laax Open',
|
||||||
|
},
|
||||||
|
'playlist_mincount': 5,
|
||||||
|
}, {
|
||||||
|
# no replays
|
||||||
|
'url': 'https://www.redbull.com/int-en/events/hahnenkamm-rennen',
|
||||||
|
'only_matching': True,
|
||||||
|
}]
|
||||||
|
|
||||||
|
def _get_livestream_slug(self, html):
|
||||||
|
livestream_div = get_element_html_by_class('playable-livestream__media', html)
|
||||||
|
if not livestream_div:
|
||||||
|
raise ExtractorError('Livestream not found', expected=True)
|
||||||
|
_, livestream_a = get_element_text_and_html_by_tag('a', livestream_div)
|
||||||
|
return extract_attributes(livestream_a)['href'].split('/')[3]
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
region, lang, slug = self._match_valid_url(url).groups()
|
||||||
|
html = self._download_webpage(url, slug)
|
||||||
|
|
||||||
|
livestream_slug = self._get_livestream_slug(html)
|
||||||
|
video_hero = self._call_api(
|
||||||
|
self._SCHEMAS['video_hero'], 'live-videos', livestream_slug, region, lang)
|
||||||
|
|
||||||
|
sidebar_items = traverse_obj(video_hero, ('sidebar', 'tabs', 0, 'items'))
|
||||||
|
if not sidebar_items:
|
||||||
|
return self.url_result(
|
||||||
|
'https://www.redbull.com/embed/' + video_hero['id'],
|
||||||
|
RedBullEmbedIE, livestream_slug)
|
||||||
|
|
||||||
|
title = clean_html(get_element_by_class('event-hero-view__title', html))
|
||||||
|
|
||||||
|
def entries():
|
||||||
|
for video in sidebar_items:
|
||||||
|
url = 'https://www.redbull.com/embed/' + video['id']
|
||||||
|
yield self.url_result(url, RedBullEmbedIE, video['id'])
|
||||||
|
|
||||||
|
return self.playlist_result(entries(), slug, title)
|
||||||
|
|
||||||
|
|
||||||
|
class RedBullShowIE(RedBullBaseIE):
|
||||||
|
_VALID_URL = r'https?:\/\/(?:www\.)?redbull\.com\/(?P<region>[a-z]{2,3})-(?P<lang>[a-z]{2})\/shows\/(?P<slug>[a-z0-9-_]+)'
|
||||||
|
_TESTS = [{
|
||||||
|
# one season
|
||||||
|
'url': 'https://www.redbull.com/int-en/shows/in-the-dust',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'in-the-dust',
|
||||||
|
'title': 'Dakar: In the Dust',
|
||||||
|
},
|
||||||
|
'playlist_mincount': 8,
|
||||||
|
}, {
|
||||||
|
# multiple seasons
|
||||||
|
'url': 'https://www.redbull.com/int-en/shows/fia-world-rally-raid-championship',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'fia-world-rally-raid-championship',
|
||||||
|
'title': 'FIA World Rally-Raid Championship',
|
||||||
|
},
|
||||||
|
'playlist_mincount': 9,
|
||||||
|
}]
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
region, lang, slug = self._match_valid_url(url).groups()
|
||||||
|
tv_series = self._call_api(
|
||||||
|
self._SCHEMAS['structured_data'], 'shows', slug, region, lang)
|
||||||
|
|
||||||
|
def entries():
|
||||||
|
for season in tv_series['containsSeason']:
|
||||||
|
for episode in season['episode']:
|
||||||
|
url = episode['associatedMedia']['url']
|
||||||
|
episode_id = url.split('/')[5]
|
||||||
|
yield self.url_result(url, RedBullIE, episode_id)
|
||||||
|
|
||||||
|
return self.playlist_result(entries(), slug, tv_series['name'])
|
||||||
|
|
|
@ -132,6 +132,16 @@ class CurlCFFIRH(ImpersonateRequestHandler, InstanceStoreMixin):
|
||||||
extensions.pop('cookiejar', None)
|
extensions.pop('cookiejar', None)
|
||||||
extensions.pop('timeout', None)
|
extensions.pop('timeout', None)
|
||||||
|
|
||||||
|
def send(self, request: Request) -> Response:
|
||||||
|
target = self._get_request_target(request)
|
||||||
|
try:
|
||||||
|
response = super().send(request)
|
||||||
|
except HTTPError as e:
|
||||||
|
e.response.extensions['impersonate'] = target
|
||||||
|
raise
|
||||||
|
response.extensions['impersonate'] = target
|
||||||
|
return response
|
||||||
|
|
||||||
def _send(self, request: Request):
|
def _send(self, request: Request):
|
||||||
max_redirects_exceeded = False
|
max_redirects_exceeded = False
|
||||||
session: curl_cffi.requests.Session = self._get_instance(
|
session: curl_cffi.requests.Session = self._get_instance(
|
||||||
|
|
|
@ -497,6 +497,7 @@ class Response(io.IOBase):
|
||||||
@param headers: response headers.
|
@param headers: response headers.
|
||||||
@param status: Response HTTP status code. Default is 200 OK.
|
@param status: Response HTTP status code. Default is 200 OK.
|
||||||
@param reason: HTTP status reason. Will use built-in reasons based on status code if not provided.
|
@param reason: HTTP status reason. Will use built-in reasons based on status code if not provided.
|
||||||
|
@param extensions: Dictionary of handler-specific response extensions.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -505,7 +506,9 @@ class Response(io.IOBase):
|
||||||
url: str,
|
url: str,
|
||||||
headers: Mapping[str, str],
|
headers: Mapping[str, str],
|
||||||
status: int = 200,
|
status: int = 200,
|
||||||
reason: str = None):
|
reason: str = None,
|
||||||
|
extensions: dict = None
|
||||||
|
):
|
||||||
|
|
||||||
self.fp = fp
|
self.fp = fp
|
||||||
self.headers = Message()
|
self.headers = Message()
|
||||||
|
@ -517,6 +520,7 @@ class Response(io.IOBase):
|
||||||
self.reason = reason or HTTPStatus(status).phrase
|
self.reason = reason or HTTPStatus(status).phrase
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.reason = None
|
self.reason = None
|
||||||
|
self.extensions = extensions or {}
|
||||||
|
|
||||||
def readable(self):
|
def readable(self):
|
||||||
return self.fp.readable()
|
return self.fp.readable()
|
||||||
|
|
Loading…
Reference in New Issue