From b998ef968f215e8f9af62c991aa03a182891a511 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 22 Dec 2023 13:50:45 -0500 Subject: [PATCH] feat: added get_exif method --- pyzipline/zipline.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pyzipline/zipline.py b/pyzipline/zipline.py index dd21f61..a8cce0a 100644 --- a/pyzipline/zipline.py +++ b/pyzipline/zipline.py @@ -162,6 +162,35 @@ class ZiplineApi: raise ValueError('username not provided') raise PyZiplineError(f"{result.status_code}: {result.message}\n{result.data}") + def get_exif(self, file_id: int) -> dict: + """Get the EXIF data for a file + + /// admonition | Requires Authentication + type: warning + /// + + Args: + file_id (int): ID of the file to get EXIF data for + + Raises: + Forbidden: The user is not authenticated + NotFound: The file does not exist + PyZiplineError: Raised if the API changes, causing a breaking change in this method + + Returns: + dict: EXIF data for the file + """ + result: Result = self._rest_adapter.get(endpoint="/exif", params={'id': file_id}) + if result.status_code == 200: + return result.data + if result.status_code == 401: + raise Forbidden(result.message) + if result.message == 'image not found': + raise NotFound(result.message) + if result.message == 'image not found on fs': + raise NotFound('image not found on filesystem') + raise PyZiplineError(f"{result.status_code}: {result.message}\n{result.data}") + def get_self(self) -> User: """Get the currently authenticated user