handle feeds with enclosures (featured media / podcasts) #35
@ -206,6 +206,9 @@ def grab_media(post_directory, url, prefered_name=None):
|
||||
shutil.copyfileobj(response.raw, media_file)
|
||||
print('Downloaded media item', media_item)
|
||||
return media_item
|
||||
else:
|
||||
print("Download failed", response.status_code)
|
||||
return url
|
||||
return media_item
|
||||
elif os.path.exists(os.path.join(post_directory, media_item)):
|
||||
return media_item
|
||||
@ -227,7 +230,6 @@ def parse_posts(post_dir, post_content):
|
||||
|
||||
for img in soup(["img", "object"]):
|
||||
if img.get("src") != None:
|
||||
|
||||
local_image = grab_media(post_dir, img["src"])
|
||||
if img["src"] != local_image:
|
||||
img["src"] = local_image
|
||||
|
Loading…
Reference in New Issue
Block a user