mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-16 23:11:27 +00:00
Add opt-in Jellyfin overview preview, publish and restore CLI
This commit is contained in:
@@ -42,6 +42,9 @@ from .maintenance import (
|
||||
remove_media_by_source,
|
||||
)
|
||||
from .meili import Meili
|
||||
from .overviews import preview as preview_visual_overview
|
||||
from .overviews import publish as publish_visual_overview
|
||||
from .overviews import restore as restore_visual_overview
|
||||
from .routing import ExplicitContentRouter, apply_context_routing
|
||||
from .search_service import SearchService
|
||||
from .sync import (
|
||||
@@ -967,6 +970,50 @@ def cmd_status(_: argparse.Namespace) -> None:
|
||||
print(f"Documents: {stats.get('numberOfDocuments', 'unknown')}")
|
||||
print(f"Indexing: {stats.get('isIndexing', 'unknown')}")
|
||||
|
||||
|
||||
def cmd_jellyfin_overview(args: argparse.Namespace) -> None:
|
||||
"""Preview first; publish and restore are explicit, separate actions."""
|
||||
target = {
|
||||
"db_path": settings.db_path,
|
||||
"media_id": args.media_id,
|
||||
"title": args.title,
|
||||
}
|
||||
if args.restore:
|
||||
result = restore_visual_overview(**target)
|
||||
print(f"Restored original Jellyfin Overview for {result['title']!r}.")
|
||||
return
|
||||
|
||||
if args.apply:
|
||||
result = publish_visual_overview(**target)
|
||||
print(
|
||||
f"Jellyfin Overview for {result['title']!r}: "
|
||||
f"{result['status']}. Original synopsis retained."
|
||||
)
|
||||
return
|
||||
|
||||
result = preview_visual_overview(
|
||||
**target,
|
||||
model=args.model,
|
||||
max_captions=args.max_captions,
|
||||
regenerate=args.regenerate,
|
||||
)
|
||||
print(f"Title: {result['title']}")
|
||||
print(f"Media ID: {result['media_id']}")
|
||||
print(f"Jellyfin: {result['jellyfin_item_id']}")
|
||||
print(f"LLM model: {result['model']}")
|
||||
print(
|
||||
f"Evidence: {result['sampled_captions']}/"
|
||||
f"{result['total_captions']} caption segments"
|
||||
)
|
||||
print("\nDRAFT ONLY — no Jellyfin metadata has been changed:\n")
|
||||
print(result["overview"])
|
||||
print(
|
||||
"\nTo append this to the existing Jellyfin synopsis, run this "
|
||||
"command again with --apply. To undo later, use --restore. "
|
||||
"This is a visual summary, not a verified film synopsis."
|
||||
)
|
||||
|
||||
|
||||
def cmd_search(args: argparse.Namespace) -> None:
|
||||
service = SearchService(
|
||||
db_path=settings.db_path,
|
||||
@@ -1055,6 +1102,35 @@ def make_parser() -> argparse.ArgumentParser:
|
||||
)
|
||||
repair.set_defaults(func=cmd_repair_caption_index)
|
||||
|
||||
overview = sub.add_parser(
|
||||
"jellyfin-overview",
|
||||
help="Preview an AI visual overview, then explicitly publish/restore Jellyfin metadata",
|
||||
)
|
||||
overview_target = overview.add_mutually_exclusive_group(required=True)
|
||||
overview_target.add_argument("--title", help="Exact indexed title (must be unique)")
|
||||
overview_target.add_argument("--media-id", help="Canonical scene-search media ID")
|
||||
action = overview.add_mutually_exclusive_group()
|
||||
action.add_argument(
|
||||
"--apply", action="store_true",
|
||||
help="Publish the previously previewed draft (append; preserve original)",
|
||||
)
|
||||
action.add_argument(
|
||||
"--restore", action="store_true",
|
||||
help="Restore the original Jellyfin synopsis if no later edits were made",
|
||||
)
|
||||
action.add_argument(
|
||||
"--regenerate", action="store_true",
|
||||
help="Regenerate the draft with current captions and model (no Jellyfin write)",
|
||||
)
|
||||
overview.add_argument(
|
||||
"--model", help="Override OVERVIEW_MODEL when generating drafts"
|
||||
)
|
||||
overview.add_argument(
|
||||
"--max-captions", type=int, default=64,
|
||||
help="Max evenly spaced caption segments sent to Ollama (1-64)",
|
||||
)
|
||||
overview.set_defaults(func=cmd_jellyfin_overview)
|
||||
|
||||
jf_test = sub.add_parser("jellyfin-test", help="Verify Jellyfin API connectivity")
|
||||
jf_test.set_defaults(func=cmd_jellyfin_test)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user