aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-07-08 08:05:15 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-08 08:05:15 +0200
commitd0e410f0251b251518357c95af0df5062b4f7fb9 (patch)
tree4bb13038676d89177bdf152b7c10f272b33cb297 /plugins
parent11a1fcddf045810ef0630df0d7cf43458e39ed90 (diff)
Mangadex: do not download same chapter by a different translator
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/mangadex.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/plugins/mangadex.py b/plugins/mangadex.py
index 29b0d31..08e85b5 100755
--- a/plugins/mangadex.py
+++ b/plugins/mangadex.py
@@ -53,6 +53,11 @@ def title_url_extract_manga_id(url):
def chapter_sort_func(chapter_data):
return chapter_data[1].get("timestamp", 0)
+def chapter_title_extract_number(chapter_title):
+ result = re.search("Ch. ([0-9]+)", chapter_title)
+ if result and len(result.groups()) > 0:
+ return result.groups()[0]
+
def list_chapters(url, chapter_list_input):
manga_id = title_url_extract_manga_id(url)
if not manga_id:
@@ -66,10 +71,14 @@ def list_chapters(url, chapter_list_input):
exit(2)
seen_titles = set()
+ seen_chapter_numbers = set()
for item in chapter_list_input:
title = item.get("title")
if title and len(title) > 0:
seen_titles.add(title.lower().replace(" ", ""))
+ chapter_number = chapter_title_extract_number(title)
+ if chapter_number:
+ seen_chapter_numbers.add(chapter_number)
seen_urls = set()
for item in chapter_list_input:
@@ -115,6 +124,9 @@ def list_chapters(url, chapter_list_input):
if chapter_title.lower().replace(" ", "") in seen_titles or chapter_url in seen_urls:
break
+ if chapter_number_str in seen_chapter_numbers:
+ break
+
output_chapters.append({ "name": chapter_name, "url": chapter_url })
print(json.dumps(output_chapters))