diff --git a/addon/plugins/filmpalast_plugin.py b/addon/plugins/filmpalast_plugin.py index 421023f..be35dde 100644 --- a/addon/plugins/filmpalast_plugin.py +++ b/addon/plugins/filmpalast_plugin.py @@ -643,26 +643,39 @@ class FilmpalastPlugin(BasisPlugin): def resolve_stream_link(self, link: str) -> Optional[str]: if not link: return None - resolved = link + try: + from resolveurl_backend import resolve as resolve_with_resolveurl + except Exception: + resolve_with_resolveurl = None + + # 1) Immer zuerst den ursprünglichen Hoster-Link an ResolveURL geben. + if callable(resolve_with_resolveurl): + resolved_by_resolveurl = resolve_with_resolveurl(link) + if resolved_by_resolveurl: + _log_url_event("ResolveURL", kind="HOSTER_RESOLVER") + _log_url_event(resolved_by_resolveurl, kind="MEDIA") + return resolved_by_resolveurl + + redirected = link if self._requests_available: try: session = get_requests_session("filmpalast", headers=HEADERS) response = session.get(link, headers=HEADERS, timeout=DEFAULT_TIMEOUT, allow_redirects=True) response.raise_for_status() - resolved = (response.url or link).strip() or link + redirected = (response.url or link).strip() or link except Exception: - resolved = link - try: - from resolveurl_backend import resolve as resolve_with_resolveurl - except Exception: - resolve_with_resolveurl = None - if callable(resolve_with_resolveurl): - resolved_by_resolveurl = resolve_with_resolveurl(resolved) + redirected = link + + # 2) Danach optional die Redirect-URL nochmals auflösen. + if callable(resolve_with_resolveurl) and redirected and redirected != link: + resolved_by_resolveurl = resolve_with_resolveurl(redirected) if resolved_by_resolveurl: _log_url_event("ResolveURL", kind="HOSTER_RESOLVER") _log_url_event(resolved_by_resolveurl, kind="MEDIA") return resolved_by_resolveurl - if resolved: - _log_url_event(resolved, kind="FINAL") - return resolved + + # 3) Fallback bleibt wie bisher: direkte URL zurückgeben. + if redirected: + _log_url_event(redirected, kind="FINAL") + return redirected return None