Merge pull request #173 from spacewander/fix-download-image-failed

Don't try to write down the image file if download failed
This commit is contained in:
Lorenzo Di Fuccia 2020-04-02 22:02:54 +02:00 • committed by GitHub
commit ba29ef43cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

1
safaribooks.py Normal file → Executable file
View file

@ -854,6 +854,7 @@ class SafariBooks:
response = self.requests_provider(urljoin(SAFARI_BASE_URL, url), stream=True)
if response == 0:
self.display.error("Error trying to retrieve this image: %s\n From: %s" % (image_name, url))
return
with open(image_path, 'wb') as img:
for chunk in response.iter_content(1024):