Browse Source

do proper handling of file paths

master
rra 2 years ago
parent
commit
c8e25c29ef
  1. 5
      event_feed.py

5
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)

Loading…
Cancel
Save