From def13e162d7d7f7cb61aa44d3a0596231819982b Mon Sep 17 00:00:00 2001 From: Nirvana Date: Fri, 10 Jul 2026 11:11:26 +0200 Subject: [PATCH] magentaeu: change epg_manager --- .../providers/magentaeu/epg_manager.py | 24 +++++++++++-------- .../providers/magentaeu/provider.py | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/streaming_providers/providers/magentaeu/epg_manager.py b/lib/streaming_providers/providers/magentaeu/epg_manager.py index 1124c04..35f91a6 100644 --- a/lib/streaming_providers/providers/magentaeu/epg_manager.py +++ b/lib/streaming_providers/providers/magentaeu/epg_manager.py @@ -27,7 +27,6 @@ Design notes from __future__ import annotations -import uuid import time from datetime import datetime, timedelta, timezone from zoneinfo import ZoneInfo @@ -409,13 +408,6 @@ class MagentaEUEpgManager: conversion belongs here; do not reintroduce it. """ merged: Dict[str, Any] = {} - headers = self._guest_headers(flow="EPG", step="EPG_SCHEDULES") - - # ✅ LOG THE FULL HEADERS (or at least the critical ones) - logger.info( - f"[MagentaEUEpgManager/{self._country}] " - f"EPG request FULL HEADERS: {headers}" - ) utc_date = self._ensure_tz(date).astimezone(timezone.utc) formatted = utc_date.strftime("%Y-%m-%d") @@ -463,12 +455,24 @@ class MagentaEUEpgManager: f"&app_language={self._app_language}" f"&natco_code={self._country}" ) - headers["x-request-tracking-id"] = str(uuid.uuid4()) - # Add retry logic max_retries = 3 block_success = False for attempt in range(max_retries): + # Build a fresh, internally-consistent header set for every + # single request (including retries). x-txn-id is a hash of + # tracking-id + call-time, so all three must be regenerated + # together — patching only tracking-id (as before) left + # x-txn-id bound to a stale/mismatched tracking-id on every + # request after the first, which upstream's edge (Akamai) + # appears to reject as malformed/replayed. + headers = self._guest_headers(flow="EPG", step="EPG_SCHEDULES") + + logger.debug( + f"[MagentaEUEpgManager/{self._country}] " + f"EPG request headers (offset={hour_offset}, attempt={attempt + 1}): {headers}" + ) + try: response = self._http.get( url, diff --git a/lib/streaming_providers/providers/magentaeu/provider.py b/lib/streaming_providers/providers/magentaeu/provider.py index 3247360..aaf6f36 100644 --- a/lib/streaming_providers/providers/magentaeu/provider.py +++ b/lib/streaming_providers/providers/magentaeu/provider.py @@ -77,7 +77,7 @@ class MagentaEUProvider(StreamingProvider): user_agent=USER_AGENT, timeout=DEFAULT_REQUEST_TIMEOUT, max_retries=DEFAULT_MAX_RETRIES, - use_tls_impersonation=(country == "hr"), # HR bifrost enforces strict JA3 fingerprinting +# use_tls_impersonation=(country == "hr"), # HR bifrost enforces strict JA3 fingerprinting ) # Initialize attributes