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
|
|
|
|
|
2024-01-01 22:05:21 +01:00
|
|
|
BASE_PATTERN = (
|
|
|
|
r"(?:https?://)?"
|
|
|
|
r"((?:chap|read|www\.|m\.)?mangan(?:at|el)o"
|
|
|
|
r"\.(?:to|com))"
|
|
|
|
)
|
2021-04-02 21:01:31 +02:00
|
|
|
|
|
|
|
|
2023-02-16 22:31:18 +01:00
|
|
|
class ManganeloBase():
|
2021-05-28 17:52:30 +02:00
|
|
|
category = "manganelo"
|
2022-10-24 14:18:48 +02:00
|
|
|
root = "https://chapmanganato.com"
|
2023-04-27 13:12:11 +02:00
|
|
|
_match_chapter = None
|
2023-02-16 22:31:18 +01:00
|
|
|
|
|
|
|
def __init__(self, match):
|
|
|
|
domain, path = match.groups()
|
|
|
|
super().__init__(match, "https://" + domain + path)
|
2023-07-25 20:09:44 +02:00
|
|
|
|
|
|
|
def _init(self):
|
2023-04-27 13:12:11 +02:00
|
|
|
if self._match_chapter is None:
|
|
|
|
ManganeloBase._match_chapter = re.compile(
|
|
|
|
r"(?:[Vv]ol\.?\s*(\d+)\s?)?"
|
|
|
|
r"[Cc]hapter\s*(\d+)([^:]*)"
|
|
|
|
r"(?::\s*(.+))?").match
|
2023-02-16 22:31:18 +01:00
|
|
|
|
|
|
|
def _parse_chapter(self, info, manga, author, date=None):
|
|
|
|
match = self._match_chapter(info)
|
2023-04-27 13:12:11 +02:00
|
|
|
if match:
|
|
|
|
volume, chapter, minor, title = match.groups()
|
|
|
|
else:
|
|
|
|
volume = chapter = minor = ""
|
|
|
|
title = info
|
2023-02-16 22:31:18 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
"manga" : manga,
|
|
|
|
"author" : author,
|
|
|
|
"date" : date,
|
|
|
|
"title" : text.unescape(title) if title else "",
|
|
|
|
"volume" : text.parse_int(volume),
|
|
|
|
"chapter" : text.parse_int(chapter),
|
2023-04-27 13:12:11 +02:00
|
|
|
"chapter_minor": minor,
|
2023-02-16 22:31:18 +01:00
|
|
|
"lang" : "en",
|
|
|
|
"language" : "English",
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class ManganeloChapterExtractor(ManganeloBase, ChapterExtractor):
|
|
|
|
"""Extractor for manga chapters from manganelo.com"""
|
2021-05-28 17:52:30 +02:00
|
|
|
pattern = BASE_PATTERN + r"(/(?:manga-\w+|chapter/\w+)/chapter[-_][^/?#]+)"
|
2023-09-11 16:30:55 +02:00
|
|
|
example = "https://chapmanganato.com/manga-ID/chapter-01"
|
2021-04-02 21:01:31 +02:00
|
|
|
|
|
|
|
def metadata(self, page):
|
2023-02-16 22:31:18 +01:00
|
|
|
extr = text.extract_from(page)
|
|
|
|
extr('class="a-h"', ">")
|
|
|
|
manga = extr('title="', '"')
|
|
|
|
info = extr('title="', '"')
|
|
|
|
author = extr("- Author(s) : ", "</p>")
|
2021-04-02 21:01:31 +02:00
|
|
|
|
2023-02-16 22:31:18 +01:00
|
|
|
return self._parse_chapter(
|
|
|
|
info, text.unescape(manga), text.unescape(author))
|
2021-04-02 21:01:31 +02:00
|
|
|
|
|
|
|
def images(self, page):
|
2022-11-04 23:39:38 +01:00
|
|
|
page = text.extr(
|
2024-01-01 22:05:21 +01:00
|
|
|
page, 'class="container-chapter-reader', 'class="container')
|
2021-04-02 21:01:31 +02:00
|
|
|
return [
|
|
|
|
(url, None)
|
|
|
|
for url in text.extract_iter(page, '<img src="', '"')
|
2024-01-01 22:05:21 +01:00
|
|
|
if not url.endswith("/gohome.png")
|
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
|
|
|
]
|
|
|
|
|
|
|
|
|
2023-02-16 22:31:18 +01:00
|
|
|
class ManganeloMangaExtractor(ManganeloBase, MangaExtractor):
|
2021-04-02 21:01:31 +02:00
|
|
|
"""Extractor for manga from manganelo.com"""
|
|
|
|
chapterclass = ManganeloChapterExtractor
|
2021-05-28 17:52:30 +02:00
|
|
|
pattern = BASE_PATTERN + r"(/(?:manga[-/]|read_)\w+)/?$"
|
2023-09-11 16:30:55 +02:00
|
|
|
example = "https://manganato.com/manga-ID"
|
2021-04-02 21:01:31 +02:00
|
|
|
|
|
|
|
def chapters(self, page):
|
|
|
|
results = []
|
2023-02-16 22:31:18 +01:00
|
|
|
append = results.append
|
|
|
|
|
|
|
|
extr = text.extract_from(page)
|
|
|
|
manga = text.unescape(extr("<h1>", "<"))
|
|
|
|
author = text.remove_html(extr("</i>Author(s) :</td>", "</tr>"))
|
2021-04-02 21:01:31 +02:00
|
|
|
|
2023-02-16 22:31:18 +01:00
|
|
|
extr('class="row-content-chapter', '')
|
2021-04-02 21:01:31 +02:00
|
|
|
while True:
|
2023-02-16 22:31:18 +01:00
|
|
|
url = extr('class="chapter-name text-nowrap" href="', '"')
|
2021-04-02 21:01:31 +02:00
|
|
|
if not url:
|
|
|
|
return results
|
2023-02-16 22:31:18 +01:00
|
|
|
info = extr(">", "<")
|
|
|
|
date = extr('class="chapter-time text-nowrap" title="', '"')
|
|
|
|
append((url, self._parse_chapter(info, manga, author, date)))
|