From e5c941c90556694048fb09d049cc4ef518c3a36c Mon Sep 17 00:00:00 2001 From: Nirvana Date: Fri, 1 May 2026 19:46:49 +0200 Subject: [PATCH] Prepare RTLPlus for new streaming prov --- .../providers/rtlplus/provider.py | 28 +++++------ .../providers/rtlplus/vod_manager.py | 46 +++++++++---------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/lib/streaming_providers/providers/rtlplus/provider.py b/lib/streaming_providers/providers/rtlplus/provider.py index 9ca0f05..1864501 100644 --- a/lib/streaming_providers/providers/rtlplus/provider.py +++ b/lib/streaming_providers/providers/rtlplus/provider.py @@ -130,28 +130,28 @@ class RTLPlusProvider(StreamingProvider): original_content_id = content_id clean_content_id = content_id - if layout_type == "program" and content_id.startswith("program:"): - # Remove "program:" prefix to get just the numeric ID - clean_content_id = content_id[8:] # "program:68137" -> "68137" + if layout_type == "program" and content_id.startswith("program_"): + # Remove "program_" prefix to get just the numeric ID + clean_content_id = content_id[8:] # "program_68137" -> "68137" logger.debug(f"Cleaned program content_id: '{original_content_id}' -> '{clean_content_id}'") - elif layout_type == "folder" and content_id.startswith("folder:"): - # Remove "folder:" prefix + elif layout_type == "folder" and content_id.startswith("folder_"): + # Remove "folder_" prefix clean_content_id = content_id[7:] logger.debug(f"Cleaned folder content_id: '{original_content_id}' -> '{clean_content_id}'") - elif layout_type == "season" and content_id.startswith("season:"): - # Remove "season:" prefix + elif layout_type == "season" and content_id.startswith("season_"): + # Remove "season_" prefix clean_content_id = content_id[7:] logger.debug(f"Cleaned season content_id: '{original_content_id}' -> '{clean_content_id}'") - # For video layouts, if content_id has "program:" prefix, that's an error - if layout_type == "video" and ":" in content_id: - logger.warning(f"Possible error: fetching video layout with content_id containing colon: '{content_id}'") - # Try to extract just the clip ID if it's in format like "program:68137/clip_xxx" - if "/" in content_id: - clean_content_id = content_id.split("/")[-1] - logger.debug(f"Extracted clip_id: '{clean_content_id}'") + # For video layouts, a prefix is always an error + if layout_type == "video" and "_" in content_id and not content_id.startswith("clip"): + logger.error( + f"fetch_layout: 'video' layout requested with non-clip content_id '{content_id}'. " + f"Pass the clip_id (e.g. 'clip_1417600') instead." + ) + return None cache_key = f"{layout_type}:{clean_content_id}:{block_page}:{nb_pages}" now = time.time() diff --git a/lib/streaming_providers/providers/rtlplus/vod_manager.py b/lib/streaming_providers/providers/rtlplus/vod_manager.py index 268c57c..2238f1e 100644 --- a/lib/streaming_providers/providers/rtlplus/vod_manager.py +++ b/lib/streaming_providers/providers/rtlplus/vod_manager.py @@ -34,9 +34,9 @@ class RTLPlusVodManager: Navigation hierarchy: root - └── folder: (Bedrock folder, e.g. folder:3 = Serien) - └── program: (program layout → seasons or direct video) - └── season: (block layout → episodes) + └── folder_ (Bedrock folder, e.g. folder_3 = Serien) + └── program_ (program layout → seasons or direct video) + └── season_ (block layout → episodes) └── clip_id (video layout, playable) Manifest and DRM for playable items are always resolved through @@ -78,10 +78,10 @@ class RTLPlusVodManager: content_id conventions ---------------------- - "" → root (fetched from home layout) - "folder:" → Bedrock folder (e.g. "folder:3") - "p_" → program/series (e.g. "p_68137") - "season:" → season block (e.g. "season:abc-123") + "" → root (fetched from home layout) + "folder_" → Bedrock folder (e.g. "folder_3") + "program_" → program/series (e.g. "program_68137") + "season_" → season block (e.g. "season_abc-123") Returns ------- @@ -94,22 +94,22 @@ class RTLPlusVodManager: if not content_id: return self._get_root_category() - if content_id.startswith("folder:"): + if content_id.startswith("folder_"): folder_id = content_id[7:] # "3" return self._get_folder_contents(folder_id, cursor, page_size) - if content_id.startswith("program:"): + if content_id.startswith("program_"): program_id = content_id[8:] # "68137" (numeric) slug = kwargs.get("slug") return self._get_program_contents(program_id, cursor, page_size, slug=slug) - if content_id.startswith("season:"): + if content_id.startswith("season_"): season_id = content_id[7:] return self._get_season_episodes(season_id, cursor, page_size) # Bare numeric ID → treat as program (backward compatibility) if content_id.isdigit(): - return self._get_program_contents(f"p_{content_id}", cursor, page_size) + return self._get_program_contents(content_id, cursor, page_size) logger.warning(f"Unrecognised VOD content_id format: {content_id!r}") return {"entries": [], "next_cursor": None, "total": 0} @@ -200,7 +200,7 @@ class RTLPlusVodManager: cat = self._extract_vod_category_from_block_item(item) if cat: # Separate folders from programs - if cat.content_id.startswith("folder:"): + if cat.content_id.startswith("folder_"): folder_categories.append(cat) else: program_categories.append(cat) @@ -529,7 +529,7 @@ class RTLPlusVodManager: if block_id: seasons.append(VodCategory( name=season_title, - content_id=f"season:{block_id}", + content_id=f"season_{block_id}", provider=self._provider.provider_name, description=None, child_count=( @@ -550,7 +550,7 @@ class RTLPlusVodManager: .get("title", {}) .get("short", "Alle Staffeln") ), - content_id=f"season:{block_id}", + content_id=f"season_{block_id}", provider=self._provider.provider_name, child_count=( block.get("content", {}) @@ -796,9 +796,9 @@ class RTLPlusVodManager: # Store with type prefix for clarity if layout_type == "folder": - content_id = f"folder:{content_id}" # folder:3 + content_id = f"folder_{content_id}" # folder_3 elif layout_type == "program": - content_id = f"program:{content_id}" # program:68137 + content_id = f"program_{content_id}" # program_68137 # Capture the SEO slug from the API (e.g. "american-pie") seo_slug = value_layout.get("seo") or "" @@ -827,7 +827,7 @@ class RTLPlusVodManager: return VodCategory( name=name, - content_id=content_id, # "folder:3" or "p_68137" + content_id=content_id, # "folder_3" or "program_68137" provider=self._provider.provider_name, logo_url=self._extract_thumbnail(item_content), description=item_content.get("description") or item_content.get("highlight"), @@ -944,8 +944,8 @@ class RTLPlusVodManager: self._provider.invalidate_layout_cache() return - if content_id.startswith("program:"): - program_id = content_id[len("program:"):] + if content_id.startswith("program_"): + program_id = content_id[len("program_"):] # Program layouts are cached under "program:::" cache_key = ( f"program:{program_id}" @@ -954,8 +954,8 @@ class RTLPlusVodManager: ) self._provider.invalidate_layout_cache(cache_key) - elif content_id.startswith("season:"): - season_id = content_id[len("season:"):].split("?")[0] + elif content_id.startswith("season_"): + season_id = content_id[len("season_"):].split("?")[0] cache_key = ( f"block:{season_id}" f":{RTLPlusDefaults.DEFAULT_BLOCK_PAGE}" @@ -963,8 +963,8 @@ class RTLPlusVodManager: ) self._provider.invalidate_layout_cache(cache_key) - elif content_id.startswith("folder:"): - folder_id = content_id[len("folder:"):] + elif content_id.startswith("folder_"): + folder_id = content_id[len("folder_"):] cache_key = ( f"folder:{folder_id}" f":{RTLPlusDefaults.DEFAULT_BLOCK_PAGE}"