From b3999f6c655f90b155e561e3c37d3e4f6a249727 Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 12:33:53 +0100 Subject: [PATCH] Add explicit authoritative library selection endpoint --- scene_search/api.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scene_search/api.py b/scene_search/api.py index 4e75a0a..63671e8 100644 --- a/scene_search/api.py +++ b/scene_search/api.py @@ -137,6 +137,26 @@ def jellyfin_libraries() -> dict: raise HTTPException(status_code=503, detail=str(exc)) from exc +@app.post( + "/api/jellyfin/libraries/selection", + dependencies=[Depends(require_api_key)], +) +def jellyfin_library_selection(request: IndexRequest) -> dict: + try: + with _job_start_lock: + if get_caption_jobs().running: + raise RuntimeError( + "Captioning is currently running. Wait for it to finish before changing indexed libraries." + ) + return get_index_jobs().apply_library_selection(request.library_ids) + except RuntimeError as exc: + message = str(exc) + status = 409 if "running" in message.lower() else 400 + raise HTTPException(status_code=status, detail=message) from exc + except Exception as exc: + raise HTTPException(status_code=503, detail=str(exc)) from exc + + @app.post( "/api/jellyfin/index", dependencies=[Depends(require_api_key)],