cal: check if image exists before downloading

此提交包含在:
2022-02-03 12:34:24 +01:00
提交者 Gitea
父節點 1fe2fa3bcf
當前提交 3297991d83

查看文件

@ -146,6 +146,7 @@ def create_event_post(post_dir, event):
if not os.path.exists(local_image): if not os.path.exists(local_image):
# download preview image # download preview image
response = requests.get(img, stream=True) response = requests.get(img, stream=True)
if response.status_code == 200:
with open(local_image, "wb") as img_file: with open(local_image, "wb") as img_file:
shutil.copyfileobj(response.raw, img_file) shutil.copyfileobj(response.raw, img_file)
print('Downloaded image for event "{}"'.format(event.name)) print('Downloaded image for event "{}"'.format(event.name))