Add Apprise notifications to quality-scan (self-hosted apprise server); dashboard ready

This commit is contained in:
2026-08-08 09:05:25 +10:00
parent 11e79b7066
commit b7d7ef38b4
3 changed files with 80 additions and 1 deletions

42
apprise_helper.py Normal file
View File

@@ -0,0 +1,42 @@
"""photo-pipeline: Apprise notification helper.
Posts to the self-hosted Apprise API server (fans out to all configured targets).
Usage: notify("Batch 3 done: 212 photos, 79 near-dups, 3 candidates")
The Apprise server holds the target config; we just POST title/body.
"""
import os
import subprocess
APPRISE_URL = os.environ.get("APPRISE_URL", "https://apprise.lab.audasmedia.com.au/notify")
def notify(title: str, body: str, tag: str = None) -> bool:
"""Send a notification via the Apprise API server. Returns success."""
import json
payload = {"title": title, "body": body}
if tag:
payload["tag"] = tag
r = subprocess.run(
["curl", "-s", "-o", "/dev/null", "-w", "%{http_code}",
"-X", "POST", APPRISE_URL,
"-H", "Content-Type: application/json",
"-d", json.dumps(payload)],
capture_output=True, text=True, timeout=30,
)
ok = r.stdout.strip() in ("204", "200")
print(f"[apprise] {title}: HTTP {r.stdout.strip()}")
return ok
if __name__ == "__main__":
# CLI test: python apprise.py "title" "body"
import sys
t = sys.argv[1] if len(sys.argv) > 1 else "photo-pipeline test"
b = sys.argv[2] if len(sys.argv) > 2 else "Notification test from photo-pipeline"
ok = notify(t, b)
print("sent" if ok else "FAILED")