aboutsummaryrefslogtreecommitdiff
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
parent11a1fcddf045810ef0630df0d7cf43458e39ed90 (diff)
Mangadex: do not download same chapter by a different translator
-rwxr-xr-xautomedia.py5
-rwxr-xr-xplugins/mangadex.py12
2 files changed, 16 insertions, 1 deletions
diff --git a/automedia.py b/automedia.py
index 7b93df2..0dc42b7 100755
--- a/automedia.py
+++ b/automedia.py
@@ -253,7 +253,10 @@ def get_rss_from_episode_info(episode_name_raw, episode_info):
elif len(response) == 0 or response[0].lower() == 'y':
break
- return 'https://nyaa.si/?page=rss&q={}&c=0_0&f=0&u={}'.format(urllib.parse.quote(generic_name), group_name_escaped)
+ nyaa_rss = 'https://nyaa.si/?page=rss&q={}&c=0_0&f=0'.format(urllib.parse.quote(generic_name))
+ if not user_failed:
+ nyaa_rss += '&u={}'.format(group_name_escaped)
+ return nyaa_rss
def add_rss(name, url, rss_config_dir, start_after):
feed = feedparser.parse(url)
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))