replacing works, but remote url was used in stead of remote when there already was an image. Fixes #5

This commit is contained in:
rra 2021-09-23 20:09:44 +02:00
parent 611bea8f24
commit 17d7faac4d

View File

@ -98,7 +98,7 @@ def create_post(post_dir, entry):
with open(os.path.join(post_dir,'index.html'),'w') as f: #n.b. .html with open(os.path.join(post_dir,'index.html'),'w') as f: #n.b. .html
post = template.render(frontmatter=frontmatter, content=parsed_content) post = template.render(frontmatter=frontmatter, content=parsed_content)
f.write(post) f.write(post)
#print('created post for', entry.title, '({})'.format(entry.link)) print('created post for', entry.title, '({})'.format(entry.link))
def grab_media(post_directory, url): def grab_media(post_directory, url):
""" """
@ -117,6 +117,8 @@ def grab_media(post_directory, url):
print('Downloaded cover image', image) print('Downloaded cover image', image)
return image return image
return image return image
elif os.path.exists(os.path.join(post_directory, image)):
return image
except Exception as e: except Exception as e:
print('Failed to download cover image', url) print('Failed to download cover image', url)