Prepare RTLPlus for new streaming prov

This commit is contained in:
Nirvana
2026-05-01 11:36:08 +02:00
parent 491fb0d419
commit 9bdaa19145
3 changed files with 30 additions and 60 deletions
@@ -142,7 +142,7 @@ class RTLPlusEventManager:
manifest_url = self._provider.extract_best_manifest_url(assets)
if manifest_url:
logger.debug(f"Found manifest for event {event_id}: {manifest_url}")
return self._provider.resolve_redirect(manifest_url)
return manifest_url
return None
@@ -342,30 +342,6 @@ class RTLPlusProvider(StreamingProvider):
return None
def resolve_redirect(self, url: str) -> str:
"""
Resolve HTTP redirects to get final manifest URL.
"""
if not url:
return url
try:
response = self.http_manager.head(
url,
headers={"User-Agent": self.rtl_config.user_agent},
follow_redirects=False,
timeout=10
)
if 300 <= response.status_code < 400:
location = response.headers.get("location")
if location:
logger.debug(f"Resolved redirect: {url} -> {location}")
return location
except Exception as e:
logger.debug(f"Redirect resolution failed: {e}")
return url
def invalidate_layout_cache(self, cache_key: str = None):
"""Invalidate layout cache for a specific key or all keys."""
if cache_key:
@@ -527,7 +503,7 @@ class RTLPlusProvider(StreamingProvider):
if manifest_url:
logger.info(f"Found manifest URL for {content_id}: {manifest_url[:100]}...")
return self.resolve_redirect(manifest_url)
return manifest_url
logger.warning(f"No suitable manifest URL found for {content_id}")
return None
+28 -34
View File
@@ -865,14 +865,31 @@ def setup_stream_routes(app, manager, service):
# /drm → returns raw DRM configs
# =========================================================================
@app.route("/api/providers/<provider>/vod/<path:path>/stream/index.mpd")
def get_vod_stream(provider, path):
# Extract vod_id as the first segment before any slashes
# Example: "clip_1417600/stream" -> "clip_1417600"
vod_id = path.split("/")[0]
try:
country = request.query.get("country")
return _resolve_stream(
CONTENT_TYPE_VOD, provider, vod_id, country=country
)
except HTTPResponse:
raise
except ValueError as e:
logger.error(f"stream error for VOD {provider}/{vod_id}: {e}")
response.status = 404
return {"error": str(e)}
except Exception as e:
logger.error(f"stream error for VOD {provider}/{vod_id}: {e}")
response.status = 500
return {"error": f"Internal server error: {str(e)}"}
@app.route("/api/providers/<provider>/vod/<path:path>/manifest")
def get_vod_stream_manifest(provider, path):
"""
Returns JSON with a manifest_url pointing to the VOD stream endpoint.
The last segment of <path> is the vod_id (edit_id / content_id).
Attaches x-kodi-drm-configs header.
"""
vod_id = path.rstrip("/").rsplit("/", 1)[-1]
vod_id = path.split("/")[0] # Fix here too
try:
country = request.query.get("country")
base_url = f"{request.urlparts.scheme}://{request.urlparts.netloc}"
@@ -900,46 +917,23 @@ def setup_stream_routes(app, manager, service):
response.status = 500
return {"error": f"Internal server error: {str(e)}"}
@app.route("/api/providers/<provider>/vod/<path:path>/stream/index.mpd")
def get_vod_stream(provider, path):
vod_id = path.rstrip("/").rsplit("/", 1)[-1]
try:
country = request.query.get("country")
return _resolve_stream(
CONTENT_TYPE_VOD, provider, vod_id, country=country
)
except HTTPResponse:
raise
except ValueError as e:
logger.error(f"stream error for VOD {provider}/{vod_id}: {e}")
response.status = 404
return {"error": str(e)}
except Exception as e:
logger.error(f"stream error for VOD {provider}/{vod_id}: {e}")
response.status = 500
return {"error": f"Internal server error: {str(e)}"}
@app.route(
"/api/providers/<provider>/vod/<path:path>/stream/decrypted/index.mpd"
)
@app.route("/api/providers/<provider>/vod/<path:path>/stream/decrypted/index.mpd")
def get_vod_stream_decrypted(provider, path):
vod_id = path.rstrip("/").rsplit("/", 1)[-1]
vod_id = path.split("/")[0] # Fix here too
return _resolve_decrypted_stream(
CONTENT_TYPE_VOD, provider, vod_id, highest_quality_only=False
)
@app.route(
"/api/providers/<provider>/vod/<path:path>/stream/decrypted/ffmpeg/index.mpd"
)
@app.route("/api/providers/<provider>/vod/<path:path>/stream/decrypted/ffmpeg/index.mpd")
def get_vod_stream_decrypted_ffmpeg(provider, path):
vod_id = path.rstrip("/").rsplit("/", 1)[-1]
vod_id = path.split("/")[0] # Fix here too
return _resolve_decrypted_stream(
CONTENT_TYPE_VOD, provider, vod_id, highest_quality_only=True
)
@app.route("/api/providers/<provider>/vod/<path:path>/drm")
def get_vod_drm(provider, path):
vod_id = path.rstrip("/").rsplit("/", 1)[-1]
vod_id = path.split("/")[0] # Fix here too
try:
country = request.query.get("country")
drm_configs = _get_drm_configs(