Prepare RTLPlus for new streaming prov

This commit is contained in:
Nirvana
2026-04-29 10:59:05 +02:00
parent 73915b67cb
commit 314c8c1079
3 changed files with 28 additions and 17 deletions
@@ -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:
@@ -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}
@@ -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