mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-17 23:41:28 +00:00
Remove skipped Jellyfin items and track tag changes
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user