From dbc380f0f51523c51fe88928d868d33e48584c18 Mon Sep 17 00:00:00 2001 From: Nirvana Date: Sun, 3 May 2026 22:01:29 +0200 Subject: [PATCH] Prepare RTLPlus for new streaming prov --- .../providers/rtlplus/constants.py | 1 + .../providers/rtlplus/vod_manager.py | 29 ++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/streaming_providers/providers/rtlplus/constants.py b/lib/streaming_providers/providers/rtlplus/constants.py index 22dc149..3b5ee75 100644 --- a/lib/streaming_providers/providers/rtlplus/constants.py +++ b/lib/streaming_providers/providers/rtlplus/constants.py @@ -70,6 +70,7 @@ class RTLPlusDefaults: # Image CDN IMAGE_BASE_URL = "https://images-fio.rtlde.bedrock.tech/v2/images" IMAGE_PARAMS = "auto=webp&blur=0&fit=scale_crop&height=320&interlace=1&optimize=high&width=213" + IMAGE_SIGNING_KEY = "x9vGg4RNeNBqV2nBfhqLV6cN4n" # Anonymous credentials (fallback) ANONYMOUS_CLIENT_ID = "anonymous-user" diff --git a/lib/streaming_providers/providers/rtlplus/vod_manager.py b/lib/streaming_providers/providers/rtlplus/vod_manager.py index 5bfdd52..2cf8204 100644 --- a/lib/streaming_providers/providers/rtlplus/vod_manager.py +++ b/lib/streaming_providers/providers/rtlplus/vod_manager.py @@ -797,14 +797,19 @@ class RTLPlusVodManager: # Thumbnail / duration helpers (pure, no I/O) # ------------------------------------------------------------------ - @classmethod - def _build_image_url(cls, image_id: str, image_hash: str = None) -> str: - """Build a Bedrock CDN image URL, appending the hash when available.""" + @staticmethod + def _build_image_url(image_id: str) -> str: + """Build a signed Bedrock CDN image URL. + + Hash formula: SHA1("/v2/images/{id}/raw?{params}" + signing_key) + """ + import hashlib from .constants import RTLPlusDefaults - url = f"{RTLPlusDefaults.IMAGE_BASE_URL}/{image_id}/raw?{RTLPlusDefaults.IMAGE_PARAMS}" - if image_hash: - url += f"&hash={image_hash}" - return url + path_and_query = f"/v2/images/{image_id}/raw?{RTLPlusDefaults.IMAGE_PARAMS}" + image_hash = hashlib.sha1( + (path_and_query + RTLPlusDefaults.IMAGE_SIGNING_KEY).encode() + ).hexdigest() + return f"{RTLPlusDefaults.IMAGE_BASE_URL}{path_and_query}&hash={image_hash}" @classmethod def _extract_thumbnail(cls, item_content: Dict) -> Optional[str]: @@ -814,19 +819,17 @@ class RTLPlusVodManager: for ratio in ("16:9", "3:1", "1:1", "2:3"): image_id = image.get("idsByRatio", {}).get(ratio) if image_id: - image_hash = image.get("hashesByRatio", {}).get(ratio) or image.get("hash") - return cls._build_image_url(image_id, image_hash) + return cls._build_image_url(image_id) image_id = image.get("id") if image_id: - return cls._build_image_url(image_id, image.get("hash")) + return cls._build_image_url(image_id) return None @classmethod def _extract_thumbnail_from_layout(cls, layout: Dict) -> Optional[str]: - image = layout.get("seo", {}).get("image", {}) - image_id = image.get("id") + image_id = layout.get("seo", {}).get("image", {}).get("id") if image_id: - return cls._build_image_url(image_id, image.get("hash")) + return cls._build_image_url(image_id) return None @staticmethod