Files
ViewIT/addon/resolveurl_backend.py
itdrui.de ee275bee47 Implement ViewIt Plugin System Documentation and Update Project Notes
- Added comprehensive documentation for the ViewIt Plugin System, detailing the plugin loading process, required methods, optional features, and community extension workflow.
- Updated project notes to reflect the current structure, build process, search logic, and known issues.
- Introduced new build scripts for installing the add-on and creating ZIP packages.
- Added test scripts for TMDB API integration, including argument parsing and logging functionality.
- Enhanced existing plugins with improved search logic and error handling.
2026-02-01 17:55:30 +01:00

44 lines
1.1 KiB
Python

"""Optionales ResolveURL-Backend für das Kodi-Addon.
Wenn `script.module.resolveurl` installiert ist, kann damit eine Hoster-URL
zu einer abspielbaren Media-URL (inkl. evtl. Header-Suffix) aufgelöst werden.
"""
from __future__ import annotations
from typing import Optional
def resolve(url: str) -> Optional[str]:
if not url:
return None
try:
import resolveurl # type: ignore
except Exception:
return None
try:
hosted = getattr(resolveurl, "HostedMediaFile", None)
if callable(hosted):
hmf = hosted(url)
valid = getattr(hmf, "valid_url", None)
if callable(valid) and not valid():
return None
resolver = getattr(hmf, "resolve", None)
if callable(resolver):
result = resolver()
return str(result) if result else None
except Exception:
pass
try:
resolve_fn = getattr(resolveurl, "resolve", None)
if callable(resolve_fn):
result = resolve_fn(url)
return str(result) if result else None
except Exception:
return None
return None