From 6081c238a9eb1359cf806c7f06ddb3658339f074 Mon Sep 17 00:00:00 2001
From: Remy Moll <me@moll.re>
Date: Wed, 4 Sep 2024 21:46:30 +0200
Subject: [PATCH] fix for immich api change

---
 src/get/immich.py   | 7 ++++---
 src/get/template.py | 8 ++++----
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/get/immich.py b/src/get/immich.py
index 30e4f0c..0c80eed 100644
--- a/src/get/immich.py
+++ b/src/get/immich.py
@@ -46,11 +46,12 @@ class ImageGetImmich(ImageGet):
 
 
     def get_image_file(self, image_id: str) -> bytearray:
-        url = self.base_url + "download/asset/" + image_id
+        url = self.base_url + f"assets/{image_id}/original"
+        print(url)
 
         headers = self.headers | {"Accept": "application/octet-stream"}
-        response = h.request("POST", url, headers=headers, data={})
+        response = h.request("GET", url, headers=headers, data={})
         if not response.status_code == 200:
-            raise ImageGetException("Error in step get_image_file: " + str(response.status_code))
+            raise ImageGetException(f"Error in step get_image_file: {response.status_code}" )
             
         return response.content
diff --git a/src/get/template.py b/src/get/template.py
index f8c5ab5..3542c49 100644
--- a/src/get/template.py
+++ b/src/get/template.py
@@ -25,8 +25,8 @@ class ImageGet:
             id = self.get_random_image_ids()[0]
             bytes = self.get_image_file(id)
             self.save_cached_files()
-        except (h.ConnectError, h.HTTPStatusError, h.NetworkError, h.RequestError, h.DecodingError, h.TransportError, ImageGetException):
-            print("Loading image from cache")
+        except (h.ConnectError, h.HTTPStatusError, h.NetworkError, h.RequestError, h.DecodingError, h.TransportError, ImageGetException) as e:
+            print(f"Encoutered {e}, loading image from cache")
             bytes = self.load_cached_file()
 
         return bytes
@@ -46,8 +46,8 @@ class ImageGet:
             new_cache = self.cache_dir / f"{uuid.uuid4()}"
             try:
                 new_cache.write_bytes(self.get_image_file(id))
-            except ImageGetException:
-                print("Could not cache image, skipping")
+            except ImageGetException as e:
+                print(f"Could not cache image, skipping ({e})")
                 continue
 
     def load_cached_file(self) -> bytearray: