From 763792f207bac7afbba2f042e40ad5e96d06902f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 27 Nov 2015 16:19:21 +0100 Subject: [PATCH] [kissmanga] add manga-extractor --- gallery_dl/extractor/kissmanga.py | 33 ++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/gallery_dl/extractor/kissmanga.py b/gallery_dl/extractor/kissmanga.py index 4b1cad15..93caa84c 100644 --- a/gallery_dl/extractor/kissmanga.py +++ b/gallery_dl/extractor/kissmanga.py @@ -12,7 +12,38 @@ from .common import Extractor, Message from .. import text, cloudflare import re -class KissmangaExtractor(Extractor): +class KissmangaMangaExtractor(Extractor): + + category = "kissmanga" + directory_fmt = ["{category}", "{manga}", "c{chapter:>03}{chapter-minor} - {title}"] + filename_fmt = "{manga}_c{chapter:>03}{chapter-minor}_{page:>03}.{extension}" + pattern = [r"(?:https?://)?(?:www\.)?kissmanga\.com/Manga/[^/]+/?$"] + url_base = "http://kissmanga.com" + + def __init__(self, match): + Extractor.__init__(self) + self.url = match.group(0) + + def items(self): + cloudflare.bypass_ddos_protection(self.session, self.url_base) + yield Message.Version, 1 + for chapter in self.get_chapters(): + yield Message.Queue, self.url_base + chapter + + def get_chapters(self): + """Return a list of all chapter urls""" + page = self.request(self.url).text + pos = 0 + chapters = [] + while True: + url, pos = text.extract(page, '\n03}{chapter-minor} - {title}"]