Fixed library downloading invalid images
This commit is contained in:
parent
517101d81e
commit
76427aea20
|
@ -90,6 +90,7 @@ def downloadImage(url, path, overwrite="n"):
|
||||||
if not os.path.isfile(path) or overwrite in ['y', 't']:
|
if not os.path.isfile(path) or overwrite in ['y', 't']:
|
||||||
try:
|
try:
|
||||||
image = get(url, headers={'User-Agent': USER_AGENT_HEADER}, timeout=30)
|
image = get(url, headers={'User-Agent': USER_AGENT_HEADER}, timeout=30)
|
||||||
|
image.raise_for_status()
|
||||||
with open(path, 'wb') as f:
|
with open(path, 'wb') as f:
|
||||||
f.write(image.content)
|
f.write(image.content)
|
||||||
return path
|
return path
|
||||||
|
|
Loading…
Reference in New Issue