diff --git a/scene_search/jellyfin.py b/scene_search/jellyfin.py index d651ea9..2a30195 100644 --- a/scene_search/jellyfin.py +++ b/scene_search/jellyfin.py @@ -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],