- GET /api/video/library -> {movies, shows} from video.db (VideoDatabase.
list_movies/list_shows; shows carry episode_count + owned_count).
- Library page (video-library subpage, isolated video-library.js): tabbed
Movies/Shows grid of poster cards, count, empty-state. A 'Scan Library'
button POSTs /api/video/scan/request then polls /api/video/scan/status,
showing live phase/counts, and refreshes the grid when done.
- Reuses the music dashboard-header chrome (icon title, sweep hidden) + the
watchlist-button styling for the scan button; video-card grid styles added.
- All data-attr wired (no inline onclick); module is an isolated IIFE that
listens for soulsync:video-page-shown. 105 tests green.
Now: video.db -> scanner -> /api/video -> live dashboard + Library page, all
isolated from music. Scanner adapters await live Plex/Jellyfin validation.
25 lines
741 B
Python
25 lines
741 B
Python
"""Video library listing endpoint.
|
|
|
|
GET /api/video/library -> {"movies": [...], "shows": [...]}
|
|
Reads what the last scan mirrored from the media server into video.db.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from flask import jsonify
|
|
|
|
from utils.logging_config import get_logger
|
|
|
|
logger = get_logger("video_api.library")
|
|
|
|
|
|
def register_routes(bp):
|
|
@bp.route("/library", methods=["GET"])
|
|
def video_library():
|
|
from . import get_video_db
|
|
try:
|
|
db = get_video_db()
|
|
return jsonify({"movies": db.list_movies(), "shows": db.list_shows()})
|
|
except Exception:
|
|
logger.exception("Failed to list video library")
|
|
return jsonify({"error": "Failed to load video library"}), 500
|