summaryrefslogtreecommitdiff
path: root/immich.py
diff options
context:
space:
mode:
authorTim Keller <tjkeller.xyz>2025-05-11 00:20:08 -0500
committerTim Keller <tjkeller.xyz>2025-05-11 00:20:08 -0500
commit31f1940ec8c4aba6a0c21b20eff9657d5d11cf80 (patch)
treec4c3aaac22d65a78b48ac5e0173a3b28b7ebbb23 /immich.py
parent8afd27d113d20f924df73456374153397039e1ba (diff)
downloadimmich-frame-31f1940ec8c4aba6a0c21b20eff9657d5d11cf80.tar.xz
immich-frame-31f1940ec8c4aba6a0c21b20eff9657d5d11cf80.zip
albums thumbnails endpoint and albums endpoint
Diffstat (limited to 'immich.py')
-rw-r--r--immich.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/immich.py b/immich.py
index 1f1ccb8..63e6f63 100644
--- a/immich.py
+++ b/immich.py
@@ -12,6 +12,13 @@ class ImmichConnector:
def _request(self, endpoint):
return requests.get(f"{self.server_url}/api/{endpoint}", headers={ "x-api-key": self.api_key })
+ def load_all_albums(self):
+ response = self._request("albums")
+ if response.status_code != 200: return
+
+ data = response.json()
+ return data
+
def load_album_assets(self, key):
response = self._request(f"albums/{key}")
if response.status_code != 200: return
@@ -19,15 +26,20 @@ class ImmichConnector:
data = response.json()
return data["assets"]
- def load_image(self, pd, key, exif=None):
- response = self._request(f"assets/{key}/thumbnail?size=fullsize")
- if response.status_code != 200: return
+ def load_image(self, key, size="preview"):
+ response = self._request(f"assets/{key}/thumbnail?size={size}")
+ if response.status_code != 200: return None, None
image_data = BytesIO(response.content)
+ mimetype = response.headers.get("Content-Type")
+ return image_data, mimetype
+
+ def load_texture(self, pd, key, exif=None, size="preview"):
+ image_data, _ = self.load_image(key, size)
it = ImageTexture(image_data, exif)
pd.textures.append(it)
print(f"Loaded image {key}")
def idle(self, pd):
for asset in self.load_album_assets("bac029a5-972b-4519-bce0-a0d74add3969"):
- self.load_image(pd, asset["id"], asset["exifInfo"])
+ self.load_texture(pd, asset["id"], asset["exifInfo"])