From 94b5fcc9887b89f6dcf31b40825086ced5797d83 Mon Sep 17 00:00:00 2001
From: Aleksei Gusev <gusev.alexey.v@gmail.com>
Date: Fri, 7 Feb 2025 01:25:03 +0300
Subject: [PATCH 1/2] [ie/redbulltv] Fix red bull tv extractor

- Update embedded extractor url
- Make video metadata optional with title fallback
---
 yt_dlp/extractor/redbulltv.py | 44 +++++++++++++++--------------------
 1 file changed, 19 insertions(+), 25 deletions(-)

diff --git a/yt_dlp/extractor/redbulltv.py b/yt_dlp/extractor/redbulltv.py
index ceeef52045..c17dfcb8ad 100644
--- a/yt_dlp/extractor/redbulltv.py
+++ b/yt_dlp/extractor/redbulltv.py
@@ -1,5 +1,4 @@
 from .common import InfoExtractor
-from ..networking.exceptions import HTTPError
 from ..utils import (
     ExtractorError,
     float_or_none,
@@ -61,6 +60,7 @@ class RedBullTVIE(InfoExtractor):
                 self.IE_NAME, session['message']))
         token = session['token']
 
+        video = {}
         try:
             video = self._download_json(
                 'https://api.redbull.tv/v3/products/' + video_id,
@@ -68,13 +68,9 @@ class RedBullTVIE(InfoExtractor):
                 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(f'{self.IE_NAME} said: {error_message}', expected=True)
-            raise
+            self.to_screen(f'Downloading video information failed, {e.cause.response.read().decode()}')
 
-        title = video['title'].strip()
+        title = (video.get('title') or 'title').strip()
 
         formats, subtitles = self._extract_m3u8_formats_and_subtitles(
             f'https://dms.redbull.tv/v3/{video_id}/{token}/playlist.m3u8',
@@ -123,19 +119,11 @@ class RedBullEmbedIE(RedBullTVIE):  # XXX: Do not subclass from concrete IE
 
     def _real_extract(self, url):
         rrn_id = self._match_id(url)
-        asset_id = self._download_json(
-            'https://edge-graphql.crepo-production.redbullaws.com/v1/graphql',
-            rrn_id, headers={
-                'Accept': 'application/json',
-                'API-KEY': 'e90a1ff11335423998b100c929ecc866',
-            }, query={
-                'query': '''{
-  resource(id: "%s", enforceGeoBlocking: false) {
-    %s
-    %s
-  }
-}''' % (rrn_id, self._VIDEO_ESSENSE_TMPL % 'LiveVideo', self._VIDEO_ESSENSE_TMPL % 'VideoResource'),  # noqa: UP031
-            })['data']['resource']['videoEssence']['attributes']['assetId']
+        data = self._download_json(
+            url_or_request=f'https://api-player.redbull.com/rbcom/videoresource?videoId={rrn_id}',
+            video_id=rrn_id,
+        )
+        asset_id = data['assetId']
         return self.extract_info(asset_id)
 
 
@@ -210,13 +198,19 @@ 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,
-            display_id, query={
+        response_data = self._download_json(
+            'https://www.redbull.com/v3/api/graphql/v1/v3/feed/' + locale,
+            display_id,
+            query={
+                'page[limit]': '1',
+                'disableUsageRestrictions': 'true',
                 'filter[type]': filter_type,
                 'filter[uriSlug]': display_id,
-                'rb3Schema': 'v1:hero',
-            })['data']['id']
+                'rb3Schema': 'v1:pageConfig',
+                'rb3PageUrl': f'/{region}-{lang}/{filter_type}/{display_id}',
+            },
+        )
+        rrn_id = response_data['data']['id']
 
         return self.url_result(
             'https://www.redbull.com/embed/' + rrn_id,

From f6d97b3060bb555417bec01003346dc722da653d Mon Sep 17 00:00:00 2001
From: Aleksei Gusev <gusev.alexey.v@gmail.com>
Date: Sun, 9 Feb 2025 01:10:36 +0300
Subject: [PATCH 2/2] fix warning

---
 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 c17dfcb8ad..a265a07f9b 100644
--- a/yt_dlp/extractor/redbulltv.py
+++ b/yt_dlp/extractor/redbulltv.py
@@ -68,7 +68,7 @@ class RedBullTVIE(InfoExtractor):
                 headers={'Authorization': token},
             )
         except ExtractorError as e:
-            self.to_screen(f'Downloading video information failed, {e.cause.response.read().decode()}')
+            self.report_warning(f'Downloading video information failed, {e.cause.response.read().decode()}')
 
         title = (video.get('title') or 'title').strip()