From 30197e80c91d8321a2442f91fdcde59f3bc17018 Mon Sep 17 00:00:00 2001 From: Sleeps Date: Tue, 6 Oct 2026 15:46:27 +0100 Subject: [PATCH] Remove skipped Jellyfin items and track tag changes --- scene_search/jellyfin_index.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/scene_search/jellyfin_index.py b/scene_search/jellyfin_index.py index 5cab165..b67e284 100644 --- a/scene_search/jellyfin_index.py +++ b/scene_search/jellyfin_index.py @@ -1,6 +1,7 @@ from __future__ import annotations import hashlib +import shutil from pathlib import Path from PIL import Image @@ -167,7 +168,21 @@ def cmd_jellyfin_index(args: object) -> None: normalized_tags = {tag.casefold() for tag in tags} if settings.jellyfin_skip_tag and settings.jellyfin_skip_tag in normalized_tags: - print(f"[{number}/{len(summaries)}] SKIP {title}: Jellyfin skip tag") + with connect(settings.db_path) as con: + existing = con.execute( + "SELECT id FROM media WHERE jellyfin_item_id = ?", + (item_id,), + ).fetchone() + if existing: + con.execute("DELETE FROM media WHERE id = ?", (existing["id"],)) + shutil.rmtree( + settings.thumbs_dir / jellyfin_media_id(item_id), + ignore_errors=True, + ) + print( + f"[{number}/{len(summaries)}] SKIP {title}: " + "Jellyfin skip tag (removed from canonical index)" + ) skipped += 1 continue @@ -199,9 +214,11 @@ def cmd_jellyfin_index(args: object) -> None: (item_id,), ).fetchone() + tags_json = tags_to_json(tags) if ( existing and existing["jellyfin_etag"] == etag + and existing["jellyfin_tags"] == tags_json and existing["model_id"] == settings.model_id and int(existing["interval_ms"]) == expected_interval_ms and not force @@ -310,7 +327,7 @@ def cmd_jellyfin_index(args: object) -> None: media_source_id, str(library["Id"]), str(detail.get("Type") or ""), - tags_to_json(tags), + tags_json, etag, trickplay_width, trickplay_tile_width,