RTL fix channel logo ratio

This commit is contained in:
Nirvana
2026-05-18 10:53:45 +02:00
parent 99e871f677
commit 44d1dfda42
3 changed files with 8 additions and 3 deletions
@@ -16,6 +16,7 @@ from datetime import date
from .layout_helpers import unwrap_target, build_image_url
from ...base.models import Channel, DRMConfig
from ...base.utils.logger import logger
from .constants import RTLPlusDefaults
class RTLPlusChannelManager:
@@ -157,7 +158,7 @@ class RTLPlusChannelManager:
)
# Set logo URL
streaming_channel.logo_url = build_image_url(logo_id) if logo_id else ""
streaming_channel.logo_url = build_image_url(logo_id, RTLPlusDefaults.IMAGE_PARAMS_LOGO) if logo_id else ""
# Store SEO in manifest_script for fallback lookups
if seo:
@@ -69,6 +69,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_PARAMS_LOGO = "auto=avif&blur=0&fit=scale_crop&height=1080&interlace=1&optimize=high&width=1080"
IMAGE_SIGNING_KEY = "x9vGg4RNeNBqV2nBfhqLV6cN4n"
# Anonymous credentials (fallback)
@@ -128,7 +128,7 @@ def parse_german_datetime(text: str) -> Optional[datetime]:
# Signed image URL construction
# ---------------------------------------------------------------------------
def build_image_url(image_id: str) -> str:
def build_image_url(image_id: str, params: str = None) -> str:
"""
Build a signed Bedrock CDN image URL for the given image ID.
@@ -139,11 +139,14 @@ def build_image_url(image_id: str) -> str:
Args:
image_id: The raw image ID returned by the Bedrock API.
params: Optional query-string overriding ``RTLPlusDefaults.IMAGE_PARAMS``.
Use ``RTLPlusDefaults.IMAGE_PARAMS_LOGO`` for square channel logos.
Returns:
A fully-qualified, signed image URL.
"""
suffix = f"/{image_id}/raw?{RTLPlusDefaults.IMAGE_PARAMS}"
image_params = params if params is not None else RTLPlusDefaults.IMAGE_PARAMS
suffix = f"/{image_id}/raw?{image_params}"
signed_path = f"/v2/images{suffix}"
image_hash = hashlib.sha1(
(signed_path + RTLPlusDefaults.IMAGE_SIGNING_KEY).encode()