"""Thin wrapper around the bits of the Immich API this project needs.""" from __future__ import annotations import httpx class ImmichClient: def __init__(self, base_url: str, api_key: str): self.base_url = base_url.rstrip("/") self._headers = {"x-api-key": api_key} def list_albums(self) -> list[dict]: resp = httpx.get(f"{self.base_url}/api/albums", headers=self._headers, timeout=10) resp.raise_for_status() return resp.json() def get_album(self, album_id: str) -> dict: resp = httpx.get(f"{self.base_url}/api/albums/{album_id}", headers=self._headers, timeout=10) resp.raise_for_status() return resp.json() def download_asset_preview(self, asset_id: str) -> bytes: resp = httpx.get( f"{self.base_url}/api/assets/{asset_id}/thumbnail", params={"size": "preview"}, headers=self._headers, timeout=30, ) resp.raise_for_status() return resp.content