From 55ef5e67e0a2bc63b762ea0f50b0ff45e804d80b Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:51:01 +0100 Subject: [PATCH 01/13] Persist last Jellyfin index report --- scene_search/index_report.py | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 scene_search/index_report.py diff --git a/scene_search/index_report.py b/scene_search/index_report.py new file mode 100644 index 0000000..21921fa --- /dev/null +++ b/scene_search/index_report.py @@ -0,0 +1,53 @@ +from __future__ import annotations + +import json +from pathlib import Path +from typing import Any + +from .config import settings + + +def report_path() -> Path: + return settings.data_dir / "last-index-report.json" + + +def save_index_report(report: dict[str, Any]) -> None: + path = report_path() + path.parent.mkdir(parents=True, exist_ok=True) + tmp = path.with_suffix(path.suffix + ".tmp") + tmp.write_text( + json.dumps(report, ensure_ascii=False, indent=2), + encoding="utf-8", + ) + tmp.replace(path) + + +def load_index_report() -> dict[str, Any]: + path = report_path() + if not path.is_file(): + return { + "available": False, + "items": [], + "summary": {}, + } + + try: + data = json.loads(path.read_text(encoding="utf-8")) + except (OSError, json.JSONDecodeError): + return { + "available": False, + "items": [], + "summary": {}, + } + + if not isinstance(data, dict): + return { + "available": False, + "items": [], + "summary": {}, + } + + data.setdefault("available", True) + data.setdefault("items", []) + data.setdefault("summary", {}) + return data From bbb254f0739944cc1ccd574be512c1a68018823f Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:51:41 +0100 Subject: [PATCH 02/13] Collect detailed Jellyfin index outcomes --- scene_search/jellyfin_index.py | 109 +++++++++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 5 deletions(-) diff --git a/scene_search/jellyfin_index.py b/scene_search/jellyfin_index.py index 0439506..e243d3a 100644 --- a/scene_search/jellyfin_index.py +++ b/scene_search/jellyfin_index.py @@ -463,10 +463,11 @@ def reconcile_selected_libraries( removed_library_ids: list[str] = [] removed_media_ids: list[str] = [] + removed_items: list[dict[str, object]] = [] with connect(settings.db_path) as con: rows = con.execute( """ - SELECT id, jellyfin_library_id + SELECT id, title, jellyfin_item_id, jellyfin_library_id FROM media WHERE source_kind = 'jellyfin' AND jellyfin_library_id IS NOT NULL @@ -483,6 +484,17 @@ def reconcile_selected_libraries( {str(row["jellyfin_library_id"]) for row in stale} ) removed_media_ids = [str(row["id"]) for row in stale] + removed_items = [ + { + "status": "removed", + "library_id": str(row["jellyfin_library_id"] or ""), + "library": str(row["jellyfin_library_id"] or ""), + "item_id": str(row["jellyfin_item_id"] or ""), + "title": str(row["title"] or row["jellyfin_item_id"] or row["id"]), + "reason": "Library deselected from Scene Search", + } + for row in stale + ] if removed_library_ids: placeholders = ",".join("?" for _ in removed_library_ids) @@ -502,15 +514,22 @@ def reconcile_selected_libraries( "removed_library_ids": removed_library_ids, "removed_libraries": len(removed_library_ids), "removed_media": len(removed_media_ids), + "removed_items": removed_items, } -def _reconcile_library(library_id: str, current_item_ids: set[str]) -> int: +def _reconcile_library( + library_id: str, + current_item_ids: set[str], + *, + library_name: str | None = None, + report_items: list[dict[str, object]] | None = None, +) -> int: stale_rows = [] with connect(settings.db_path) as con: rows = con.execute( """ - SELECT id, jellyfin_item_id + SELECT id, title, jellyfin_item_id FROM media WHERE source_kind = 'jellyfin' AND jellyfin_library_id = ? @@ -528,6 +547,17 @@ def _reconcile_library(library_id: str, current_item_ids: set[str]) -> int: for row in stale_rows: shutil.rmtree(settings.thumbs_dir / str(row["id"]), ignore_errors=True) + if report_items is not None: + report_items.append( + { + "status": "removed", + "library_id": library_id, + "library": library_name or library_id, + "item_id": str(row["jellyfin_item_id"] or ""), + "title": str(row["title"] or row["jellyfin_item_id"] or row["id"]), + "reason": "Item no longer present in Jellyfin library", + } + ) return len(stale_rows) @@ -540,6 +570,7 @@ def _index_library( limit: int | None, force: bool, progress: ProgressCallback | None = None, + report_items: list[dict[str, object]] | None = None, ) -> tuple[SiglipEmbedder | None, int, int, int, int]: library_id = str(library["Id"]) library_name = _library_name(library) @@ -599,6 +630,17 @@ def _index_library( if existing: con.execute("DELETE FROM media WHERE id = ?", (existing["id"],)) pruned += 1 + if report_items is not None: + report_items.append( + { + "status": "removed", + "library_id": library_id, + "library": library_name, + "item_id": item_id, + "title": title, + "reason": "Jellyfin skip tag", + } + ) shutil.rmtree( settings.thumbs_dir / jellyfin_media_id(item_id), ignore_errors=True, @@ -677,11 +719,23 @@ def _index_library( else: local_path = Path(source_path_text) if not local_path.is_file(): + reason = "No Trickplay and media path is not locally accessible" print( f"[{number}/{len(summaries)}] SKIP {title}: " "no Trickplay and media path is not locally accessible" ) failed += 1 + if report_items is not None: + report_items.append( + { + "status": "failed", + "library_id": library_id, + "library": library_name, + "item_id": item_id, + "title": title, + "reason": reason, + } + ) continue print( @@ -703,8 +757,20 @@ def _index_library( trickplay_tile_height = None if selection is None and not frame_paths: + reason = "No frames were extracted" print(f"[{number}/{len(summaries)}] SKIP {title}: no frames") failed += 1 + if report_items is not None: + report_items.append( + { + "status": "failed", + "library_id": library_id, + "library": library_name, + "item_id": item_id, + "title": title, + "reason": reason, + } + ) continue if embedder is None: @@ -817,16 +883,47 @@ def _index_library( f"{preserved_note}" ) indexed += 1 + if report_items is not None: + report_items.append( + { + "status": "indexed", + "library_id": library_id, + "library": library_name, + "item_id": item_id, + "title": title, + "frames": len(frame_rows), + "preserved_annotations": preserved, + "reason": "Indexed successfully", + } + ) except Exception as exc: failed += 1 + failed_item_id = str(summary.get("Id") or "") + failed_title = str(summary.get("Name") or failed_item_id or "(unnamed)") print( f"[{number}/{len(summaries)}] FAIL " - f"{summary.get('Name') or summary.get('Id')}: {exc}" + f"{failed_title}: {exc}" ) + if report_items is not None: + report_items.append( + { + "status": "failed", + "library_id": library_id, + "library": library_name, + "item_id": failed_item_id, + "title": failed_title, + "reason": str(exc), + } + ) if limit is None: - reconciled = _reconcile_library(library_id, current_item_ids) + reconciled = _reconcile_library( + library_id, + current_item_ids, + library_name=library_name, + report_items=report_items, + ) pruned += reconciled if reconciled: print(f" pruned {reconciled} stale item(s) no longer present in Jellyfin") @@ -844,6 +941,7 @@ def index_libraries( limit: int | None = None, force: bool = False, progress: ProgressCallback | None = None, + report_items: list[dict[str, object]] | None = None, ) -> tuple[SiglipEmbedder | None, dict]: total_indexed = 0 total_skipped = 0 @@ -869,6 +967,7 @@ def index_libraries( limit=limit, force=force, progress=progress, + report_items=report_items, ) total_indexed += indexed total_skipped += skipped From 79d3bc86155a6258eb11f43553a12343eb8c2f93 Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:52:44 +0100 Subject: [PATCH 03/13] Persist and page detailed index reports --- scene_search/index_jobs.py | 127 ++++++++++++++++++++++++++++++++++--- 1 file changed, 119 insertions(+), 8 deletions(-) diff --git a/scene_search/index_jobs.py b/scene_search/index_jobs.py index 8bb6cf2..df8ed62 100644 --- a/scene_search/index_jobs.py +++ b/scene_search/index_jobs.py @@ -6,6 +6,7 @@ from datetime import datetime, timezone from typing import Any from .database import connect, init_db +from .index_report import load_index_report, save_index_report from .jellyfin_index import ( build_jellyfin_client, index_libraries, @@ -40,6 +41,39 @@ class IndexJobManager: with self._state_lock: return deepcopy(self._state) + def report( + self, + *, + category: str | None = None, + offset: int = 0, + limit: int = 200, + ) -> dict[str, Any]: + report = load_index_report() + items = list(report.get("items") or []) + if category: + items = [ + item + for item in items + if str(item.get("status") or "") == category + ] + + total = len(items) + page = items[offset:offset + limit] + return { + "available": bool(report.get("available", False)), + "kind": report.get("kind"), + "status": report.get("status"), + "started_at": report.get("started_at"), + "finished_at": report.get("finished_at"), + "error": report.get("error"), + "summary": report.get("summary") or {}, + "category": category, + "offset": offset, + "limit": limit, + "total": total, + "items": page, + } + def libraries(self) -> list[dict[str, Any]]: client = build_jellyfin_client() libraries = client.media_folders() @@ -92,7 +126,9 @@ class IndexJobManager: for value in library_ids if str(value).strip() } + started_at = datetime.now(timezone.utc).isoformat() result = reconcile_selected_libraries(selected_ids) + removed_items = list(result.pop("removed_items", []) or []) removed_ids = [ str(value) for value in (result.get("removed_library_ids") or []) @@ -104,6 +140,26 @@ class IndexJobManager: + ", ".join(removed_ids) + f" ({int(result.get('removed_media') or 0)} media item(s))" ) + + finished_at = datetime.now(timezone.utc).isoformat() + save_index_report( + { + "available": True, + "kind": "library_selection", + "status": "complete", + "started_at": started_at, + "finished_at": finished_at, + "error": None, + "summary": { + "indexed": 0, + "skipped": 0, + "failed": 0, + "pruned": int(result.get("removed_media") or 0), + "removed_libraries": int(result.get("removed_libraries") or 0), + }, + "items": removed_items, + } + ) return result def start(self, library_ids: list[str], *, force: bool = False) -> dict[str, Any]: @@ -208,8 +264,11 @@ class IndexJobManager: selected_ids: set[str], force: bool, ) -> None: + report_items: list[dict[str, object]] = [] + started_at = str(self.status().get("started_at") or datetime.now(timezone.utc).isoformat()) try: removed = reconcile_selected_libraries(selected_ids) + report_items.extend(list(removed.pop("removed_items", []) or [])) removed_ids = [ str(value) for value in (removed.get("removed_library_ids") or []) @@ -229,17 +288,34 @@ class IndexJobManager: ) if not libraries: + finished_at = datetime.now(timezone.utc).isoformat() + summary = { + "library_total": 0, + "indexed": 0, + "skipped": 0, + "failed": 0, + "pruned": int(removed.get("removed_media") or 0), + "removed_libraries": int(removed.get("removed_libraries") or 0), + } self._progress( { "running": False, "stage": "complete", - "finished_at": datetime.now(timezone.utc).isoformat(), + "finished_at": finished_at, "documents_processed": 0, - "library_total": 0, - "indexed": 0, - "skipped": 0, - "failed": 0, - "pruned": int(removed.get("removed_media") or 0), + **summary, + } + ) + save_index_report( + { + "available": True, + "kind": "index", + "status": "complete", + "started_at": started_at, + "finished_at": finished_at, + "error": None, + "summary": summary, + "items": report_items, } ) return @@ -253,6 +329,7 @@ class IndexJobManager: embedder=embedder, force=force, progress=self._progress, + report_items=report_items, ) retained_index_changed = ( int(summary.get("indexed") or 0) > 0 @@ -276,22 +353,56 @@ class IndexJobManager: "skipping full Meilisearch rebuild." ) + finished_at = datetime.now(timezone.utc).isoformat() self._progress( { "running": False, "stage": "complete", - "finished_at": datetime.now(timezone.utc).isoformat(), + "finished_at": finished_at, "documents_processed": documents, "full_meili_rebuild": retained_index_changed, **summary, } ) + save_index_report( + { + "available": True, + "kind": "index", + "status": "complete", + "started_at": started_at, + "finished_at": finished_at, + "error": None, + "summary": { + **summary, + "documents_processed": documents, + "full_meili_rebuild": retained_index_changed, + }, + "items": report_items, + } + ) except Exception as exc: + finished_at = datetime.now(timezone.utc).isoformat() self._progress( { "running": False, "stage": "failed", - "finished_at": datetime.now(timezone.utc).isoformat(), + "finished_at": finished_at, "error": str(exc), } ) + save_index_report( + { + "available": True, + "kind": "index", + "status": "failed", + "started_at": started_at, + "finished_at": finished_at, + "error": str(exc), + "summary": { + "indexed": sum(1 for item in report_items if item.get("status") == "indexed"), + "failed": sum(1 for item in report_items if item.get("status") == "failed"), + "pruned": sum(1 for item in report_items if item.get("status") == "removed"), + }, + "items": report_items, + } + ) From 98f3a5cb869b6c66f67d3624cc2a401fbca0bdb6 Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:52:56 +0100 Subject: [PATCH 04/13] Expose paged last-index report API --- scene_search/api.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scene_search/api.py b/scene_search/api.py index 63671e8..44b9c88 100644 --- a/scene_search/api.py +++ b/scene_search/api.py @@ -189,6 +189,27 @@ def jellyfin_index_status() -> dict: return get_index_jobs().status() +@app.get( + "/api/jellyfin/index/report", + dependencies=[Depends(require_api_key)], +) +def jellyfin_index_report( + category: str | None = Query(default=None), + offset: int = Query(default=0, ge=0), + limit: int = Query(default=200, ge=1, le=1000), +) -> dict: + if category not in {None, "failed", "removed", "indexed"}: + raise HTTPException( + status_code=400, + detail="category must be failed, removed, indexed, or omitted", + ) + return get_index_jobs().report( + category=category, + offset=offset, + limit=limit, + ) + + @app.post( "/api/caption", dependencies=[Depends(require_api_key)], From 1fd0eb9687ef93d8c0ec9cff307b11f2d7393e74 Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:53:28 +0100 Subject: [PATCH 05/13] Add index report plugin models --- .../SceneSearchAdminModels.cs | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/SceneSearchAdminModels.cs b/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/SceneSearchAdminModels.cs index 9533168..33c876e 100644 --- a/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/SceneSearchAdminModels.cs +++ b/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/SceneSearchAdminModels.cs @@ -99,6 +99,91 @@ public sealed class SceneSearchIndexStatus } +public sealed class SceneSearchIndexReportResponse +{ + [JsonPropertyName("available")] + public bool Available { get; set; } + + [JsonPropertyName("kind")] + public string? Kind { get; set; } + + [JsonPropertyName("status")] + public string? Status { get; set; } + + [JsonPropertyName("started_at")] + public string? StartedAt { get; set; } + + [JsonPropertyName("finished_at")] + public string? FinishedAt { get; set; } + + [JsonPropertyName("error")] + public string? Error { get; set; } + + [JsonPropertyName("summary")] + public SceneSearchIndexReportSummary Summary { get; set; } = new(); + + [JsonPropertyName("category")] + public string? Category { get; set; } + + [JsonPropertyName("offset")] + public int Offset { get; set; } + + [JsonPropertyName("limit")] + public int Limit { get; set; } + + [JsonPropertyName("total")] + public int Total { get; set; } + + [JsonPropertyName("items")] + public List Items { get; set; } = []; +} + +public sealed class SceneSearchIndexReportSummary +{ + [JsonPropertyName("indexed")] + public int Indexed { get; set; } + + [JsonPropertyName("skipped")] + public int Skipped { get; set; } + + [JsonPropertyName("failed")] + public int Failed { get; set; } + + [JsonPropertyName("pruned")] + public int Pruned { get; set; } + + [JsonPropertyName("removed_libraries")] + public int RemovedLibraries { get; set; } +} + +public sealed class SceneSearchIndexReportItem +{ + [JsonPropertyName("status")] + public string Status { get; set; } = string.Empty; + + [JsonPropertyName("library_id")] + public string LibraryId { get; set; } = string.Empty; + + [JsonPropertyName("library")] + public string Library { get; set; } = string.Empty; + + [JsonPropertyName("item_id")] + public string ItemId { get; set; } = string.Empty; + + [JsonPropertyName("title")] + public string Title { get; set; } = string.Empty; + + [JsonPropertyName("reason")] + public string Reason { get; set; } = string.Empty; + + [JsonPropertyName("frames")] + public int? Frames { get; set; } + + [JsonPropertyName("preserved_annotations")] + public int? PreservedAnnotations { get; set; } +} + + public sealed class SceneSearchCaptionRequest { [JsonPropertyName("library_ids")] From de4180f9aa471c968642366ed5468a9961991091 Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:53:41 +0100 Subject: [PATCH 06/13] Add plugin index report client --- .../SceneSearchClient.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/SceneSearchClient.cs b/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/SceneSearchClient.cs index 03e14aa..5007163 100644 --- a/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/SceneSearchClient.cs +++ b/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/SceneSearchClient.cs @@ -97,6 +97,30 @@ public sealed class SceneSearchClient : IDisposable content: null, cancellationToken); + public Task GetIndexReportAsync( + string? category, + int offset, + int limit, + CancellationToken cancellationToken) + { + var path = string.Concat( + "/api/jellyfin/index/report?offset=", + Math.Max(offset, 0).ToString(System.Globalization.CultureInfo.InvariantCulture), + "&limit=", + Math.Clamp(limit, 1, 1000).ToString(System.Globalization.CultureInfo.InvariantCulture)); + + if (!string.IsNullOrWhiteSpace(category)) + { + path += "&category=" + Uri.EscapeDataString(category); + } + + return SendAsync( + HttpMethod.Get, + path, + content: null, + cancellationToken); + } + public Task StartCaptionAsync( SceneSearchCaptionRequest request, CancellationToken cancellationToken) From 6d161bf8de5428afc8c3b07b7a70725a965c08dd Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:53:54 +0100 Subject: [PATCH 07/13] Expose index report through Jellyfin plugin --- .../Api/SceneSearchController.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Api/SceneSearchController.cs b/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Api/SceneSearchController.cs index 89cf1f0..ab4c14f 100644 --- a/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Api/SceneSearchController.cs +++ b/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Api/SceneSearchController.cs @@ -58,6 +58,24 @@ public sealed class SceneSearchController : ControllerBase : Ok(result); } + [HttpGet("IndexReport")] + [ProducesResponseType(StatusCodes.Status200OK)] + public async Task> IndexReport( + [FromQuery] string? category = null, + [FromQuery] int offset = 0, + [FromQuery] int limit = 200) + { + var result = await _client.GetIndexReportAsync( + category, + offset, + limit, + HttpContext.RequestAborted).ConfigureAwait(false); + + return result is null + ? StatusCode(StatusCodes.Status503ServiceUnavailable, "Scene Search API unavailable.") + : Ok(result); + } + [HttpPost("Caption")] [ProducesResponseType(StatusCodes.Status202Accepted)] From 1dbf09b5d52287359641e3e59fbbd800be70b51f Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:54:18 +0100 Subject: [PATCH 08/13] Add index result drill-down to web dashboard --- scene_search/web/index.html | 68 +++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/scene_search/web/index.html b/scene_search/web/index.html index 45c846f..1e805bf 100644 --- a/scene_search/web/index.html +++ b/scene_search/web/index.html @@ -90,6 +90,14 @@
Idle
+
+ + + +
+
+
+
@@ -127,6 +135,9 @@ let lastIndexRunning = false; let lastCaptionRunning = false; let captionLastStatus = null; + let reportCategory = null; + let reportOffset = 0; + let reportTotal = 0; let thumbnailUrls = []; $('apiKey').value = localStorage.getItem('sceneSearchApiKey') || ''; @@ -222,6 +233,55 @@ } } + async function refreshIndexReportSummary() { + try { + const report = await api('/api/jellyfin/index/report?limit=1'); + const summary = report.summary || {}; + $('reportFailed').textContent = 'Failed (' + (summary.failed || 0) + ')'; + $('reportRemoved').textContent = 'Removed (' + (summary.pruned || 0) + ')'; + $('reportIndexed').textContent = 'Indexed (' + (summary.indexed || 0) + ')'; + if (!report.available) { + $('indexReportMeta').textContent = 'No saved index report yet.'; + } + } catch (_) {} + } + + async function loadIndexReport(category, append=false) { + const offset = append ? reportOffset : 0; + try { + const report = await api( + '/api/jellyfin/index/report?category=' + encodeURIComponent(category) + + '&offset=' + offset + '&limit=200' + ); + reportCategory = category; + reportOffset = offset + (report.items || []).length; + reportTotal = Number(report.total || 0); + + const container = $('indexReportList'); + if (!append) container.innerHTML = ''; + + for (const item of (report.items || [])) { + const row = document.createElement('div'); + row.style.cssText = 'padding:8px 0;border-bottom:1px solid #282d36'; + row.innerHTML = + '' + escapeHtml(item.title || item.item_id || '(unnamed)') + '' + + '
' + + escapeHtml(item.library || item.library_id || '') + + (item.item_id ? ' · ' + escapeHtml(item.item_id) : '') + + '
' + + '
' + escapeHtml(item.reason || '') + '
'; + container.appendChild(row); + } + + $('indexReportMeta').textContent = + reportTotal + ' ' + category + ' item' + (reportTotal === 1 ? '' : 's') + + (report.finished_at ? ' · last run ' + report.finished_at : ''); + $('indexReportMore').style.display = reportOffset < reportTotal ? '' : 'none'; + } catch (e) { + $('indexReportMeta').textContent = e.message; + } + } + async function refreshStatus() { try { const s = await api('/api/jellyfin/index/status'); @@ -230,6 +290,7 @@ if (lastIndexRunning && !running) { loadLibraries(); refreshHealth(); + refreshIndexReportSummary(); } lastIndexRunning = running; return s; @@ -472,6 +533,12 @@ $('indexNow').onclick = startIndex; $('captionNow').onclick = startCaption; $('captionPause').onclick = toggleCaptionPause; + $('reportFailed').onclick = () => loadIndexReport('failed'); + $('reportRemoved').onclick = () => loadIndexReport('removed'); + $('reportIndexed').onclick = () => loadIndexReport('indexed'); + $('indexReportMore').onclick = () => { + if (reportCategory) loadIndexReport(reportCategory, true); + }; $('searchButton').onclick = search; $('searchQuery').addEventListener('keydown', e => { if (e.key === 'Enter') search(); }); @@ -479,6 +546,7 @@ loadLibraries(); refreshStatus(); refreshCaptionStatus(); + refreshIndexReportSummary(); statusTimer = setInterval(refreshStatus, 2000); captionTimer = setInterval(refreshCaptionStatus, 2000); })(); From 41f2d32b935c1d382cfd1ec54f0bd3082e96f9f3 Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:54:56 +0100 Subject: [PATCH 09/13] Add index report drill-down to Jellyfin plugin --- .../Configuration/configPage.html | 111 +++++++++++++++++- 1 file changed, 109 insertions(+), 2 deletions(-) diff --git a/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html b/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html index 3af5afc..70fa1fa 100644 --- a/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html +++ b/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html @@ -70,7 +70,17 @@ -
+
+
+ + + +
+
+
+

Captioning

@@ -115,6 +125,9 @@ var lastIndexRunning = false; var lastCaptionRunning = false; var lastCaptionStatus = null; + var reportCategory = null; + var reportOffset = 0; + var reportTotal = 0; function selectedLibraryIds() { return Array.prototype.slice.call( @@ -200,6 +213,79 @@ } } + function refreshIndexReportSummary() { + return ApiClient.getJSON( + ApiClient.getUrl('Plugins/SceneSearch/IndexReport') + '?limit=1' + ).then(function (report) { + var summary = (report && report.summary) || {}; + page.querySelector('#reportFailed span').textContent = + 'Failed (' + (summary.failed || 0) + ')'; + page.querySelector('#reportRemoved span').textContent = + 'Removed (' + (summary.pruned || 0) + ')'; + page.querySelector('#reportIndexed span').textContent = + 'Indexed (' + (summary.indexed || 0) + ')'; + if (!report || !report.available) { + page.querySelector('#indexReportMeta').textContent = + 'No saved index report yet.'; + } + }).catch(function () { + // Status remains usable even if no report is available. + }); + } + + function loadIndexReport(category, append) { + append = !!append; + var offset = append ? reportOffset : 0; + var url = ApiClient.getUrl('Plugins/SceneSearch/IndexReport') + + '?category=' + encodeURIComponent(category) + + '&offset=' + offset + '&limit=200'; + + return ApiClient.getJSON(url).then(function (report) { + reportCategory = category; + var items = (report && report.items) || []; + reportOffset = offset + items.length; + reportTotal = Number((report && report.total) || 0); + + var container = page.querySelector('#indexReportList'); + if (!append) { + container.innerHTML = ''; + } + + items.forEach(function (item) { + var row = document.createElement('div'); + row.style.cssText = + 'padding:.65em 0;border-bottom:1px solid rgba(255,255,255,.12)'; + + var title = document.createElement('strong'); + title.textContent = item.title || item.item_id || '(unnamed)'; + row.appendChild(title); + + var meta = document.createElement('div'); + meta.className = 'fieldDescription'; + meta.textContent = + (item.library || item.library_id || '') + + (item.item_id ? ' · ' + item.item_id : ''); + row.appendChild(meta); + + var reason = document.createElement('div'); + reason.textContent = item.reason || ''; + row.appendChild(reason); + container.appendChild(row); + }); + + page.querySelector('#indexReportMeta').textContent = + reportTotal + ' ' + category + ' item' + + (reportTotal === 1 ? '' : 's') + + (report.finished_at ? ' · last run ' + report.finished_at : ''); + + page.querySelector('#indexReportMore').style.display = + reportOffset < reportTotal ? '' : 'none'; + }).catch(function () { + page.querySelector('#indexReportMeta').textContent = + 'Could not load the saved index report.'; + }); + } + function refreshStatus() { return ApiClient.getJSON(ApiClient.getUrl('Plugins/SceneSearch/IndexStatus')) .then(function (status) { @@ -208,6 +294,7 @@ if (lastIndexRunning && !running) { loadLibraries(); + refreshIndexReportSummary(); } lastIndexRunning = running; }) @@ -346,7 +433,12 @@ page.querySelector('#maxResults').value = config.MaxResults || 20; page.querySelector('#timeoutSeconds').value = config.TimeoutSeconds || 60; - return Promise.all([loadLibraries(), refreshStatus(), refreshCaptionStatus()]); + return Promise.all([ + loadLibraries(), + refreshStatus(), + refreshCaptionStatus(), + refreshIndexReportSummary() + ]); }).then(function () { if (!statusTimer) { statusTimer = setInterval(refreshStatus, 2000); @@ -370,6 +462,21 @@ } }); + page.querySelector('#reportFailed').addEventListener('click', function () { + loadIndexReport('failed', false); + }); + page.querySelector('#reportRemoved').addEventListener('click', function () { + loadIndexReport('removed', false); + }); + page.querySelector('#reportIndexed').addEventListener('click', function () { + loadIndexReport('indexed', false); + }); + page.querySelector('#indexReportMore').addEventListener('click', function () { + if (reportCategory) { + loadIndexReport(reportCategory, true); + } + }); + page.querySelector('#applyLibraries').addEventListener('click', function () { var ids = selectedLibraryIds(); if (!ids.length && !window.confirm( From fe8c70243cf663c376a47fcc499a8727460bbc31 Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:55:24 +0100 Subject: [PATCH 10/13] Document persistent index run reports --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 14b9422..a867fe7 100644 --- a/README.md +++ b/README.md @@ -460,6 +460,7 @@ The API also exposes authenticated management endpoints used by the plugin and s - `POST /api/jellyfin/libraries/selection` — apply the authoritative library selection and remove deselected libraries from SQLite/Meilisearch. - `POST /api/jellyfin/index` — apply the authoritative selection and start one background indexing job for selected library ids. - `GET /api/jellyfin/index/status` — report live library/item/frame/sync progress. +- `GET /api/jellyfin/index/report` — page through the persisted last-run details for failed, removed or indexed items. - `POST /api/caption` — start or resume caption generation for selected library ids. - `GET /api/caption/status` — report routing/caption/model/frame/sync progress. - `POST /api/caption/pause` — cooperatively pause routing/captioning at the next safe boundary. @@ -523,7 +524,8 @@ The plugin's library selection is authoritative. Saving the plugin settings post Library removal is targeted. **Apply selection only** (or saving the plugin settings) deletes deselected libraries from SQLite and deletes only matching `jellyfin_library_id` documents from Meilisearch; it does not clear/re-feed the complete Meilisearch index. **Index selected libraries** remains the action for scanning media. If that scan finds all retained libraries unchanged, Scene Search now skips the final full Meilisearch rebuild as well. -Use **Apply library selection / index** to apply the same authoritative set and start a backend indexing job. An empty selection is allowed only after an explicit confirmation and removes all Jellyfin-backed Scene Search data. The plugin shows an overall percentage/progress bar across all selected libraries as well as the current library, item and frame progress, and polls until the job completes. When ingestion finishes, the backend automatically rebuilds Meilisearch, so newly indexed vectors are searchable without a separate `sync-meili` command. +Use **Apply library selection / index** to apply the same authoritative set and start a backend indexing job. An empty selection is allowed only after an explicit confirmation and removes all Jellyfin-backed Scene Search data. The plugin shows an overall percentage/progress bar across all selected libraries as well as the current library, item and frame progress, and polls until the job completes. When ingestion finishes, the backend automatically rebuilds Meilisearch, so newly indexed vectors are searchable without a separate `sync-meili` command. The completed summary also exposes drill-down buttons for **Failed**, **Removed** and **Indexed** items. Those details are written to `data/last-index-report.json`, are paged on demand instead of being included in the 2-second status polling payload, and survive a dashboard refresh or container restart. Unchanged items are counted but intentionally not persisted individually because large libraries can contain tens of thousands of them. + The same page also has **Start / resume captioning** and **Pause**. Pause finishes the currently active routing batch or Ollama frame request, then waits before starting the next unit; Resume continues the same in-memory job without rebuilding its queues. Every successful caption is committed immediately, so a process/container interruption can still be recovered by pressing Start / resume and continuing from uncaptained frames. **Force recaption existing frames** deliberately regenerates captions, but reuses saved routing decisions while the routing policy is still current. From 7aae4d050ef27b96fbb38b10139c8f6da2454169 Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:55:43 +0100 Subject: [PATCH 11/13] Test persistent paged index reports --- tests/test_index_report.py | 64 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/test_index_report.py diff --git a/tests/test_index_report.py b/tests/test_index_report.py new file mode 100644 index 0000000..2f8d9b2 --- /dev/null +++ b/tests/test_index_report.py @@ -0,0 +1,64 @@ +from __future__ import annotations + +import tempfile +import unittest +from pathlib import Path +from types import SimpleNamespace +from unittest.mock import patch + +from scene_search.index_jobs import IndexJobManager +from scene_search.index_report import load_index_report, save_index_report + + +class IndexReportTests(unittest.TestCase): + def test_report_persists_across_process_state(self) -> None: + with tempfile.TemporaryDirectory() as tmp: + fake_settings = SimpleNamespace(data_dir=Path(tmp)) + report = { + "available": True, + "kind": "index", + "status": "complete", + "summary": {"failed": 1, "pruned": 1, "indexed": 1}, + "items": [ + {"status": "failed", "title": "Bad", "reason": "No Trickplay"}, + {"status": "removed", "title": "Gone", "reason": "Removed"}, + {"status": "indexed", "title": "Good", "reason": "Indexed"}, + ], + } + + with patch("scene_search.index_report.settings", fake_settings): + save_index_report(report) + loaded = load_index_report() + + self.assertTrue(loaded["available"]) + self.assertEqual(loaded["summary"]["failed"], 1) + self.assertEqual(len(loaded["items"]), 3) + + def test_manager_report_filters_and_pages_without_polling_all_items(self) -> None: + manager = IndexJobManager(SimpleNamespace()) # type: ignore[arg-type] + stored = { + "available": True, + "kind": "index", + "status": "complete", + "started_at": "start", + "finished_at": "finish", + "summary": {"failed": 3}, + "items": [ + {"status": "failed", "title": "A"}, + {"status": "indexed", "title": "B"}, + {"status": "failed", "title": "C"}, + {"status": "failed", "title": "D"}, + ], + } + + with patch("scene_search.index_jobs.load_index_report", return_value=stored): + page = manager.report(category="failed", offset=1, limit=1) + + self.assertEqual(page["total"], 3) + self.assertEqual(page["offset"], 1) + self.assertEqual(page["limit"], 1) + self.assertEqual([item["title"] for item in page["items"]], ["C"]) + + +if __name__ == "__main__": + unittest.main() From 7641d009769c1c5c9c258b7e292754b87a0d6c16 Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:56:09 +0100 Subject: [PATCH 12/13] Refresh report summary after library removal --- scene_search/web/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/scene_search/web/index.html b/scene_search/web/index.html index 1e805bf..58dbaf6 100644 --- a/scene_search/web/index.html +++ b/scene_search/web/index.html @@ -326,6 +326,7 @@ $('indexDetail').textContent = 'No full Meilisearch rebuild was run.'; await loadLibraries(); refreshHealth(); + refreshIndexReportSummary(); } catch (e) { $('indexStatus').className = 'status error'; $('indexStatus').textContent = e.message; From 918473812b0356254a4ec85114cdcf2ba9c235ae Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:56:26 +0100 Subject: [PATCH 13/13] Refresh plugin report after library removal --- .../Jellyfin.Plugin.SceneSearch/Configuration/configPage.html | 1 + 1 file changed, 1 insertion(+) diff --git a/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html b/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html index 70fa1fa..9c4e4e8 100644 --- a/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html +++ b/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html @@ -510,6 +510,7 @@ ' and ' + removedMedia + ' media items. No full search-index rebuild.' : 'Selection applied: nothing to remove.'; loadLibraries(); + refreshIndexReportSummary(); }).catch(function () { page.querySelector('#indexStatus').textContent = 'Could not apply library selection. Check Jellyfin logs and Scene Search API status.';