forked from ruangrupa/konfluks
cal: check if image exists before downloading
This commit is contained in:
parent
1fe2fa3bcf
commit
3297991d83
@ -146,12 +146,13 @@ def create_event_post(post_dir, event):
|
||||
if not os.path.exists(local_image):
|
||||
# download preview image
|
||||
response = requests.get(img, stream=True)
|
||||
with open(local_image, "wb") as img_file:
|
||||
shutil.copyfileobj(response.raw, img_file)
|
||||
print('Downloaded image for event "{}"'.format(event.name))
|
||||
event_metadata["description"] = event_metadata["description"].replace(
|
||||
img, "![]({})".format(img_name)
|
||||
)
|
||||
if response.status_code == 200:
|
||||
with open(local_image, "wb") as img_file:
|
||||
shutil.copyfileobj(response.raw, img_file)
|
||||
print('Downloaded image for event "{}"'.format(event.name))
|
||||
event_metadata["description"] = event_metadata["description"].replace(
|
||||
img, "![]({})".format(img_name)
|
||||
)
|
||||
if img_name in existing_images:
|
||||
existing_images.remove(img_name)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user