Support safe full-DTO Jellyfin Overview metadata updates

This commit is contained in:
Sleeps
2026-10-08 15:45:21 +01:00
parent e780fd4176
commit b938c433f0
+28
View File
@@ -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],