mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-19 00:03:36 +00:00
Support safe full-DTO Jellyfin Overview metadata updates
This commit is contained in:
@@ -152,6 +152,34 @@ class JellyfinClient:
|
||||
raise RuntimeError(f"Jellyfin item not found: {item_id}")
|
||||
return items[0]
|
||||
|
||||
def item_for_update(self, item_id: str) -> dict[str, Any]:
|
||||
"""Fetch the full Jellyfin DTO, not the slim indexed-items projection."""
|
||||
data = self._get(f"/Items/{item_id}").json()
|
||||
if not isinstance(data, dict) or not data.get("Id"):
|
||||
raise RuntimeError(f"Jellyfin returned no editable item for {item_id}")
|
||||
return data
|
||||
|
||||
def update_item_overview(self, item: dict[str, Any], overview: str) -> None:
|
||||
"""Submit Jellyfin's full item DTO with only Overview modified.
|
||||
|
||||
POST /Items/{id} is a metadata edit, NOT a partial PATCH. Using a
|
||||
minimal body risks resetting other metadata; supply the current DTO.
|
||||
"""
|
||||
item_id = str(item.get("Id") or "")
|
||||
if not item_id:
|
||||
raise ValueError("Cannot update an item without its Jellyfin ID")
|
||||
payload = {**item, "Overview": overview}
|
||||
response = self.session.post(
|
||||
f"{self.url}/Items/{item_id}",
|
||||
json=payload,
|
||||
timeout=self.timeout_seconds,
|
||||
)
|
||||
if not response.ok:
|
||||
raise RuntimeError(
|
||||
f"Jellyfin {response.status_code} POST /Items/{item_id}: "
|
||||
f"{response.text[:500]}"
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def select_trickplay(
|
||||
item: dict[str, Any],
|
||||
|
||||
Reference in New Issue
Block a user