aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xplugins/manganelo.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/manganelo.py b/plugins/manganelo.py
index e8e7efb..57ad6f5 100755
--- a/plugins/manganelo.py
+++ b/plugins/manganelo.py
@@ -31,12 +31,15 @@ if len(sys.argv) < 2:
usage()
def download_file(url, save_path):
+ file_size = 0
with requests.get(url, stream=True) as response:
response.raise_for_status()
with open(save_path, "wb") as file:
for chunk in response.iter_content(chunk_size=8192):
if chunk:
file.write(chunk)
+ file_size += len(chunk)
+ return file_size
def list_chapters(url, chapter_list_input):
response = requests.get(url)
@@ -83,7 +86,10 @@ def download_chapter(url, download_dir):
image_name = str(img_number) + ext
image_path = os.path.join(download_dir, image_name)
print("Downloading {} to {}".format(image_source, image_path))
- download_file(image_source, image_path)
+ file_size = download_file(image_source, image_path)
+ if file_size < 255:
+ print("resource temporary unavailable: %s" % image_source)
+ exit(2)
img_number += 1
with open(os.path.join(download_dir, ".finished"), "w") as file: