From d324c5803806e208b8102ce30da5b35a5acc3d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 17 Sep 2016 18:12:37 +0200 Subject: [PATCH] [rule34] add tag- and image-extractor --- gallery_dl/extractor/__init__.py | 1 + gallery_dl/extractor/rule34.py | 45 +++++++++++++++++++++++++++++++ gallery_dl/extractor/safebooru.py | 1 - 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 gallery_dl/extractor/rule34.py diff --git a/gallery_dl/extractor/__init__.py b/gallery_dl/extractor/__init__.py index 2ba67bc8..d57d965a 100644 --- a/gallery_dl/extractor/__init__.py +++ b/gallery_dl/extractor/__init__.py @@ -54,6 +54,7 @@ modules = [ "nijie", "pinterest", "powermanga", + "rule34", "safebooru", "sankaku", "seiga", diff --git a/gallery_dl/extractor/rule34.py b/gallery_dl/extractor/rule34.py new file mode 100644 index 00000000..f6e21ac9 --- /dev/null +++ b/gallery_dl/extractor/rule34.py @@ -0,0 +1,45 @@ +# -*- 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 images from https://rule34.xxx/""" + +from . import booru + +class Rule34Extractor(booru.XMLBooruExtractor): + """Base class for rule34 extractors""" + category = "rule34" + api_url = "https://rule34.xxx/index.php" + + def setup(self): + self.params.update({"page":"dapi", "s":"post", "q":"index"}) + + def update_page(self, reset=False): + if reset is False: + self.params["pid"] += 1 + else: + self.params["pid"] = 0 + +class Rule34TagExtractor(Rule34Extractor, booru.BooruTagExtractor): + """Extractor for images from rule34.xxx based on search-tags""" + subcategory = "tag" + pattern = [(r"(?:https?://)?(?:www\.)?rule34\.xxx/(?:index\.php)?" + r"\?page=post&s=list&tags=([^&]+)")] + test = [("http://rule34.xxx/index.php?page=post&s=list&tags=danraku", { + "url": "104094495973edfe7e764c8f2dd42017163322aa", + "content": "a01768c6f86f32eb7ebbdeb87c30b0d9968d7f97", + })] + +class Rule34PostExtractor(Rule34Extractor, booru.BooruPostExtractor): + """Extractor for single images from rule34.xxx""" + subcategory = "post" + pattern = [(r"(?:https?://)?(?:www\.)?rule34\.xxx/(?:index\.php)?" + r"\?page=post&s=view&id=(\d+)")] + test = [("http://rule34.xxx/index.php?page=post&s=view&id=1974854", { + "url": "3b1f9817785868d1cd94d5376d20478eed591965", + "content": "fd2820df78fb937532da0a46f7af6cefc4dc94be", + })] diff --git a/gallery_dl/extractor/safebooru.py b/gallery_dl/extractor/safebooru.py index 8248181c..cf9e160c 100644 --- a/gallery_dl/extractor/safebooru.py +++ b/gallery_dl/extractor/safebooru.py @@ -12,7 +12,6 @@ from . import booru class SafebooruExtractor(booru.XMLBooruExtractor): """Base class for safebooru extractors""" - category = "safebooru" api_url = "http://safebooru.org/index.php"