Added image placeholder if cant retrieve it

This commit is contained in:
Joan
2023-06-28 13:26:31 +02:00
parent a40f55ca4e
commit 243d0ba749
3 changed files with 11 additions and 5 deletions

View File

@@ -21,10 +21,13 @@ def add_product(tg_user, tg_group, tg_user_id, tg_group_id, url, referurl, title
con.commit()
con.close()
response = requests.get(image, headers=constants.HEADERS)
file = open(f"/app/data/images/products/{product_id}.jpg", "wb")
file.write(response.content)
file.close()
try:
response = requests.get(image, headers=constants.HEADERS)
file = open(f"/app/data/images/products/{product_id}.jpg", "wb")
file.write(response.content)
file.close()
except:
pass
return product_id