Files
ViewIT/scripts/test_tmdb.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

51 lines
1.6 KiB
Python
Executable File

#!/usr/bin/env python3
from __future__ import annotations
import argparse
import os
import sys
try:
from source.kodi_addon.tmdb import lookup_tv_show
except Exception:
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "source", "kodi_addon"))
from tmdb import lookup_tv_show # type: ignore[import-not-found]
def main() -> int:
parser = argparse.ArgumentParser(description="Manueller Test fuer tmdb.py (Plot + Poster).")
parser.add_argument("title", nargs="?", default="Dark", help="Serientitel (Default: Dark)")
parser.add_argument("--key", default=os.environ.get("TMDB_API_KEY", ""), help="TMDB API Key (oder env TMDB_API_KEY)")
parser.add_argument("--lang", default=os.environ.get("TMDB_LANGUAGE", "de-DE"), help="Sprache, z.B. de-DE")
parser.add_argument("--log-responses", action="store_true", help="Antwort-JSON (gekürzt) loggen")
args = parser.parse_args()
if not args.key:
print(
"Fehlt: --key oder env TMDB_API_KEY\n"
"Beispiel: TMDB_API_KEY=DEIN_KEY ./scripts/test_tmdb.py\n"
"Oder: ./scripts/test_tmdb.py \"Dark\" --key DEIN_KEY",
file=sys.stderr,
)
return 2
meta = lookup_tv_show(
title=args.title,
api_key=args.key,
language=args.lang,
log=print,
log_responses=args.log_responses,
)
if not meta:
print("Kein Treffer / keine Meta-Daten.")
return 1
print("\nRESULT")
print("plot:", (meta.plot or "")[:500])
print("poster:", meta.poster)
return 0
if __name__ == "__main__":
raise SystemExit(main())