aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)