soulsync/api/video/dashboard.py
BoulderBadgeDad a5ff4a1dd8 video Tools: server-prefix the scan title (Plex/Jellyfin Library Scan)
Dashboard endpoint now returns the active media server; the Tools card title
becomes '<Server> Library Scan' (e.g. 'Plex Library Scan'), matching how music
prefixes 'Plex Database Updater'.
2026-06-14 07:47:40 -07:00

30 lines
979 B
Python

"""Video dashboard endpoint — live counts from video.db.
GET /api/video/dashboard -> {library:{...}, downloads:{...}, watchlist, wishlist}
With an empty database every value is a real 0.
"""
from __future__ import annotations
from flask import jsonify
from utils.logging_config import get_logger
logger = get_logger("video_api.dashboard")
def register_routes(bp):
@bp.route("/dashboard", methods=["GET"])
def video_dashboard():
from . import get_video_db
try:
stats = get_video_db().dashboard_stats()
try:
from config.settings import config_manager
stats["server"] = config_manager.get_active_media_server()
except Exception:
stats["server"] = None
return jsonify(stats)
except Exception:
logger.exception("Failed to build video dashboard stats")
return jsonify({"error": "Failed to load video dashboard stats"}), 500