From 4d8f61ad7678ce814848e044a2f8312a9edc6252 Mon Sep 17 00:00:00 2001 From: Duy Nguyen <7498938+nthduy@users.noreply.github.com> Date: Sun, 25 Jan 2026 00:02:36 +0100 Subject: [PATCH 1/4] [mangatown] add support --- gallery_dl/extractor/__init__.py | 1 + gallery_dl/extractor/mangatown.py | 101 ++++++++++++++++++++++++++++++ test/results/mangatown.py | 46 ++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 gallery_dl/extractor/mangatown.py create mode 100644 test/results/mangatown.py diff --git a/gallery_dl/extractor/__init__.py b/gallery_dl/extractor/__init__.py index b57d7517..4ec16766 100644 --- a/gallery_dl/extractor/__init__.py +++ b/gallery_dl/extractor/__init__.py @@ -133,6 +133,7 @@ modules = [ "mangaread", "mangareader", "mangataro", + "mangatown", "mangoxo", "misskey", "motherless", diff --git a/gallery_dl/extractor/mangatown.py b/gallery_dl/extractor/mangatown.py new file mode 100644 index 00000000..ea762c8d --- /dev/null +++ b/gallery_dl/extractor/mangatown.py @@ -0,0 +1,101 @@ +# -*- coding: utf-8 -*- + +# Copyright 2015-2025 Mike Fährmann +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. + +"""Extractors for https://www.mangatown.com/""" + +from .common import ChapterExtractor, MangaExtractor +from .. import text + + +class MangatownBase(): + """Base class for mangatown extractors""" + category = "mangatown" + root = "https://www.mangatown.com" + + +class MangatownChapterExtractor(MangatownBase, ChapterExtractor): + """Extractor for manga-chapters from mangatown.com""" + pattern = (r"(?:https?://)?(?:www\.)?mangatown\.com" + r"(/manga/[^/]+(?:/v0*(\d+))?/c(\d+[^/?#]*))") + example = "https://www.mangatown.com/manga/TITLE/c001/1.html" + + def __init__(self, match): + self.part, self.volume, self.chapter = match.groups() + self.base = f"{self.root}/manga/{self.part}/" + ChapterExtractor.__init__(self, match, self.base + "1.html") + + def metadata(self, page): + manga, pos = text.extract(page, '', '') + manga = manga.partition(" Manga")[0].replace("Read ", "", 1) + + count , pos = text.extract(page, "total_pages = ", ";", pos) + manga_id , pos = text.extract(page, "series_id = ", ";", pos) + chapter_id, pos = text.extract(page, "chapter_id = ", ";", pos) + + chapter, dot, minor = self.chapter.partition(".") + + return { + "manga": text.unescape(manga), + "manga_id": text.parse_int(manga_id), + "volume": text.parse_int(self.volume), + "chapter": text.parse_int(chapter), + "chapter_minor": dot + minor, + "chapter_id": text.parse_int(chapter_id), + "count": text.parse_int(count), + "lang": "en", + "language": "English", + } + + def images(self, page): + pnum = 1 + + while True: + url, pos = text.extract(page, 'id="image" src="', '"') + if not url: + url, pos = text.extract(page, '', '') + manga = manga.partition(" Manga")[0].replace("Read ", "", 1) + manga = text.unescape(manga) + + page = text.extract( + page, 'class="chapter_list"', '', pos)[0] + + pos = 0 + while True: + url, pos = text.extract(page, '', '<', pos) + date , pos = text.extract(page, 'class="time"', '', pos) + date = text.remove_html(date).strip() + + results.append((url, { + "manga": manga, + "title": text.unescape(title), + "date": date, + "lang": "en", + "language": "English", + })) diff --git a/test/results/mangatown.py b/test/results/mangatown.py new file mode 100644 index 00000000..f38ce835 --- /dev/null +++ b/test/results/mangatown.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. + +from gallery_dl.extractor import mangatown + + +__tests__ = ( +{ + "#url" : "https://www.mangatown.com/manga/kimetsu_no_yaiba/c001/", + "#category": ("", "mangatown", "chapter"), + "#class" : mangatown.MangatownChapterExtractor, + "#pattern" : r"https://zjcdn\.mangahere\.org/.*", + "#count" : ">= 20", +}, + +{ + "#url" : "https://www.mangatown.com/manga/kimetsu_no_yaiba/c001/1.html", + "#category": ("", "mangatown", "chapter"), + "#class" : mangatown.MangatownChapterExtractor, + "#pattern" : r"https://zjcdn\.mangahere\.org/.*", +}, + +{ + "#url" : "http://www.mangatown.com/manga/kimetsu_no_yaiba/c001/", + "#category": ("", "mangatown", "chapter"), + "#class" : mangatown.MangatownChapterExtractor, +}, + +{ + "#url" : "https://www.mangatown.com/manga/kimetsu_no_yaiba/", + "#category": ("", "mangatown", "manga"), + "#class" : mangatown.MangatownMangaExtractor, + "#pattern" : mangatown.MangatownChapterExtractor.pattern, + "#count" : ">= 100", +}, + +{ + "#url" : "http://www.mangatown.com/manga/kimetsu_no_yaiba/", + "#category": ("", "mangatown", "manga"), + "#class" : mangatown.MangatownMangaExtractor, +}, + +) From 9f2d5cbd5dcb7c79446be00f6b4c6f10bb5ce1c4 Mon Sep 17 00:00:00 2001 From: Duy Nguyen <7498938+nthduy@users.noreply.github.com> Date: Sun, 25 Jan 2026 00:04:23 +0100 Subject: [PATCH 2/4] docs: add mangatown to supported sites --- docs/supportedsites.md | 6 ++++++ scripts/supportedsites.py | 1 + 2 files changed, 7 insertions(+) diff --git a/docs/supportedsites.md b/docs/supportedsites.md index cebbc033..47820537 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -691,6 +691,12 @@ Consider all listed sites to potentially be NSFW. Chapters, Manga + + MangaTown + https://www.mangatown.com/ + Chapters, Manga + + Mangoxo https://www.mangoxo.com/ diff --git a/scripts/supportedsites.py b/scripts/supportedsites.py index 0f950c06..a731d171 100755 --- a/scripts/supportedsites.py +++ b/scripts/supportedsites.py @@ -128,6 +128,7 @@ CATEGORY_MAP = { "mangafox" : "Manga Fox", "mangahere" : "Manga Here", "mangakakalot" : "MangaKakalot", + "mangatown" : "MangaTown", "manganato" : "MangaNato", "mangapark" : "MangaPark", "mangaread" : "MangaRead", From befa9b8a3e0dff545cb099b897cdc978463fef44 Mon Sep 17 00:00:00 2001 From: Duy Nguyen <7498938+nthduy@users.noreply.github.com> Date: Sun, 25 Jan 2026 11:40:15 +0100 Subject: [PATCH 3/4] [mangatown] fix base url and simplify image extraction --- gallery_dl/extractor/mangatown.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gallery_dl/extractor/mangatown.py b/gallery_dl/extractor/mangatown.py index ea762c8d..046135ac 100644 --- a/gallery_dl/extractor/mangatown.py +++ b/gallery_dl/extractor/mangatown.py @@ -26,7 +26,7 @@ class MangatownChapterExtractor(MangatownBase, ChapterExtractor): def __init__(self, match): self.part, self.volume, self.chapter = match.groups() - self.base = f"{self.root}/manga/{self.part}/" + self.base = self.root + self.part + "/" ChapterExtractor.__init__(self, match, self.base + "1.html") def metadata(self, page): @@ -55,9 +55,8 @@ class MangatownChapterExtractor(MangatownBase, ChapterExtractor): pnum = 1 while True: - url, pos = text.extract(page, 'id="image" src="', '"') - if not url: - url, pos = text.extract(page, ' Date: Sun, 25 Jan 2026 18:32:17 +0100 Subject: [PATCH 4/4] [mangatown] fix & update - use BASE_PATTERN - fix manga, manga_id, chapter_id extraction - fix & extend 'manga' metadata results - extend test results --- gallery_dl/extractor/mangatown.py | 62 +++++++++++++++---------------- test/results/mangatown.py | 28 +++++++++++--- 2 files changed, 52 insertions(+), 38 deletions(-) diff --git a/gallery_dl/extractor/mangatown.py b/gallery_dl/extractor/mangatown.py index 046135ac..ccfd7551 100644 --- a/gallery_dl/extractor/mangatown.py +++ b/gallery_dl/extractor/mangatown.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2015-2025 Mike Fährmann -# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. @@ -11,6 +9,8 @@ from .common import ChapterExtractor, MangaExtractor from .. import text +BASE_PATTERN = r"(?:https?://)?(?:www\.)?mangatown\.com" + class MangatownBase(): """Base class for mangatown extractors""" @@ -20,34 +20,32 @@ class MangatownBase(): class MangatownChapterExtractor(MangatownBase, ChapterExtractor): """Extractor for manga-chapters from mangatown.com""" - pattern = (r"(?:https?://)?(?:www\.)?mangatown\.com" - r"(/manga/[^/]+(?:/v0*(\d+))?/c(\d+[^/?#]*))") + pattern = BASE_PATTERN + r"(/manga/[^/?#]+(?:/v0*(\d+))?/c(\d+[^/?#]*))" example = "https://www.mangatown.com/manga/TITLE/c001/1.html" def __init__(self, match): self.part, self.volume, self.chapter = match.groups() - self.base = self.root + self.part + "/" + self.base = f"{self.root}{self.part}/" ChapterExtractor.__init__(self, match, self.base + "1.html") def metadata(self, page): - manga, pos = text.extract(page, '', '') - manga = manga.partition(" Manga")[0].replace("Read ", "", 1) - + manga, pos = text.extract( + page, 'property="og:title" content="', '"') count , pos = text.extract(page, "total_pages = ", ";", pos) - manga_id , pos = text.extract(page, "series_id = ", ";", pos) - chapter_id, pos = text.extract(page, "chapter_id = ", ";", pos) + manga_id , pos = text.extract(page, "series_id=", ";", pos) + chapter_id, pos = text.extract(page, "chapter_id=", ";", pos) chapter, dot, minor = self.chapter.partition(".") return { - "manga": text.unescape(manga), + "manga" : text.unescape(manga), "manga_id": text.parse_int(manga_id), - "volume": text.parse_int(self.volume), - "chapter": text.parse_int(chapter), + "volume" : text.parse_int(self.volume), + "chapter" : text.parse_int(chapter), "chapter_minor": dot + minor, "chapter_id": text.parse_int(chapter_id), - "count": text.parse_int(count), - "lang": "en", + "count" : text.parse_int(count), + "lang" : "en", "language": "English", } @@ -67,8 +65,7 @@ class MangatownChapterExtractor(MangatownBase, ChapterExtractor): class MangatownMangaExtractor(MangatownBase, MangaExtractor): """Extractor for manga from mangatown.com""" chapterclass = MangatownChapterExtractor - pattern = (r"(?:https?://)?(?:www\.)?mangatown\.com" - r"(/manga/[^/?#]+)/?$") + pattern = BASE_PATTERN + r"(/manga/[^/?#]+)" example = "https://www.mangatown.com/manga/TITLE" def chapters(self, page): @@ -78,23 +75,22 @@ class MangatownMangaExtractor(MangatownBase, MangaExtractor): manga = manga.partition(" Manga")[0].replace("Read ", "", 1) manga = text.unescape(manga) - page = text.extract( - page, 'class="chapter_list"', '', pos)[0] + page = text.extract(page, 'class="chapter_list"', '', pos)[0] + for ch in text.extract_iter(page, "
  • ", "
  • "): + path , pos = text.extract(ch, '
    ", "<", pos) + date , pos = text.extract(ch, 'class="time">', "<", pos) - pos = 0 - while True: - url, pos = text.extract(page, '', '<', pos) - date , pos = text.extract(page, 'class="time"', '', pos) - date = text.remove_html(date).strip() + chapter = text.extr(path, "/c", "/") + chapter, sep, minor = chapter.partition(".") - results.append((url, { - "manga": manga, - "title": text.unescape(title), - "date": date, - "lang": "en", + results.append((self.root + path, { + "manga" : manga, + "chapter" : text.parse_int(chapter), + "chapter_minor": sep + minor, + "title" : "" if title is None else text.unescape(title), + "date" : date, + "lang" : "en", "language": "English", })) + return results diff --git a/test/results/mangatown.py b/test/results/mangatown.py index f38ce835..0bfece3d 100644 --- a/test/results/mangatown.py +++ b/test/results/mangatown.py @@ -10,36 +10,54 @@ from gallery_dl.extractor import mangatown __tests__ = ( { "#url" : "https://www.mangatown.com/manga/kimetsu_no_yaiba/c001/", - "#category": ("", "mangatown", "chapter"), "#class" : mangatown.MangatownChapterExtractor, "#pattern" : r"https://zjcdn\.mangahere\.org/.*", "#count" : ">= 20", + + "chapter" : 1, + "chapter_id" : 368511, + "chapter_minor": "", + "count" : 55, + "page" : range(1, 55), + "extension" : "jpg", + "filename" : str, + "lang" : "en", + "language" : "English", + "manga" : "Kimetsu no Yaiba", + "manga_id" : 21437, + "volume" : 0, + }, { "#url" : "https://www.mangatown.com/manga/kimetsu_no_yaiba/c001/1.html", - "#category": ("", "mangatown", "chapter"), "#class" : mangatown.MangatownChapterExtractor, "#pattern" : r"https://zjcdn\.mangahere\.org/.*", }, { "#url" : "http://www.mangatown.com/manga/kimetsu_no_yaiba/c001/", - "#category": ("", "mangatown", "chapter"), "#class" : mangatown.MangatownChapterExtractor, }, { "#url" : "https://www.mangatown.com/manga/kimetsu_no_yaiba/", - "#category": ("", "mangatown", "manga"), "#class" : mangatown.MangatownMangaExtractor, "#pattern" : mangatown.MangatownChapterExtractor.pattern, "#count" : ">= 100", + + "chapter" : int, + "chapter_minor": {"", ".5", ".6"}, + "date" : str, + "lang" : "en", + "language" : "English", + "manga" : "Kimetsu no Yaiba", + "title" : str, + }, { "#url" : "http://www.mangatown.com/manga/kimetsu_no_yaiba/", - "#category": ("", "mangatown", "manga"), "#class" : mangatown.MangatownMangaExtractor, },