fix for immich api change
This commit is contained in:
parent
694db084ed
commit
6081c238a9
@ -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
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user