From 2892cbd38b07484b9c251059f71107db3f50fa67 Mon Sep 17 00:00:00 2001 From: Nirvana Date: Mon, 23 Mar 2026 18:03:13 +0100 Subject: [PATCH] Prepare recordings --- lib/streaming_providers/providers/lib_theplatform.py | 9 ++++++++- lib/streaming_providers/providers/magenta2/provider.py | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/streaming_providers/providers/lib_theplatform.py b/lib/streaming_providers/providers/lib_theplatform.py index ef384f2..4775596 100644 --- a/lib/streaming_providers/providers/lib_theplatform.py +++ b/lib/streaming_providers/providers/lib_theplatform.py @@ -212,6 +212,7 @@ def fetch_distribution_rights( cid: str, user_agent: str, timeout: int = 30, + extra_headers: Optional[dict] = None, ) -> List[str]: """ Call getApplicableDistributionRights and return the list of right URLs. @@ -223,15 +224,21 @@ def fetch_distribution_rights( cid: Correlation ID string "session_id::call_id" user_agent: Platform user-agent string. timeout: HTTP timeout in seconds. + extra_headers: Optional additional headers merged on top of the + default set (e.g. Authorization, Origin, Referer). + Caller-supplied keys take precedence. Returns: List of DistributionRight URL strings, empty on failure. """ try: + headers = {"User-Agent": user_agent, "Accept": "application/json"} + if extra_headers: + headers.update(extra_headers) response = http_manager.get( rights_url, operation="get_distribution_rights", - headers={"User-Agent": user_agent, "Accept": "application/json"}, + headers=headers, params={"form": "json", "schema": "1.2", "cid": cid}, timeout=timeout, ) diff --git a/lib/streaming_providers/providers/magenta2/provider.py b/lib/streaming_providers/providers/magenta2/provider.py index 84692a1..a187ae6 100644 --- a/lib/streaming_providers/providers/magenta2/provider.py +++ b/lib/streaming_providers/providers/magenta2/provider.py @@ -829,12 +829,20 @@ class Magenta2Provider(StreamingProvider): "No license_service_url available – configuration discovery may have failed" ) + persona_token = self._ensure_authenticated() + auth_headers = { + "Authorization": f"Basic {persona_token}", + "Origin": "https://www.magenta.tv", + "Referer": "https://www.magenta.tv/", + } + distribution_rights = fetch_distribution_rights( http_manager=self.http_manager, rights_url=rights_url, cid=cid, user_agent=user_agent, timeout=DEFAULT_REQUEST_TIMEOUT, + extra_headers=auth_headers, ) # ── Step 2: fetch entitled-channels feed ─────────────────────────