feat(immich): write-back (upsert_tag, tag_assets) + _pipeline tag conventions
This commit is contained in:
@@ -72,3 +72,22 @@ class ImmichClient:
|
||||
timeout=self.timeout)
|
||||
r.raise_for_status()
|
||||
return r.content
|
||||
|
||||
def upsert_tag(self, name: str) -> str:
|
||||
r = self.session.put(self._url("/api/tags"),
|
||||
json={"tags": [name]}, timeout=self.timeout)
|
||||
r.raise_for_status()
|
||||
for tag in r.json():
|
||||
if tag.get("value") == name or tag.get("name") == name:
|
||||
return tag["id"]
|
||||
resolved = self.resolve_tag_id(name)
|
||||
if resolved is None:
|
||||
raise RuntimeError(f"upsert_tag: could not resolve id for {name!r}")
|
||||
return resolved
|
||||
|
||||
def tag_assets(self, tag_id: str, asset_ids: list[str]) -> None:
|
||||
if not asset_ids:
|
||||
return
|
||||
r = self.session.put(self._url(f"/api/tags/{tag_id}/assets"),
|
||||
json={"ids": asset_ids}, timeout=self.timeout)
|
||||
r.raise_for_status()
|
||||
|
||||
Reference in New Issue
Block a user