merge #8925: [mangatown] add support
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -133,6 +133,7 @@ modules = [
|
||||
"mangaread",
|
||||
"mangareader",
|
||||
"mangataro",
|
||||
"mangatown",
|
||||
"mangoxo",
|
||||
"misskey",
|
||||
"motherless",
|
||||
|
||||
96
gallery_dl/extractor/mangatown.py
Normal file
96
gallery_dl/extractor/mangatown.py
Normal file
@@ -0,0 +1,96 @@
|
||||
# -*- 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.
|
||||
|
||||
"""Extractors for https://www.mangatown.com/"""
|
||||
|
||||
from .common import ChapterExtractor, MangaExtractor
|
||||
from .. import text
|
||||
|
||||
BASE_PATTERN = r"(?:https?://)?(?:www\.)?mangatown\.com"
|
||||
|
||||
|
||||
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 = 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 = f"{self.root}{self.part}/"
|
||||
ChapterExtractor.__init__(self, match, self.base + "1.html")
|
||||
|
||||
def metadata(self, page):
|
||||
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)
|
||||
|
||||
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 = BASE_PATTERN + 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]
|
||||
for ch in text.extract_iter(page, "<li>", "</li>"):
|
||||
path , pos = text.extract(ch, '<a href="', '"')
|
||||
title, pos = text.extract(ch, "<span>", "<", pos)
|
||||
date , pos = text.extract(ch, 'class="time">', "<", pos)
|
||||
|
||||
chapter = text.extr(path, "/c", "/")
|
||||
chapter, sep, minor = chapter.partition(".")
|
||||
|
||||
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
|
||||
@@ -128,6 +128,7 @@ CATEGORY_MAP = {
|
||||
"mangafox" : "Manga Fox",
|
||||
"mangahere" : "Manga Here",
|
||||
"mangakakalot" : "MangaKakalot",
|
||||
"mangatown" : "MangaTown",
|
||||
"manganato" : "MangaNato",
|
||||
"mangapark" : "MangaPark",
|
||||
"mangaread" : "MangaRead",
|
||||
|
||||
64
test/results/mangatown.py
Normal file
64
test/results/mangatown.py
Normal file
@@ -0,0 +1,64 @@
|
||||
# -*- 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/",
|
||||
"#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",
|
||||
"#class" : mangatown.MangatownChapterExtractor,
|
||||
"#pattern" : r"https://zjcdn\.mangahere\.org/.*",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "http://www.mangatown.com/manga/kimetsu_no_yaiba/c001/",
|
||||
"#class" : mangatown.MangatownChapterExtractor,
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.mangatown.com/manga/kimetsu_no_yaiba/",
|
||||
"#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/",
|
||||
"#class" : mangatown.MangatownMangaExtractor,
|
||||
},
|
||||
|
||||
)
|
||||
Reference in New Issue
Block a user