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):
|
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)
|
||||||
with open(local_image, "wb") as img_file:
|
if response.status_code == 200:
|
||||||
shutil.copyfileobj(response.raw, img_file)
|
with open(local_image, "wb") as img_file:
|
||||||
print('Downloaded image for event "{}"'.format(event.name))
|
shutil.copyfileobj(response.raw, img_file)
|
||||||
event_metadata["description"] = event_metadata["description"].replace(
|
print('Downloaded image for event "{}"'.format(event.name))
|
||||||
img, "![]({})".format(img_name)
|
event_metadata["description"] = event_metadata["description"].replace(
|
||||||
)
|
img, "![]({})".format(img_name)
|
||||||
|
)
|
||||||
if img_name in existing_images:
|
if img_name in existing_images:
|
||||||
existing_images.remove(img_name)
|
existing_images.remove(img_name)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user