fix for immich api change

This commit is contained in:
Remy Moll 2024-09-04 21:46:30 +02:00
parent 694db084ed
commit 6081c238a9
2 changed files with 8 additions and 7 deletions

View File

@ -46,11 +46,12 @@ class ImageGetImmich(ImageGet):
def get_image_file(self, image_id: str) -> bytearray: 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"} 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: 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 return response.content

View File

@ -25,8 +25,8 @@ class ImageGet:
id = self.get_random_image_ids()[0] id = self.get_random_image_ids()[0]
bytes = self.get_image_file(id) bytes = self.get_image_file(id)
self.save_cached_files() self.save_cached_files()
except (h.ConnectError, h.HTTPStatusError, h.NetworkError, h.RequestError, h.DecodingError, h.TransportError, ImageGetException): except (h.ConnectError, h.HTTPStatusError, h.NetworkError, h.RequestError, h.DecodingError, h.TransportError, ImageGetException) as e:
print("Loading image from cache") print(f"Encoutered {e}, loading image from cache")
bytes = self.load_cached_file() bytes = self.load_cached_file()
return bytes return bytes
@ -46,8 +46,8 @@ class ImageGet:
new_cache = self.cache_dir / f"{uuid.uuid4()}" new_cache = self.cache_dir / f"{uuid.uuid4()}"
try: try:
new_cache.write_bytes(self.get_image_file(id)) new_cache.write_bytes(self.get_image_file(id))
except ImageGetException: except ImageGetException as e:
print("Could not cache image, skipping") print(f"Could not cache image, skipping ({e})")
continue continue
def load_cached_file(self) -> bytearray: def load_cached_file(self) -> bytearray: