summaryrefslogtreecommitdiff
path: root/src/server/immich.py
diff options
context:
space:
mode:
authorTim Keller <tjk@tjkeller.xyz>2025-12-22 21:53:33 -0600
committerTim Keller <tjk@tjkeller.xyz>2025-12-22 21:53:33 -0600
commitf84408bbd4a4c53dc49589b7735aba905efcc848 (patch)
treefcf5921d91d03a985a09e31c913e0b67b69140d6 /src/server/immich.py
parent0822f9c93729d97cb355028f7c4d79ee4e542961 (diff)
downloadimmich-frame-0.4.1.tar.xz
immich-frame-0.4.1.zip
add sorting options with oldest-first as defaultv0.4.1
Diffstat (limited to 'src/server/immich.py')
-rw-r--r--src/server/immich.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/server/immich.py b/src/server/immich.py
index d5c5fd1..84aa7be 100644
--- a/src/server/immich.py
+++ b/src/server/immich.py
@@ -1,4 +1,5 @@
import requests
+import random
from io import BytesIO
from queue import Queue
@@ -32,6 +33,23 @@ class ImmichConnector:
data = response.json()
return data["assets"]
+ def load_albums_assets(self, keys):
+ config = PixMan().config
+
+ assets = []
+ for key in keys:
+ assets += self.load_album_assets(key)
+
+ if config.order == "newest-first" or config.order == "oldest-first":
+ # NOTE: asset.createdAt is a ISO 8601 date string, which are able to be sorted via python string sorting
+ assets_sorted = sorted(assets, key=lambda asset: asset["createdAt"], reverse=(config.order == "newest-first"))
+ elif config.order == "random":
+ assets_sorted = assets
+ random.shuffle(assets_sorted)
+
+ assert assets_sorted, f"Invalid config value for 'order': {config.order}"
+ return assets_sorted
+
def load_image(self, key, size="preview"):
response = self._request(f"assets/{key}/thumbnail?size={size}")
if not response or response.status_code != 200: return None, None
@@ -51,7 +69,8 @@ class ImmichConnector:
self.texture_load_queue.put((texture_list, image_texture))
def idle(self):
- size = "preview" # TODO
+ config = PixMan().config
+ size = config.display_size
while True:
texture_list, image_texture = self.texture_load_queue.get()
if not texture_list.index_in_cache_range(image_texture.asset_index) or texture_list.void: