diff --git a/gallery_dl/extractor/mangareader.py b/gallery_dl/extractor/mangareader.py index 57fd3efc..267966d1 100644 --- a/gallery_dl/extractor/mangareader.py +++ b/gallery_dl/extractor/mangareader.py @@ -11,16 +11,15 @@ from .common import AsynchronousExtractor, Message from .. import text import os.path -import re info = { "category": "mangareader", "extractor": "MangaReaderExtractor", - "directory": ["{category}", "{manga}", "c{chapter:>03}"], + "directory": ["{category}", "{manga}", "c{chapter:>03} - {title}"], "filename": "{manga}_c{chapter:>03}_{page:>03}.{extension}", "pattern": [ - r"(?:https?://)?(?:www\.)?mangareader\.net(/[^/]+/\d+).*", - r"(?:https?://)?(?:www\.)?mangareader\.net(/\d+-\d+-\d+/[^/]+/chapter-\d+.html)", + r"(?:https?://)?(?:www\.)?mangareader\.net((/[^/]+)/(\d+))", + r"(?:https?://)?(?:www\.)?mangareader\.net(/\d+-\d+-\d+(/[^/]+)/chapter-(\d+).html)", ], } @@ -30,25 +29,56 @@ class MangaReaderExtractor(AsynchronousExtractor): def __init__(self, match): AsynchronousExtractor.__init__(self) - self.part = match.group(1) + self.part, self.url_title, self.chapter = match.groups() def items(self): + page = self.request(self.url_base + self.part).text + data = self.get_job_metadata(page) yield Message.Version, 1 - url = self.url_base + self.part - while True: - url, image_url, data = self.get_page_metadata(url) - if url is None: - return - yield Message.Directory, data - yield Message.Url, image_url, data + yield Message.Directory, data + for i in range(1, int(data["count"])+1): + next_url, image_url, image_data = self.get_page_metadata(page) + image_data.update(data) + image_data["page"] = i + yield Message.Url, image_url, image_data + if next_url: + page = self.request(next_url).text - def get_page_metadata(self, page_url): + def get_job_metadata(self, chapter_page): + """Collect metadata for extractor-job""" + page = self.request(self.url_base + self.url_title).text + data = { + "category": info["category"], + "chapter": self.chapter, + "lang": "en", + "language": "English", + } + data, _ = text.extract_all(page, ( + (None, 'Name:', ''), + ("manga", '

', '

'), + (None, 'Year of Release:', ''), + ('manga-release', '', ''), + (None, 'Author:', ''), + ('author', '', ''), + (None, 'Artist:', ''), + ('artist', '', ''), + (None, '
', ''), + ('title', ' ' + self.chapter + ' : ', ''), + ('chapter-date', '', ''), + ), values=data) + data, _ = text.extract_all(chapter_page, ( + (None, '