From 9165039abfe4899ae9b42f5f4e89db1f0b9ab599 Mon Sep 17 00:00:00 2001 From: Norielle Cruz Date: Sat, 5 Aug 2023 06:57:31 +0800 Subject: [PATCH] refactor: add url preloading before actual download --- bot/plugins/webshot.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bot/plugins/webshot.py b/bot/plugins/webshot.py index 45e93ad..4684c3d 100644 --- a/bot/plugins/webshot.py +++ b/bot/plugins/webshot.py @@ -29,6 +29,11 @@ class WebshotPlugin(Plugin): async def execute(self, function_name, **kwargs) -> Dict: try: image_url = f'https://image.thum.io/get/maxAge/12/width/720/{kwargs["url"]}' + + # preload url first + requests.get(image_url) + + # download the actual image response = requests.get(image_url, timeout=30) if response.status_code == 200: