From 4d4e94fb9f913a72817285e1f8c64aebe99fdd68 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 30 Mar 2020 14:47:36 +0200 Subject: Detect when manganelo files are temporary unavailable --- plugins/manganelo.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'plugins/manganelo.py') 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: -- cgit v1.2.3