dev: revert resolveurl dependency path injection
This commit is contained in:
@@ -7,36 +7,10 @@ zu einer abspielbaren Media-URL (inkl. evtl. Header-Suffix) aufgelöst werden.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
import sys
|
|
||||||
|
|
||||||
_LAST_RESOLVE_ERROR = ""
|
_LAST_RESOLVE_ERROR = ""
|
||||||
|
|
||||||
|
|
||||||
def _append_kodi_dependency_paths() -> None:
|
|
||||||
"""Ensure optional Kodi module dependencies are importable."""
|
|
||||||
try:
|
|
||||||
import xbmcaddon # type: ignore
|
|
||||||
import xbmcvfs # type: ignore
|
|
||||||
except Exception:
|
|
||||||
return
|
|
||||||
for addon_id in ("script.module.resolveurl", "script.module.kodi-six", "script.module.six"):
|
|
||||||
try:
|
|
||||||
addon = xbmcaddon.Addon(addon_id)
|
|
||||||
addon_path = addon.getAddonInfo("path") or ""
|
|
||||||
except Exception:
|
|
||||||
addon_path = ""
|
|
||||||
if not addon_path:
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
addon_path = xbmcvfs.translatePath(addon_path)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
lib_path = f"{addon_path}/lib"
|
|
||||||
for candidate in (lib_path, addon_path):
|
|
||||||
if candidate and candidate not in sys.path:
|
|
||||||
sys.path.append(candidate)
|
|
||||||
|
|
||||||
|
|
||||||
def get_last_error() -> str:
|
def get_last_error() -> str:
|
||||||
return str(_LAST_RESOLVE_ERROR or "")
|
return str(_LAST_RESOLVE_ERROR or "")
|
||||||
|
|
||||||
@@ -46,21 +20,11 @@ def resolve(url: str) -> Optional[str]:
|
|||||||
_LAST_RESOLVE_ERROR = ""
|
_LAST_RESOLVE_ERROR = ""
|
||||||
if not url:
|
if not url:
|
||||||
return None
|
return None
|
||||||
resolveurl = None
|
|
||||||
try:
|
try:
|
||||||
import resolveurl as _resolveurl # type: ignore
|
import resolveurl # type: ignore
|
||||||
resolveurl = _resolveurl
|
|
||||||
except Exception:
|
except Exception:
|
||||||
# Ohne harte addon.xml-Abhaengigkeit liegen optionale libs ggf. nicht im Python-Pfad.
|
_LAST_RESOLVE_ERROR = "resolveurl missing"
|
||||||
_append_kodi_dependency_paths()
|
return None
|
||||||
try:
|
|
||||||
import resolveurl as _resolveurl # type: ignore
|
|
||||||
resolveurl = _resolveurl
|
|
||||||
except Exception:
|
|
||||||
resolveurl = None
|
|
||||||
if resolveurl is None:
|
|
||||||
_LAST_RESOLVE_ERROR = "resolveurl missing"
|
|
||||||
return None
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
hosted = getattr(resolveurl, "HostedMediaFile", None)
|
hosted = getattr(resolveurl, "HostedMediaFile", None)
|
||||||
|
|||||||
Reference in New Issue
Block a user