From 314c8c10794c4c428d3b7d8bbfd6791ec69ed7a9 Mon Sep 17 00:00:00 2001 From: Nirvana Date: Wed, 29 Apr 2026 10:59:05 +0200 Subject: [PATCH] Prepare RTLPlus for new streaming prov --- .../providers/rtlplus/constants.py | 8 +++-- .../providers/rtlplus/provider.py | 30 +++++++++++-------- .../providers/rtlplus/vod_manager.py | 7 +++-- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/lib/streaming_providers/providers/rtlplus/constants.py b/lib/streaming_providers/providers/rtlplus/constants.py index 4ba174e..fdb1cd9 100644 --- a/lib/streaming_providers/providers/rtlplus/constants.py +++ b/lib/streaming_providers/providers/rtlplus/constants.py @@ -628,10 +628,12 @@ class RTLPlusConfig: "folder": RTLPlusDefaults.LAYOUT_PATH_FOLDER, "program": RTLPlusDefaults.LAYOUT_PATH_PROGRAM, "block": RTLPlusDefaults.LAYOUT_PATH_BLOCK, + # 'alias' is not in path_map because it uses a different URL pattern } - path = path_map.get(layout_type) - if not path: - raise ValueError(f"Unknown layout type: {layout_type}") + if layout_type not in path_map: + raise ValueError(f"Unknown layout type: {layout_type}. Valid types: {list(path_map.keys())}") + + path = path_map[layout_type] return f"{self.bedrock_layout_base}{path.format(id=content_id)}" def get_layout_headers(self, oauth_token: str, bedrock_token: str, location: str = None) -> dict: diff --git a/lib/streaming_providers/providers/rtlplus/provider.py b/lib/streaming_providers/providers/rtlplus/provider.py index afc17ef..83e3f21 100644 --- a/lib/streaming_providers/providers/rtlplus/provider.py +++ b/lib/streaming_providers/providers/rtlplus/provider.py @@ -113,20 +113,21 @@ class RTLPlusProvider(StreamingProvider): # -------------------------------------------------------------------------- def fetch_layout( - self, - layout_type: str, - content_id: str, - block_page: int = None, - nb_pages: int = None, - location: str = None, - force_refresh: bool = False, + self, + layout_type: str, + content_id: str, + block_page: int = None, + nb_pages: int = None, + location: str = None, + force_refresh: bool = False, ) -> Optional[Dict]: """ Fetch any layout (live/video/folder/program/block) with caching. Args: - layout_type: 'live', 'video', 'folder', 'program', 'block' - content_id: The ID (seo for live, clip_id for video, folder_id for folder) + layout_type: 'live', 'video', 'folder', 'program', 'block', 'alias' (for root/home) + content_id: The ID (seo for live, clip_id for video, folder_id for folder, + or 'home'/'root' for alias layouts) block_page: Page number for blocks (default 1) nb_pages: Number of pages to request (default 2) location: x-location header value (auto-generated if not provided) @@ -166,11 +167,16 @@ class RTLPlusProvider(StreamingProvider): return None # Auto-generate location header if not provided - if location is None and layout_type in ("live", "video", "folder", "program"): + if location is None and layout_type in ("live", "video", "folder", "program", "alias"): location = f"{self.rtl_config.beta_website}{content_id}" - # Build request - url = self.rtl_config.get_layout_url(layout_type, content_id) + # Build request - handle alias layouts specially + if layout_type == "alias": + # For alias layouts, the URL pattern is: {base}/alias/{content_id}/layout + url = f"{self.rtl_config.bedrock_layout_base}/alias/{content_id}/layout" + else: + url = self.rtl_config.get_layout_url(layout_type, content_id) + headers = self.rtl_config.get_layout_headers(oauth_token, bedrock_token, location) params = {"blockPage": block_page, "nbPages": nb_pages} diff --git a/lib/streaming_providers/providers/rtlplus/vod_manager.py b/lib/streaming_providers/providers/rtlplus/vod_manager.py index 1170568..50f0c6c 100644 --- a/lib/streaming_providers/providers/rtlplus/vod_manager.py +++ b/lib/streaming_providers/providers/rtlplus/vod_manager.py @@ -150,15 +150,18 @@ class RTLPlusVodManager: """ entries: List[Union[VodCategory, VodItem]] = [] + # Use layout_type="alias" with content_id="home" layout = self._provider.fetch_layout( layout_type="alias", content_id="home", + location=f"{self.cfg.beta_website}", ) if not layout: logger.warning("Failed to fetch home layout for VOD root; returning empty") return {"entries": [], "next_cursor": None, "total": 0} + # Parse blocks as before... blocks = layout.get("blocks", []) for block in blocks: if block.get("type") != "bffPaginated": @@ -166,8 +169,8 @@ class RTLPlusVodManager: block_title = ( block.get("analytics", {}) - .get("tealium", {}) - .get("block_title", "") + .get("tealium", {}) + .get("block_title", "") ) # Continue-watching items