From d45b090774556e6ddfd498a0b80a3f13f6d8ba1b Mon Sep 17 00:00:00 2001 From: UZQueen <157540577+HanaokaYuzu@users.noreply.github.com> Date: Sat, 25 May 2024 21:54:33 -0500 Subject: [PATCH] fix: return file path if `GeneratedImage.save()` succeeds --- src/gemini_webapi/types/image.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gemini_webapi/types/image.py b/src/gemini_webapi/types/image.py index 7c4cbc0..58196bd 100644 --- a/src/gemini_webapi/types/image.py +++ b/src/gemini_webapi/types/image.py @@ -136,7 +136,7 @@ def validate_cookies(cls, v: dict) -> dict: return v # @override - async def save(self, **kwargs) -> None: + async def save(self, **kwargs) -> str | None: """ Save the image to disk. @@ -147,8 +147,13 @@ async def save(self, **kwargs) -> None: And since the URL ends with a long hash, by default will use timestamp + end of the hash as the filename. kwargs: `dict`, optional Other arguments to pass to `Image.save`. + + Returns + ------- + `str | None` + Absolute path of the saved image if successfully saved. """ - await super().save( + return await super().save( filename=kwargs.pop("filename", None) or f"{datetime.now().strftime('%Y%m%d%H%M%S')}_{self.url[-10:]}.png", cookies=self.cookies,