forked from ruangrupa/konfluks
add reason for failure
This commit is contained in:
parent
fecf5cd64e
commit
c84a975887
@ -206,6 +206,9 @@ def grab_media(post_directory, url, prefered_name=None):
|
|||||||
shutil.copyfileobj(response.raw, media_file)
|
shutil.copyfileobj(response.raw, media_file)
|
||||||
print('Downloaded media item', media_item)
|
print('Downloaded media item', media_item)
|
||||||
return media_item
|
return media_item
|
||||||
|
else:
|
||||||
|
print("Download failed", response.status_code)
|
||||||
|
return url
|
||||||
return media_item
|
return media_item
|
||||||
elif os.path.exists(os.path.join(post_directory, media_item)):
|
elif os.path.exists(os.path.join(post_directory, media_item)):
|
||||||
return media_item
|
return media_item
|
||||||
@ -227,7 +230,6 @@ def parse_posts(post_dir, post_content):
|
|||||||
|
|
||||||
for img in soup(["img", "object"]):
|
for img in soup(["img", "object"]):
|
||||||
if img.get("src") != None:
|
if img.get("src") != None:
|
||||||
|
|
||||||
local_image = grab_media(post_dir, img["src"])
|
local_image = grab_media(post_dir, img["src"])
|
||||||
if img["src"] != local_image:
|
if img["src"] != local_image:
|
||||||
img["src"] = local_image
|
img["src"] = local_image
|
||||||
|
Loading…
Reference in New Issue
Block a user