forked from ruangrupa/konfluks
cal: check if image exists before downloading
This commit is contained in:
parent
1fe2fa3bcf
commit
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))
|
||||||
|
Loading…
Reference in New Issue
Block a user