2016-09-17 18:12:37 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-02-08 13:45:40 +01:00
|
|
|
# Copyright 2016-2019 Mike Fährmann
|
2016-09-17 18:12:37 +02:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2018-01-03 23:52:01 +01:00
|
|
|
class Rule34Extractor(booru.XmlParserMixin,
|
|
|
|
booru.GelbooruPageMixin,
|
|
|
|
booru.BooruExtractor):
|
2016-09-17 18:12:37 +02:00
|
|
|
"""Base class for rule34 extractors"""
|
|
|
|
category = "rule34"
|
|
|
|
api_url = "https://rule34.xxx/index.php"
|
2018-07-01 22:28:52 +02:00
|
|
|
post_url = "https://rule34.xxx/index.php?page=post&s=view&id={}"
|
2018-07-04 12:24:01 +02:00
|
|
|
pool_url = "https://rule34.xxx/index.php?page=pool&s=show&id={}"
|
2018-01-03 23:52:01 +01:00
|
|
|
page_limit = 4000
|
2016-09-17 18:12:37 +02:00
|
|
|
|
2018-01-03 23:52:01 +01:00
|
|
|
def __init__(self, match):
|
|
|
|
super().__init__(match)
|
2017-02-01 00:53:19 +01:00
|
|
|
self.params.update({"page": "dapi", "s": "post", "q": "index"})
|
2016-09-17 18:12:37 +02:00
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2018-01-03 23:52:01 +01:00
|
|
|
class Rule34TagExtractor(booru.TagMixin, Rule34Extractor):
|
2016-09-17 18:12:37 +02:00
|
|
|
"""Extractor for images from rule34.xxx based on search-tags"""
|
2019-02-08 13:45:40 +01:00
|
|
|
pattern = (r"(?:https?://)?(?:www\.)?rule34\.xxx/(?:index\.php)?"
|
|
|
|
r"\?page=post&s=list&tags=(?P<tags>[^&#]+)")
|
|
|
|
test = ("https://rule34.xxx/index.php?page=post&s=list&tags=danraku", {
|
2019-04-11 20:43:08 +02:00
|
|
|
"content": "97e4bbf86c3860be18de384d02d544251afe1d45",
|
2018-08-03 17:28:47 +02:00
|
|
|
"pattern": r"https?://([^.]+\.)?rule34\.xxx/images/\d+/[0-9a-f]+\.jpg",
|
2019-04-11 20:43:08 +02:00
|
|
|
"count": 1,
|
2019-02-08 13:45:40 +01:00
|
|
|
})
|
2016-09-17 18:12:37 +02:00
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2018-07-04 12:24:01 +02:00
|
|
|
class Rule34PoolExtractor(booru.GelbooruPoolMixin, Rule34Extractor):
|
|
|
|
"""Extractor for image-pools from rule34.xxx"""
|
2019-02-08 13:45:40 +01:00
|
|
|
pattern = (r"(?:https?://)?(?:www\.)?rule34\.xxx/(?:index\.php)?"
|
|
|
|
r"\?page=pool&s=show&id=(?P<pool>\d+)")
|
|
|
|
test = ("https://rule34.xxx/index.php?page=pool&s=show&id=179", {
|
2018-07-04 12:24:01 +02:00
|
|
|
"count": 3,
|
2019-02-08 13:45:40 +01:00
|
|
|
})
|
2018-07-04 12:24:01 +02:00
|
|
|
|
|
|
|
|
2018-01-03 23:52:01 +01:00
|
|
|
class Rule34PostExtractor(booru.PostMixin, Rule34Extractor):
|
2016-09-17 18:12:37 +02:00
|
|
|
"""Extractor for single images from rule34.xxx"""
|
2019-02-08 13:45:40 +01:00
|
|
|
pattern = (r"(?:https?://)?(?:www\.)?rule34\.xxx/(?:index\.php)?"
|
|
|
|
r"\?page=post&s=view&id=(?P<post>\d+)")
|
2019-04-11 20:43:08 +02:00
|
|
|
test = ("https://rule34.xxx/index.php?page=post&s=view&id=1995545", {
|
|
|
|
"content": "97e4bbf86c3860be18de384d02d544251afe1d45",
|
2018-07-01 22:28:52 +02:00
|
|
|
"options": (("tags", True),),
|
|
|
|
"keyword": {
|
|
|
|
"tags_artist": "danraku",
|
2019-04-11 20:43:08 +02:00
|
|
|
"tags_character": "kashima_(kantai_collection)",
|
|
|
|
"tags_copyright": "kantai_collection",
|
2018-08-10 16:26:10 +02:00
|
|
|
"tags_general": str,
|
2019-04-11 20:43:08 +02:00
|
|
|
"tags_metadata": str,
|
2018-07-01 22:28:52 +02:00
|
|
|
},
|
2019-02-08 13:45:40 +01:00
|
|
|
})
|