mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2025-12-23 23:55:05 +01:00
refactor: add url preloading before actual download
This commit is contained in:
@@ -29,6 +29,11 @@ class WebshotPlugin(Plugin):
|
|||||||
async def execute(self, function_name, **kwargs) -> Dict:
|
async def execute(self, function_name, **kwargs) -> Dict:
|
||||||
try:
|
try:
|
||||||
image_url = f'https://image.thum.io/get/maxAge/12/width/720/{kwargs["url"]}'
|
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)
|
response = requests.get(image_url, timeout=30)
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
|
|||||||
Reference in New Issue
Block a user