aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-03-30 14:47:36 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:12:34 +0200
commit4d4e94fb9f913a72817285e1f8c64aebe99fdd68 (patch)
tree7c61e9c1772c74a06456e8b7ee3c7e4fa9a6ab89 /plugins
parentf5d02c8e76663a5e4dd63e752d06f55737841668 (diff)
Detect when manganelo files are temporary unavailable
Diffstat (limited to 'plugins')
-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: