Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/supportedsites.md
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,12 @@ Consider all listed sites to potentially be NSFW.
<td>Chapters, Manga</td>
<td></td>
</tr>
<tr id="mangatown" title="mangatown">
<td>MangaTown</td>
<td>https://www.mangatown.com/</td>
<td>Chapters, Manga</td>
<td></td>
</tr>
<tr id="mangoxo" title="mangoxo">
<td>Mangoxo</td>
<td>https://www.mangoxo.com/</td>
Expand Down
1 change: 1 addition & 0 deletions gallery_dl/extractor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"mangaread",
"mangareader",
"mangataro",
"mangatown",
"mangoxo",
"misskey",
"motherless",
Expand Down
100 changes: 100 additions & 0 deletions gallery_dl/extractor/mangatown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# -*- 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 = self.root + self.part + "/"
ChapterExtractor.__init__(self, match, self.base + "1.html")

def metadata(self, page):
manga, pos = text.extract(page, '<title>', '</title>')
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 = (text.extr(page, 'id="image" src="', '"') or
text.extr(page, '<img src="', '"'))
if not url:
return
yield text.ensure_http_scheme(url), None
pnum += 1
page = self.request(f"{self.base}{pnum}.html").text


class MangatownMangaExtractor(MangatownBase, MangaExtractor):
"""Extractor for manga from mangatown.com"""
chapterclass = MangatownChapterExtractor
pattern = (r"(?:https?://)?(?:www\.)?mangatown\.com"
r"(/manga/[^/?#]+)/?$")
example = "https://www.mangatown.com/manga/TITLE"

def chapters(self, page):
results = []

manga, pos = text.extract(page, '<title>', '</title>')
manga = manga.partition(" Manga")[0].replace("Read ", "", 1)
manga = text.unescape(manga)

page = text.extract(
page, 'class="chapter_list"', '</ul>', pos)[0]

pos = 0
while True:
url, pos = text.extract(page, '<a href="', '"', pos)
if not url:
return results
url = text.urljoin(self.root, url)
title, pos = text.extract(page, '>', '<', pos)
date , pos = text.extract(page, 'class="time"', '</span>', pos)
date = text.remove_html(date).strip()

results.append((url, {
"manga": manga,
"title": text.unescape(title),
"date": date,
"lang": "en",
"language": "English",
}))
1 change: 1 addition & 0 deletions scripts/supportedsites.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
"mangafox" : "Manga Fox",
"mangahere" : "Manga Here",
"mangakakalot" : "MangaKakalot",
"mangatown" : "MangaTown",
"manganato" : "MangaNato",
"mangapark" : "MangaPark",
"mangaread" : "MangaRead",
Expand Down
46 changes: 46 additions & 0 deletions test/results/mangatown.py
Original file line number Diff line number Diff line change
@@ -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,
},

)