# -*- coding: utf-8 -*- # Copyright 2015-2017 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://kissmanga.com/""" from .common import Extractor, Message from .. import text, cloudflare, aes import re import hashlib IV = [ 165, 232, 226, 233, 194, 114, 27, 224, 168, 74, 214, 96, 196, 114, 193, 243, ] class KissmangaExtractor(Extractor): """Base class for kissmanga extractors""" category = "kissmanga" directory_fmt = ["{category}", "{manga}", "c{chapter:>03}{chapter-minor} - {title}"] filename_fmt = ("{manga}_c{chapter:>03}{chapter-minor}_" "{page:>03}.{extension}") root = "http://kissmanga.com" def __init__(self, match): Extractor.__init__(self) self.url = match.group(0) self.session.headers["Referer"] = self.root request = cloudflare.request_func class KissmangaMangaExtractor(KissmangaExtractor): """Extractor for mangas from kissmanga.com""" subcategory = "manga" pattern = [r"(?:https?://)?(?:www\.)?kissmanga\.com/Manga/[^/]+/?$"] test = [("http://kissmanga.com/Manga/Dropout", { "url": "992befdd64e178fe5af67de53f8b510860d968ca", })] def items(self): yield Message.Version, 1 for chapter in self.get_chapters(): yield Message.Queue, self.root + 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, '