From 16e0c77162f6f4df3f91ba121a41cb3b81a3e275 Mon Sep 17 00:00:00 2001 From: "itdrui.de" Date: Tue, 24 Feb 2026 20:41:08 +0100 Subject: [PATCH] dev: import resolveurl from addon path when dependency is soft --- addon/resolveurl_backend.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/addon/resolveurl_backend.py b/addon/resolveurl_backend.py index 3433316..20326f5 100644 --- a/addon/resolveurl_backend.py +++ b/addon/resolveurl_backend.py @@ -7,6 +7,7 @@ zu einer abspielbaren Media-URL (inkl. evtl. Header-Suffix) aufgelöst werden. from __future__ import annotations from typing import Optional +import sys _LAST_RESOLVE_ERROR = "" @@ -20,11 +21,31 @@ def resolve(url: str) -> Optional[str]: _LAST_RESOLVE_ERROR = "" if not url: return None + resolveurl = None try: - import resolveurl # type: ignore + import resolveurl as _resolveurl # type: ignore + resolveurl = _resolveurl except Exception: - _LAST_RESOLVE_ERROR = "resolveurl missing" - return None + # Ohne harte addon.xml-Abhaengigkeit liegt resolveurl ggf. nicht im Python-Pfad. + try: + import xbmcaddon # type: ignore + import xbmcvfs # type: ignore + + addon = xbmcaddon.Addon("script.module.resolveurl") + addon_path = addon.getAddonInfo("path") or "" + if addon_path: + lib_path = xbmcvfs.translatePath(f"{addon_path}/lib") + if lib_path and lib_path not in sys.path: + sys.path.append(lib_path) + if addon_path and addon_path not in sys.path: + sys.path.append(addon_path) + import resolveurl as _resolveurl # type: ignore + resolveurl = _resolveurl + except Exception: + resolveurl = None + if resolveurl is None: + _LAST_RESOLVE_ERROR = "resolveurl missing" + return None try: hosted = getattr(resolveurl, "HostedMediaFile", None)