# -*- coding: utf-8 -*- # Copyright 2015 Mike Fährmann # # 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. """Extract manga-chapters and entire manga from http://www.mangashare.com/""" from .common import Extractor, AsynchronousExtractor, Message from .. import text class MangaShareMangaExtractor(Extractor): """Extract all manga-chapters from mangashare""" category = "mangashare" subcategory = "manga" pattern = [r"(?:https?://)?read\.mangashare\.com/[^/]+$"] test = [("http://read.mangashare.com/Gantz", { "url": "c3b9153d99200ddd2fae0194dad903ccb815e9e7", })] def __init__(self, match): Extractor.__init__(self) self.url = match.group(0) def items(self): yield Message.Version, 1 for chapter in self.get_chapters(): yield Message.Queue, chapter def get_chapters(self): """Return a list of all chapter urls""" page = self.request(self.url).text return reversed(list( text.extract_iter(page, '