# -*- 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://mangaread.org/""" from .common import ChapterExtractor, MangaExtractor from .. import text, exception import re class MangareadBase(): """Base class for Mangaread extractors""" category = "mangaread" root = "https://www.mangaread.org" @staticmethod def parse_chapter_string(chapter_string, data): match = re.match( r"(?:(.+)\s*-\s*)?[Cc]hapter\s*(\d+)(\.\d+)?(?:\s*-\s*(.+))?", text.unescape(chapter_string).strip()) manga, chapter, minor, title = match.groups() manga = manga.strip() if manga else "" data["manga"] = data.pop("manga", manga) data["chapter"] = text.parse_int(chapter) data["chapter_minor"] = minor or "" data["title"] = title or "" data["lang"] = "en" data["language"] = "English" class MangareadChapterExtractor(MangareadBase, ChapterExtractor): """Extractor for manga-chapters from mangaread.org""" pattern = (r"(?:https?://)?(?:www\.)?mangaread\.org" r"(/manga/[^/?#]+/[^/?#]+)") example = "https://www.mangaread.org/manga/MANGA/chapter-01/" def metadata(self, page): tags = text.extr(page, 'class="wp-manga-tags-list">', '') data = {"tags": list(text.split_html(tags)[::2])} info = text.extr(page, '