aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-06-07 07:58:35 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:12:34 +0200
commit40724c99dcdc86d0465af3337a7299477860a846 (patch)
tree426db51e89d70f446a6d5aae9147aca5b1b02321 /plugins
parent593c3d68dc4247f5bc56186cfb7215f1dc6d7ead (diff)
mangatown: fail if one image failed to download
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/mangatown.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/plugins/mangatown.py b/plugins/mangatown.py
index 2ee739b..7092f9d 100755
--- a/plugins/mangatown.py
+++ b/plugins/mangatown.py
@@ -101,6 +101,15 @@ def download_chapter(url, download_dir):
with open(in_progress_filepath, "w") as file:
file.write(url)
+ tree = etree.HTML(response.text)
+ num_pages = 0
+ for element in tree.xpath('//div[@class="page_select"]//option'):
+ value = element.attrib.get("value", "")
+ if "/manga/" in value and is_only_num(element.text):
+ num_pages += 1
+
+ num_pages /= 2
+
img_number = 1
while True:
full_url = url + str(img_number) + ".html"
@@ -124,8 +133,8 @@ def download_chapter(url, download_dir):
exit(2)
img_number += 1
- if img_number == 1:
- print("Failed to find images for chapter")
+ if img_number - 1 != num_pages:
+ print("Failed to find images for chapter. Expected %d images, got %d" % (img_number - 1, num_pages))
os.remove(in_progress_filepath)
exit(2)