Nightly: reproducible zips and plugin manifest
This commit is contained in:
@@ -14,6 +14,7 @@ ViewIT ist ein Kodi‑Addon zum Durchsuchen und Abspielen von Inhalten der unter
|
||||
- Addon‑Ordner bauen: `./scripts/build_install_addon.sh` → `dist/<addon_id>/`
|
||||
- Kodi‑ZIP bauen: `./scripts/build_kodi_zip.sh` → `dist/<addon_id>-<version>.zip`
|
||||
- Addon‑Version in `addon/addon.xml`
|
||||
- Reproduzierbare ZIPs: optional `SOURCE_DATE_EPOCH` setzen
|
||||
|
||||
## Lokales Kodi-Repository
|
||||
- Repository bauen (inkl. ZIPs + `addons.xml` + `addons.xml.md5`): `./scripts/build_local_kodi_repo.sh`
|
||||
|
||||
Binary file not shown.
@@ -1079,3 +1079,7 @@ class EinschaltenPlugin(BasisPlugin):
|
||||
return []
|
||||
# Backwards compatible: first page only. UI uses paging via `new_titles_page`.
|
||||
return self.new_titles_page(1)
|
||||
|
||||
|
||||
# Alias für die automatische Plugin-Erkennung.
|
||||
Plugin = EinschaltenPlugin
|
||||
|
||||
@@ -922,3 +922,7 @@ class FilmpalastPlugin(BasisPlugin):
|
||||
_log_url_event(redirected, kind="FINAL")
|
||||
return redirected
|
||||
return None
|
||||
|
||||
|
||||
# Alias für die automatische Plugin-Erkennung.
|
||||
Plugin = FilmpalastPlugin
|
||||
|
||||
@@ -101,6 +101,7 @@ Plugins sollten die Helper aus `addon/plugin_helpers.py` nutzen:
|
||||
## Build & Test
|
||||
- ZIP bauen: `./scripts/build_kodi_zip.sh`
|
||||
- Addon‑Ordner: `./scripts/build_install_addon.sh`
|
||||
- Plugin‑Manifest aktualisieren: `python3 scripts/generate_plugin_manifest.py`
|
||||
|
||||
## Beispiel‑Checkliste
|
||||
- [ ] `name` korrekt gesetzt
|
||||
|
||||
104
docs/PLUGIN_MANIFEST.json
Normal file
104
docs/PLUGIN_MANIFEST.json
Normal file
@@ -0,0 +1,104 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"plugins": [
|
||||
{
|
||||
"file": "addon/plugins/aniworld_plugin.py",
|
||||
"module": "aniworld_plugin",
|
||||
"name": "Aniworld",
|
||||
"class": "AniworldPlugin",
|
||||
"version": "1.0.0",
|
||||
"capabilities": [
|
||||
"genres",
|
||||
"latest_episodes",
|
||||
"popular_series"
|
||||
],
|
||||
"prefer_source_metadata": false,
|
||||
"base_url_setting": "aniworld_base_url",
|
||||
"available": true,
|
||||
"unavailable_reason": null,
|
||||
"error": null
|
||||
},
|
||||
{
|
||||
"file": "addon/plugins/dokustreams_plugin.py",
|
||||
"module": "dokustreams_plugin",
|
||||
"name": "Doku-Streams",
|
||||
"class": "DokuStreamsPlugin",
|
||||
"version": "1.0.0",
|
||||
"capabilities": [
|
||||
"genres",
|
||||
"popular_series"
|
||||
],
|
||||
"prefer_source_metadata": true,
|
||||
"base_url_setting": "doku_streams_base_url",
|
||||
"available": true,
|
||||
"unavailable_reason": null,
|
||||
"error": null
|
||||
},
|
||||
{
|
||||
"file": "addon/plugins/einschalten_plugin.py",
|
||||
"module": "einschalten_plugin",
|
||||
"name": "Einschalten",
|
||||
"class": "EinschaltenPlugin",
|
||||
"version": "1.0.0",
|
||||
"capabilities": [
|
||||
"genres",
|
||||
"new_titles"
|
||||
],
|
||||
"prefer_source_metadata": false,
|
||||
"base_url_setting": "einschalten_base_url",
|
||||
"available": true,
|
||||
"unavailable_reason": null,
|
||||
"error": null
|
||||
},
|
||||
{
|
||||
"file": "addon/plugins/filmpalast_plugin.py",
|
||||
"module": "filmpalast_plugin",
|
||||
"name": "Filmpalast",
|
||||
"class": "FilmpalastPlugin",
|
||||
"version": "1.0.0",
|
||||
"capabilities": [
|
||||
"alpha",
|
||||
"genres",
|
||||
"series_catalog"
|
||||
],
|
||||
"prefer_source_metadata": false,
|
||||
"base_url_setting": "filmpalast_base_url",
|
||||
"available": true,
|
||||
"unavailable_reason": null,
|
||||
"error": null
|
||||
},
|
||||
{
|
||||
"file": "addon/plugins/serienstream_plugin.py",
|
||||
"module": "serienstream_plugin",
|
||||
"name": "Serienstream",
|
||||
"class": "SerienstreamPlugin",
|
||||
"version": "1.0.0",
|
||||
"capabilities": [
|
||||
"genres",
|
||||
"latest_episodes",
|
||||
"popular_series"
|
||||
],
|
||||
"prefer_source_metadata": false,
|
||||
"base_url_setting": "serienstream_base_url",
|
||||
"available": true,
|
||||
"unavailable_reason": null,
|
||||
"error": null
|
||||
},
|
||||
{
|
||||
"file": "addon/plugins/topstreamfilm_plugin.py",
|
||||
"module": "topstreamfilm_plugin",
|
||||
"name": "Topstreamfilm",
|
||||
"class": "TopstreamfilmPlugin",
|
||||
"version": "1.0.0",
|
||||
"capabilities": [
|
||||
"genres",
|
||||
"popular_series"
|
||||
],
|
||||
"prefer_source_metadata": false,
|
||||
"base_url_setting": "topstream_base_url",
|
||||
"available": true,
|
||||
"unavailable_reason": null,
|
||||
"error": null
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -9,6 +9,7 @@ ViewIt lädt Provider-Integrationen dynamisch aus `addon/plugins/*.py`. Jede Dat
|
||||
Weitere Details:
|
||||
- `docs/DEFAULT_ROUTER.md` (Hauptlogik in `addon/default.py`)
|
||||
- `docs/PLUGIN_DEVELOPMENT.md` (Entwicklerdoku für Plugins)
|
||||
- `docs/PLUGIN_MANIFEST.json` (zentraler Überblick über Plugins, Versionen, Capabilities)
|
||||
|
||||
### Aktuelle Plugins
|
||||
|
||||
@@ -33,6 +34,10 @@ Der Loader in `addon/default.py`:
|
||||
|
||||
Damit bleiben fehlerhafte Plugins isoliert und blockieren nicht das gesamte Add-on.
|
||||
|
||||
### Plugin-Manifest (Audit & Repro)
|
||||
`docs/PLUGIN_MANIFEST.json` listet alle Plugins mit Version, Capabilities und Basis-Settings.
|
||||
Erzeugung: `python3 scripts/generate_plugin_manifest.py`
|
||||
|
||||
### BasisPlugin – verpflichtende Methoden
|
||||
|
||||
Definiert in `addon/plugin_interface.py`:
|
||||
|
||||
@@ -37,6 +37,6 @@ ZIP_PATH="${INSTALL_DIR}/${ZIP_NAME}"
|
||||
ADDON_DIR="$("${ROOT_DIR}/scripts/build_install_addon.sh" >/dev/null; echo "${INSTALL_DIR}/${ADDON_ID}")"
|
||||
|
||||
rm -f "${ZIP_PATH}"
|
||||
(cd "${INSTALL_DIR}" && zip -r "${ZIP_NAME}" "$(basename "${ADDON_DIR}")" >/dev/null)
|
||||
python3 "${ROOT_DIR}/scripts/zip_deterministic.py" "${ZIP_PATH}" "${ADDON_DIR}" >/dev/null
|
||||
|
||||
echo "${ZIP_PATH}"
|
||||
|
||||
@@ -73,7 +73,7 @@ PY
|
||||
REPO_ZIP_NAME="${REPO_ADDON_ID}-${REPO_ADDON_VERSION}.zip"
|
||||
REPO_ZIP_PATH="${REPO_DIR}/${REPO_ZIP_NAME}"
|
||||
rm -f "${REPO_ZIP_PATH}"
|
||||
(cd "${TMP_DIR}" && zip -r "${REPO_ZIP_PATH}" "${REPO_ADDON_ID}" >/dev/null)
|
||||
python3 "${ROOT_DIR}/scripts/zip_deterministic.py" "${REPO_ZIP_PATH}" "${TMP_REPO_ADDON_DIR}" >/dev/null
|
||||
|
||||
python3 - "${PLUGIN_ADDON_XML}" "${TMP_REPO_ADDON_DIR}/addon.xml" "${REPO_DIR}/addons.xml" <<'PY'
|
||||
import sys
|
||||
|
||||
106
scripts/generate_plugin_manifest.py
Executable file
106
scripts/generate_plugin_manifest.py
Executable file
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate a JSON manifest for addon plugins."""
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import inspect
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT_DIR = Path(__file__).resolve().parents[1]
|
||||
PLUGIN_DIR = ROOT_DIR / "addon" / "plugins"
|
||||
OUTPUT_PATH = ROOT_DIR / "docs" / "PLUGIN_MANIFEST.json"
|
||||
|
||||
sys.path.insert(0, str(ROOT_DIR / "addon"))
|
||||
|
||||
try:
|
||||
from plugin_interface import BasisPlugin # type: ignore
|
||||
except Exception as exc: # pragma: no cover
|
||||
raise SystemExit(f"Failed to import BasisPlugin: {exc}")
|
||||
|
||||
|
||||
def _import_module(path: Path):
|
||||
spec = importlib.util.spec_from_file_location(path.stem, path)
|
||||
if spec is None or spec.loader is None:
|
||||
raise ImportError(f"Missing spec for {path}")
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
sys.modules[spec.name] = module
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
def _collect_plugins():
|
||||
plugins = []
|
||||
for file_path in sorted(PLUGIN_DIR.glob("*.py")):
|
||||
if file_path.name.startswith("_"):
|
||||
continue
|
||||
entry = {
|
||||
"file": str(file_path.relative_to(ROOT_DIR)),
|
||||
"module": file_path.stem,
|
||||
"name": None,
|
||||
"class": None,
|
||||
"version": None,
|
||||
"capabilities": [],
|
||||
"prefer_source_metadata": False,
|
||||
"base_url_setting": None,
|
||||
"available": None,
|
||||
"unavailable_reason": None,
|
||||
"error": None,
|
||||
}
|
||||
try:
|
||||
module = _import_module(file_path)
|
||||
preferred = getattr(module, "Plugin", None)
|
||||
if inspect.isclass(preferred) and issubclass(preferred, BasisPlugin) and preferred is not BasisPlugin:
|
||||
classes = [preferred]
|
||||
else:
|
||||
classes = [
|
||||
obj
|
||||
for obj in module.__dict__.values()
|
||||
if inspect.isclass(obj) and issubclass(obj, BasisPlugin) and obj is not BasisPlugin
|
||||
]
|
||||
classes.sort(key=lambda cls: cls.__name__.casefold())
|
||||
|
||||
if not classes:
|
||||
entry["error"] = "No plugin classes found"
|
||||
plugins.append(entry)
|
||||
continue
|
||||
|
||||
cls = classes[0]
|
||||
instance = cls()
|
||||
entry["class"] = cls.__name__
|
||||
entry["name"] = str(getattr(instance, "name", "") or "") or None
|
||||
entry["version"] = str(getattr(instance, "version", "0.0.0") or "0.0.0")
|
||||
entry["prefer_source_metadata"] = bool(getattr(instance, "prefer_source_metadata", False))
|
||||
entry["available"] = bool(getattr(instance, "is_available", True))
|
||||
entry["unavailable_reason"] = getattr(instance, "unavailable_reason", None)
|
||||
try:
|
||||
caps = instance.capabilities() # type: ignore[call-arg]
|
||||
entry["capabilities"] = sorted([str(c) for c in caps]) if caps else []
|
||||
except Exception:
|
||||
entry["capabilities"] = []
|
||||
|
||||
entry["base_url_setting"] = getattr(module, "SETTING_BASE_URL", None)
|
||||
except Exception as exc: # pragma: no cover
|
||||
entry["error"] = str(exc)
|
||||
plugins.append(entry)
|
||||
|
||||
plugins.sort(key=lambda item: (item.get("name") or item["module"]).casefold())
|
||||
return plugins
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if not PLUGIN_DIR.exists():
|
||||
raise SystemExit("Plugin directory missing")
|
||||
manifest = {
|
||||
"schema_version": 1,
|
||||
"plugins": _collect_plugins(),
|
||||
}
|
||||
OUTPUT_PATH.parent.mkdir(parents=True, exist_ok=True)
|
||||
OUTPUT_PATH.write_text(json.dumps(manifest, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
||||
print(str(OUTPUT_PATH))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
73
scripts/zip_deterministic.py
Executable file
73
scripts/zip_deterministic.py
Executable file
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Create deterministic zip archives.
|
||||
|
||||
Usage:
|
||||
zip_deterministic.py <zip_path> <root_dir>
|
||||
|
||||
The archive will include the root directory itself and all files under it.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _timestamp() -> tuple[int, int, int, int, int, int]:
|
||||
epoch = os.environ.get("SOURCE_DATE_EPOCH")
|
||||
if epoch:
|
||||
try:
|
||||
value = int(epoch)
|
||||
return time.gmtime(value)[:6]
|
||||
except Exception:
|
||||
pass
|
||||
return (2000, 1, 1, 0, 0, 0)
|
||||
|
||||
|
||||
def _iter_files(root: Path):
|
||||
for dirpath, dirnames, filenames in os.walk(root):
|
||||
dirnames[:] = sorted([d for d in dirnames if d != "__pycache__"])
|
||||
for filename in sorted(filenames):
|
||||
if filename.endswith(".pyc"):
|
||||
continue
|
||||
yield Path(dirpath) / filename
|
||||
|
||||
|
||||
def _add_file(zf: zipfile.ZipFile, file_path: Path, arcname: str) -> None:
|
||||
info = zipfile.ZipInfo(arcname, date_time=_timestamp())
|
||||
info.compress_type = zipfile.ZIP_DEFLATED
|
||||
info.external_attr = (0o644 & 0xFFFF) << 16
|
||||
with file_path.open("rb") as handle:
|
||||
data = handle.read()
|
||||
zf.writestr(info, data, compress_type=zipfile.ZIP_DEFLATED)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage: zip_deterministic.py <zip_path> <root_dir>")
|
||||
return 2
|
||||
|
||||
zip_path = Path(sys.argv[1]).resolve()
|
||||
root = Path(sys.argv[2]).resolve()
|
||||
if not root.exists() or not root.is_dir():
|
||||
print(f"Missing root dir: {root}")
|
||||
return 2
|
||||
|
||||
base = root.parent
|
||||
zip_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
if zip_path.exists():
|
||||
zip_path.unlink()
|
||||
|
||||
with zipfile.ZipFile(zip_path, "w") as zf:
|
||||
for file_path in sorted(_iter_files(root)):
|
||||
arcname = str(file_path.relative_to(base)).replace(os.sep, "/")
|
||||
_add_file(zf, file_path, arcname)
|
||||
|
||||
print(str(zip_path))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user