Prepare recordings

This commit is contained in:
Nirvana
2026-03-23 18:03:13 +01:00
parent eb3127161a
commit 2892cbd38b
2 changed files with 16 additions and 1 deletions
@@ -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,
)
@@ -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 ─────────────────────────