From edf7d0ebd320b8e14b368ebbe0e4d6f94e69ddf2 Mon Sep 17 00:00:00 2001 From: "Antti S." Date: Mon, 6 Jan 2025 20:35:36 +0200 Subject: [PATCH 1/6] [RedBullIE] Fixed API-endpoint changes. --- yt_dlp/extractor/redbulltv.py | 51 +++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/yt_dlp/extractor/redbulltv.py b/yt_dlp/extractor/redbulltv.py index ceeef52045..262b9036d7 100644 --- a/yt_dlp/extractor/redbulltv.py +++ b/yt_dlp/extractor/redbulltv.py @@ -168,12 +168,26 @@ class RedBullIE(InfoExtractor): 'info_dict': { 'id': 'AA-1MT8DQWA91W14', 'ext': 'mp4', - 'title': 'Grime - Hashtags S2E4', + 'title': 'Grime', 'description': 'md5:5546aa612958c08a98faaad4abce484d', + 'duration': 904.0, + }, + 'params': { + 'skip_download': True, }, }, { 'url': 'https://www.redbull.com/int-en/films/kilimanjaro-mountain-of-greatness', - 'only_matching': True, + 'md5': 'db8271a7200d40053a1809ed0dd574ff', + 'info_dict': { + 'id': 'AA-1UDTFEPTW1W12', + 'ext': 'mp4', + 'title': 'Kilimanjaro: Mountain of Greatness', + 'description': 'md5:e44aedc87ff8587307a4a20fdfe8db61', + 'duration': 1834.0, + }, + 'params': { + 'skip_download': True, + }, }, { 'url': 'https://www.redbull.com/int-en/recap-videos/uci-mountain-bike-world-cup-2017-mens-xco-finals-from-vallnord', 'only_matching': True, @@ -210,14 +224,29 @@ class RedBullIE(InfoExtractor): regions.append('INT') locale = '>'.join([f'{lang}-{reg}' for reg in regions]) - rrn_id = self._download_json( - 'https://www.redbull.com/v3/api/graphql/v1/v3/query/' + locale, + rrn_data = self._download_json( + 'https://www.redbull.com/v3/api/graphql/v1/v3/feed/' + locale, display_id, query={ - 'filter[type]': filter_type, - 'filter[uriSlug]': display_id, - 'rb3Schema': 'v1:hero', - })['data']['id'] + 'filter[type]': filter_type, 'page[limit]': 1, 'filter[uriSlug]': display_id, + 'disableUsageRestrictions': 'true', 'rb3Schema': 'v1:pageConfig', + 'rb3PageUrl': '/' + region.lower() + '-' + lang.lower() + '/' + filter_type + '/' + display_id, + })['data'] + + video_info = self._download_json( + 'https://api-player.redbull.com/rbcom/videoresource', display_id, query={ + 'videoId': rrn_data['id'], + 'localeMixing': locale, + }) - return self.url_result( - 'https://www.redbull.com/embed/' + rrn_id, - RedBullEmbedIE.ie_key(), rrn_id) + video_id = video_info['assetId'] + formats, subtitles = self._extract_m3u8_formats_and_subtitles(video_info['videoUrl'], + video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls') + + return { + 'id': video_id, + 'title': video_info['title'], + 'description': rrn_data['pageMeta'].get('description') or None, + 'duration': float_or_none(video_info['duration']), + 'formats': formats, + 'subtitles': subtitles, + } From 7b9398f1d15edc0ea0ed2f4bc4d352e7eab4d880 Mon Sep 17 00:00:00 2001 From: suanto Date: Tue, 7 Jan 2025 15:48:33 +0200 Subject: [PATCH 2/6] Update yt_dlp/extractor/redbulltv.py Fix Url formatting. Co-authored-by: pukkandan --- yt_dlp/extractor/redbulltv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt_dlp/extractor/redbulltv.py b/yt_dlp/extractor/redbulltv.py index 262b9036d7..d9df4f2ff7 100644 --- a/yt_dlp/extractor/redbulltv.py +++ b/yt_dlp/extractor/redbulltv.py @@ -225,7 +225,7 @@ class RedBullIE(InfoExtractor): locale = '>'.join([f'{lang}-{reg}' for reg in regions]) rrn_data = self._download_json( - 'https://www.redbull.com/v3/api/graphql/v1/v3/feed/' + locale, + f'https://www.redbull.com/v3/api/graphql/v1/v3/feed/{locale}', display_id, query={ 'filter[type]': filter_type, 'page[limit]': 1, 'filter[uriSlug]': display_id, 'disableUsageRestrictions': 'true', 'rb3Schema': 'v1:pageConfig', From aa72488bd69b71f979d73b690e611bb82142c918 Mon Sep 17 00:00:00 2001 From: suanto Date: Tue, 7 Jan 2025 15:49:01 +0200 Subject: [PATCH 3/6] Update yt_dlp/extractor/redbulltv.py Fix Url formatting. Co-authored-by: pukkandan --- yt_dlp/extractor/redbulltv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt_dlp/extractor/redbulltv.py b/yt_dlp/extractor/redbulltv.py index d9df4f2ff7..ef7344b5d2 100644 --- a/yt_dlp/extractor/redbulltv.py +++ b/yt_dlp/extractor/redbulltv.py @@ -229,7 +229,7 @@ class RedBullIE(InfoExtractor): display_id, query={ 'filter[type]': filter_type, 'page[limit]': 1, 'filter[uriSlug]': display_id, 'disableUsageRestrictions': 'true', 'rb3Schema': 'v1:pageConfig', - 'rb3PageUrl': '/' + region.lower() + '-' + lang.lower() + '/' + filter_type + '/' + display_id, + 'rb3PageUrl': f'/{region.lower()}-{lang.lower()}/{filter_type}/{display_id}', })['data'] video_info = self._download_json( From 0bc6814c9f065b8f7c4980469a4f99595b7c6e62 Mon Sep 17 00:00:00 2001 From: suanto Date: Tue, 7 Jan 2025 15:49:54 +0200 Subject: [PATCH 4/6] Update yt_dlp/extractor/redbulltv.py Fix indentation. Co-authored-by: pukkandan --- yt_dlp/extractor/redbulltv.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yt_dlp/extractor/redbulltv.py b/yt_dlp/extractor/redbulltv.py index ef7344b5d2..13a562946f 100644 --- a/yt_dlp/extractor/redbulltv.py +++ b/yt_dlp/extractor/redbulltv.py @@ -239,8 +239,8 @@ class RedBullIE(InfoExtractor): }) video_id = video_info['assetId'] - formats, subtitles = self._extract_m3u8_formats_and_subtitles(video_info['videoUrl'], - video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls') + formats, subtitles = self._extract_m3u8_formats_and_subtitles( + video_info['videoUrl'], video_id, 'mp4', m3u8_id='hls') return { 'id': video_id, From c7a9c4d2502bf0d2227648d617efdb36dc2940f3 Mon Sep 17 00:00:00 2001 From: "Antti S." Date: Tue, 7 Jan 2025 16:30:18 +0200 Subject: [PATCH 5/6] Field extraction more robust. Formatting fixed. Second JSON fetch to report rrn_id. --- yt_dlp/extractor/redbulltv.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/yt_dlp/extractor/redbulltv.py b/yt_dlp/extractor/redbulltv.py index 13a562946f..838ebb3dbd 100644 --- a/yt_dlp/extractor/redbulltv.py +++ b/yt_dlp/extractor/redbulltv.py @@ -3,6 +3,7 @@ from ..networking.exceptions import HTTPError from ..utils import ( ExtractorError, float_or_none, + traverse_obj ) @@ -227,26 +228,33 @@ class RedBullIE(InfoExtractor): rrn_data = self._download_json( f'https://www.redbull.com/v3/api/graphql/v1/v3/feed/{locale}', display_id, query={ - 'filter[type]': filter_type, 'page[limit]': 1, 'filter[uriSlug]': display_id, - 'disableUsageRestrictions': 'true', 'rb3Schema': 'v1:pageConfig', + 'filter[type]': filter_type, + 'page[limit]': 1, + 'filter[uriSlug]': display_id, + 'disableUsageRestrictions': 'true', + 'rb3Schema': 'v1:pageConfig', 'rb3PageUrl': f'/{region.lower()}-{lang.lower()}/{filter_type}/{display_id}', })['data'] + rrn_id = rrn_data.get('id') + video_info = self._download_json( - 'https://api-player.redbull.com/rbcom/videoresource', display_id, query={ - 'videoId': rrn_data['id'], + 'https://api-player.redbull.com/rbcom/videoresource', rrn_id, query={ + 'videoId': rrn_id, 'localeMixing': locale, }) - video_id = video_info['assetId'] + video_id = video_info.get('assetId') formats, subtitles = self._extract_m3u8_formats_and_subtitles( - video_info['videoUrl'], video_id, 'mp4', m3u8_id='hls') + video_info.get('videoUrl'), video_id, 'mp4', m3u8_id='hls') return { 'id': video_id, - 'title': video_info['title'], - 'description': rrn_data['pageMeta'].get('description') or None, - 'duration': float_or_none(video_info['duration']), + **traverse_obj(video_info, { + 'title': 'title', + 'duration': 'duration', + }), + 'description': traverse_obj(rrn_data, ('pageMeta', 'description')), 'formats': formats, 'subtitles': subtitles, } From f333ff8f7cded73abd7b6e66d98b962075ee403d Mon Sep 17 00:00:00 2001 From: "Antti S." Date: Wed, 8 Jan 2025 15:57:16 +0200 Subject: [PATCH 6/6] Formatting fixes. 'Skip download test' parameter to self-documenting one. --- yt_dlp/extractor/redbulltv.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/yt_dlp/extractor/redbulltv.py b/yt_dlp/extractor/redbulltv.py index 838ebb3dbd..7b23563189 100644 --- a/yt_dlp/extractor/redbulltv.py +++ b/yt_dlp/extractor/redbulltv.py @@ -1,10 +1,6 @@ from .common import InfoExtractor from ..networking.exceptions import HTTPError -from ..utils import ( - ExtractorError, - float_or_none, - traverse_obj -) +from ..utils import ExtractorError, float_or_none, traverse_obj class RedBullTVIE(InfoExtractor): @@ -173,9 +169,7 @@ class RedBullIE(InfoExtractor): 'description': 'md5:5546aa612958c08a98faaad4abce484d', 'duration': 904.0, }, - 'params': { - 'skip_download': True, - }, + 'params': {'skip_download': 'm3u8'}, }, { 'url': 'https://www.redbull.com/int-en/films/kilimanjaro-mountain-of-greatness', 'md5': 'db8271a7200d40053a1809ed0dd574ff', @@ -186,9 +180,7 @@ class RedBullIE(InfoExtractor): 'description': 'md5:e44aedc87ff8587307a4a20fdfe8db61', 'duration': 1834.0, }, - 'params': { - 'skip_download': True, - }, + 'params': {'skip_download': 'm3u8'}, }, { 'url': 'https://www.redbull.com/int-en/recap-videos/uci-mountain-bike-world-cup-2017-mens-xco-finals-from-vallnord', 'only_matching': True, @@ -228,10 +220,10 @@ class RedBullIE(InfoExtractor): rrn_data = self._download_json( f'https://www.redbull.com/v3/api/graphql/v1/v3/feed/{locale}', display_id, query={ - 'filter[type]': filter_type, - 'page[limit]': 1, + 'filter[type]': filter_type, + 'page[limit]': 1, 'filter[uriSlug]': display_id, - 'disableUsageRestrictions': 'true', + 'disableUsageRestrictions': 'true', 'rb3Schema': 'v1:pageConfig', 'rb3PageUrl': f'/{region.lower()}-{lang.lower()}/{filter_type}/{display_id}', })['data']