diff --git a/event_feed.py b/event_feed.py index d11fb1c..d20c7a2 100644 --- a/event_feed.py +++ b/event_feed.py @@ -130,8 +130,8 @@ def create_event_post(post_dir, event): for img in event_metadata['images']: #parse img url to safe local image name - img_name = img.split('/')[-1] - fn, ext = img_name.split('.') + img_name = os.path.basename(img) + fn, ext = os.path.splitext(img_name) img_name = slugify(fn) + '.' + ext local_image = os.path.join(post_dir, img_name) @@ -142,6 +142,7 @@ def create_event_post(post_dir, event): with open(local_image, 'wb') as img_file: shutil.copyfileobj(response.raw, img_file) print('Downloaded image for event "{}"'.format(event.name)) + # TODO fix bug here event_metadata['description'] = event_metadata['description'].replace(img, '![]({})'.format(img_name)) if img_name in existing_images: existing_images.remove(img_name)