Skip to content

Commit

Permalink
fix: return file path if GeneratedImage.save() succeeds
Browse files Browse the repository at this point in the history
  • Loading branch information
HanaokaYuzu committed May 26, 2024
1 parent b5388e2 commit d45b090
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/gemini_webapi/types/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down

0 comments on commit d45b090

Please sign in to comment.