2021-04-02 21:01:31 +02:00
|
|
|
# -*- 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.
|
|
|
|
|
2021-05-28 17:52:30 +02:00
|
|
|
"""Extractors for https://manganato.com/"""
|
2021-04-02 21:01:31 +02:00
|
|
|
|
|
|
|
from .common import ChapterExtractor, MangaExtractor
|
|
|
|
from .. import text
|
|
|
|
import re
|
|
|
|
|
2023-02-16 21:36:11 +01:00
|
|
|
BASE_PATTERN = r"(?:https?://)?((?:chap|read|www\.|m\.)?mangan(?:at|el)o\.com)"
|
2021-04-02 21:01:31 +02:00
|
|
|
|
|
|
|
|
2021-05-28 17:52:30 +02:00
|
|
|
class ManganeloChapterExtractor(ChapterExtractor):
|
2023-02-16 21:36:11 +01:00
|
|
|
"""Extractor for manga chapters from manganelo.com"""
|
2021-05-28 17:52:30 +02:00
|
|
|
category = "manganelo"
|
2022-10-24 14:18:48 +02:00
|
|
|
root = "https://chapmanganato.com"
|
2021-05-28 17:52:30 +02:00
|
|
|
pattern = BASE_PATTERN + r"(/(?:manga-\w+|chapter/\w+)/chapter[-_][^/?#]+)"
|
2021-04-02 21:01:31 +02:00
|
|
|
test = (
|
2022-10-24 14:18:48 +02:00
|
|
|
("https://chapmanganato.com/manga-gn983696/chapter-23", {
|
2022-07-12 15:46:51 +02:00
|
|
|
"pattern": r"https://v\d+\.mkklcdnv6tempv5\.com/img/tab_17/03/23"
|
|
|
|
r"/39/gn983696/vol_3_chapter_23_24_yen/\d+-[no]\.jpg",
|
|
|
|
"keyword": "2c5cd59342f149375df9bcb50aa416b4d04a43cf",
|
2021-04-02 21:01:31 +02:00
|
|
|
"count": 25,
|
|
|
|
}),
|
2023-02-15 00:02:28 +01:00
|
|
|
("https://chapmanganelo.com/manga-ti107776/chapter-4", {
|
|
|
|
"pattern": r"https://v\d+\.mkklcdnv6tempv5\.com/img/tab_17/01/92"
|
|
|
|
r"/08/ti970565/chapter_4_caster/\d+-o\.jpg",
|
|
|
|
"keyword": "16ac03503c920fb98490ad2c3621c27fddcb6c4b",
|
|
|
|
"count": 45,
|
|
|
|
}),
|
2022-10-24 14:18:48 +02:00
|
|
|
("https://readmanganato.com/manga-gn983696/chapter-23"),
|
2022-07-12 15:46:51 +02:00
|
|
|
("https://manganelo.com/chapter/gamers/chapter_15"),
|
2021-05-28 17:52:30 +02:00
|
|
|
("https://manganelo.com/chapter/gq921227/chapter_23"),
|
2021-04-02 21:01:31 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def __init__(self, match):
|
2021-05-28 17:52:30 +02:00
|
|
|
domain, path = match.groups()
|
|
|
|
ChapterExtractor.__init__(self, match, "https://" + domain + path)
|
2021-04-02 21:01:31 +02:00
|
|
|
self.session.headers['Referer'] = self.root
|
|
|
|
|
|
|
|
def metadata(self, page):
|
2023-02-15 00:02:28 +01:00
|
|
|
_ , pos = text.extract(page, 'class="a-h"', ">")
|
|
|
|
manga , pos = text.extract(page, 'title="', '"', pos)
|
|
|
|
info , pos = text.extract(page, 'title="', '"', pos)
|
2021-04-02 21:01:31 +02:00
|
|
|
author, pos = text.extract(page, '- Author(s) : ', '</p>', pos)
|
|
|
|
|
|
|
|
match = re.match(
|
|
|
|
r"(?:[Vv]ol\. *(\d+) )?"
|
|
|
|
r"[Cc]hapter *([^:]*)"
|
|
|
|
r"(?:: *(.+))?", info)
|
|
|
|
volume, chapter, title = match.groups() if match else ("", "", info)
|
|
|
|
chapter, sep, minor = chapter.partition(".")
|
|
|
|
|
|
|
|
return {
|
|
|
|
"manga" : text.unescape(manga),
|
|
|
|
"title" : text.unescape(title) if title else "",
|
|
|
|
"author" : text.unescape(author) if author else "",
|
|
|
|
"volume" : text.parse_int(volume),
|
|
|
|
"chapter" : text.parse_int(chapter),
|
|
|
|
"chapter_minor": sep + minor,
|
|
|
|
"lang" : "en",
|
|
|
|
"language" : "English",
|
|
|
|
}
|
|
|
|
|
|
|
|
def images(self, page):
|
2022-11-04 23:39:38 +01:00
|
|
|
page = text.extr(
|
|
|
|
page, 'class="container-chapter-reader', '\n<div')
|
2021-04-02 21:01:31 +02:00
|
|
|
return [
|
|
|
|
(url, None)
|
|
|
|
for url in text.extract_iter(page, '<img src="', '"')
|
2023-02-15 00:02:28 +01:00
|
|
|
] or [
|
|
|
|
(url, None)
|
|
|
|
for url in text.extract_iter(
|
|
|
|
page, '<img class="reader-content" src="', '"')
|
2021-04-02 21:01:31 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2021-05-28 17:52:30 +02:00
|
|
|
class ManganeloMangaExtractor(MangaExtractor):
|
2021-04-02 21:01:31 +02:00
|
|
|
"""Extractor for manga from manganelo.com"""
|
2021-05-28 17:52:30 +02:00
|
|
|
category = "manganelo"
|
2022-10-24 14:18:48 +02:00
|
|
|
root = "https://chapmanganato.com"
|
2021-04-02 21:01:31 +02:00
|
|
|
chapterclass = ManganeloChapterExtractor
|
2021-05-28 17:52:30 +02:00
|
|
|
pattern = BASE_PATTERN + r"(/(?:manga[-/]|read_)\w+)/?$"
|
2021-04-02 21:01:31 +02:00
|
|
|
test = (
|
2022-10-24 14:18:48 +02:00
|
|
|
("https://chapmanganato.com/manga-gn983696", {
|
2021-04-02 21:01:31 +02:00
|
|
|
"pattern": ManganeloChapterExtractor.pattern,
|
2022-07-12 15:46:51 +02:00
|
|
|
"count": ">= 25",
|
2021-04-02 21:01:31 +02:00
|
|
|
}),
|
2023-02-15 00:02:28 +01:00
|
|
|
("https://m.manganelo.com/manga-ti107776", {
|
|
|
|
"pattern": ManganeloChapterExtractor.pattern,
|
|
|
|
"count": ">= 12",
|
|
|
|
}),
|
2022-10-24 14:18:48 +02:00
|
|
|
("https://readmanganato.com/manga-gn983696"),
|
2022-07-12 15:46:51 +02:00
|
|
|
("https://manganelo.com/manga/read_otome_no_teikoku"),
|
2021-05-28 17:52:30 +02:00
|
|
|
("https://manganelo.com/manga/ol921234/"),
|
2021-04-02 21:01:31 +02:00
|
|
|
)
|
|
|
|
|
2021-05-28 17:52:30 +02:00
|
|
|
def __init__(self, match):
|
|
|
|
domain, path = match.groups()
|
|
|
|
MangaExtractor.__init__(self, match, "https://" + domain + path)
|
|
|
|
self.session.headers['Referer'] = self.root
|
|
|
|
|
2021-04-02 21:01:31 +02:00
|
|
|
def chapters(self, page):
|
|
|
|
results = []
|
|
|
|
data = self.parse_page(page, {"lang": "en", "language": "English"})
|
|
|
|
|
|
|
|
needle = 'class="chapter-name text-nowrap" href="'
|
2023-02-15 00:02:28 +01:00
|
|
|
pos = page.index('class="row-content-chapter')
|
2021-04-02 21:01:31 +02:00
|
|
|
while True:
|
|
|
|
url, pos = text.extract(page, needle, '"', pos)
|
|
|
|
if not url:
|
|
|
|
return results
|
|
|
|
data["title"], pos = text.extract(page, '>', '</a>', pos)
|
|
|
|
data["date"] , pos = text.extract(
|
|
|
|
page, 'class="chapter-time text-nowrap" title="', '">', pos)
|
|
|
|
chapter, sep, minor = url.rpartition("/chapter_")[2].partition(".")
|
|
|
|
data["chapter"] = text.parse_int(chapter)
|
|
|
|
data["chapter_minor"] = sep + minor
|
|
|
|
results.append((url, data.copy()))
|
2021-05-28 17:52:30 +02:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def parse_page(page, data):
|
|
|
|
"""Parse metadata on 'page' and add it to 'data'"""
|
|
|
|
text.extract_all(page, (
|
|
|
|
("manga" , '<h1>', '</h1>'),
|
|
|
|
('author' , '</i>Author(s) :</td>', '</tr>'),
|
|
|
|
), values=data)
|
|
|
|
data["author"] = text.remove_html(data["author"])
|
|
|
|
return data
|