From 6f1afa9d76e9c2611a8025fb067d7ee14518dc18 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 20 Apr 2020 00:57:21 +0200 Subject: Remove in_progress file for manga if download fails --- plugins/manganelo.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'plugins/manganelo.py') diff --git a/plugins/manganelo.py b/plugins/manganelo.py index d8b5c9a..3cb3118 100755 --- a/plugins/manganelo.py +++ b/plugins/manganelo.py @@ -33,7 +33,8 @@ if len(sys.argv) < 2: def download_file(url, save_path): file_size = 0 with requests.get(url, stream=True) as response: - response.raise_for_status() + if not response.ok(): + return 0 with open(save_path, "wb") as file: for chunk in response.iter_content(chunk_size=8192): if chunk: @@ -89,11 +90,13 @@ def download_chapter(url, download_dir): file_size = download_file(image_source, image_path) if file_size < 255: print("resource temporary unavailable: %s" % image_source) + os.remove(in_progress_filepath) exit(2) img_number += 1 if img_number == 1: print("Failed to find images for chapter") + os.remove(in_progress_filepath) exit(2) with open(os.path.join(download_dir, ".finished"), "w") as file: -- cgit v1.2.3