From b634ace39e62c78aa79adaebdbd40ac6d26a9b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 14 Nov 2016 18:29:45 +0100 Subject: [PATCH] [readcomiconline] add comic-issue and comic extractor --- README.rst | 2 + gallery_dl/cloudflare.py | 3 +- gallery_dl/extractor/__init__.py | 1 + gallery_dl/extractor/readcomiconline.py | 65 +++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 gallery_dl/extractor/readcomiconline.py diff --git a/README.rst b/README.rst index c560637c..c1a90ebd 100644 --- a/README.rst +++ b/README.rst @@ -52,6 +52,8 @@ Supported Sites mangahere.co, mangamint.com, mangapanda.com, mangapark.me, mangareader.net, mangashare.com, mangastream.com, powermanga.org, raw.senmanga.com, reader.sensescans.com, thespectrum.net +* Comic: + readcomiconline.to * Hentai: exhentai.org, hbrowse.com, hentai2read.com, hentaibox.net, hentaihere.com, hitomi.la, luscious.net, nhentai.net diff --git a/gallery_dl/cloudflare.py b/gallery_dl/cloudflare.py index 962f4177..a1ee9c77 100644 --- a/gallery_dl/cloudflare.py +++ b/gallery_dl/cloudflare.py @@ -19,7 +19,8 @@ def bypass_ddos_protection(session, url): session.cookies = solve_challenge(session, url) return session -@cache(maxage=24*60*60, keyarg=1) +# TODO: this is only a temporary workaround for readcomiconline.to +@cache(maxage=30*60, keyarg=1) def solve_challenge(session, url): session.headers["Referer"] = url page = session.get(url).text diff --git a/gallery_dl/extractor/__init__.py b/gallery_dl/extractor/__init__.py index fee5bfaf..3ca22311 100644 --- a/gallery_dl/extractor/__init__.py +++ b/gallery_dl/extractor/__init__.py @@ -50,6 +50,7 @@ modules = [ "nijie", "pinterest", "powermanga", + "readcomiconline", "rule34", "safebooru", "sankaku", diff --git a/gallery_dl/extractor/readcomiconline.py b/gallery_dl/extractor/readcomiconline.py new file mode 100644 index 00000000..29413e9a --- /dev/null +++ b/gallery_dl/extractor/readcomiconline.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- + +# Copyright 2016 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 comic-issues and entire comics from http://readcomiconline.to/""" + +from .common import Extractor +from .. import text +from . import kissmanga +import re + +class ReadcomiconlineExtractor(Extractor): + """Base class for readcomiconline extractors""" + category = "readcomiconline" + directory_fmt = ["{category}", "{comic}", "{issue:>03}"] + filename_fmt = "{comic}_{issue:>03}_{page:>03}.{extension}" + url_base = "http://readcomiconline.to" + + def __init__(self, match): + Extractor.__init__(self) + self.url = match.group(0) + + +class ReadcomiconlineComicExtractor(ReadcomiconlineExtractor, + kissmanga.KissmangaMangaExtractor): + """Extractor for comics from readcomiconline.to""" + subcategory = "comic" + pattern = [r"(?:https?://)?(?:www\.)?readcomiconline\.to/Comic/[^/]+/?$"] + test = [("http://readcomiconline.to/Comic/W-i-t-c-h", { + "url": "c5a530538a30b176916e30cbe223a93d83cb2691", + })] + + def get_chapters(self): + """Return a list of all chapter urls""" + page = self.request(self.url).text + return reversed(list( + text.extract_iter(page, '