feat(immich): write-back (upsert_tag, tag_assets) + _pipeline tag conventions

This commit is contained in:
2026-06-27 17:16:07 +02:00
parent c36d93e3c7
commit da5b1de2a2
5 changed files with 60 additions and 1 deletions
+2 -1
View File
@@ -1,3 +1,4 @@
from photoflow.immich.client import ImmichClient
from photoflow.immich import pipeline
__all__ = ["ImmichClient"]
__all__ = ["ImmichClient", "pipeline"]
+19
View File
@@ -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()
+11
View File
@@ -0,0 +1,11 @@
ROOT = "_pipeline"
PROCESSED = f"{ROOT}/processed"
NON_TRIP = f"{ROOT}/non-trip"
def ai_rating(n: int) -> str:
return f"{ROOT}/ai-rating/{n}"
def is_pipeline_tag(name: str) -> bool:
return name == ROOT or name.startswith(ROOT + "/")