refactor: add url preloading before actual download

This commit is contained in:
Norielle Cruz
2023-08-05 06:57:31 +08:00
committed by GitHub
parent 72da699ac7
commit 9165039abf

View File

@@ -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: