2015-04-15 22:24:27 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2020-12-01 15:31:28 +01:00
|
|
|
# Copyright 2015-2020 Mike Fährmann
|
2015-04-15 22:24:27 +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.
|
|
|
|
|
2020-12-01 15:31:28 +01:00
|
|
|
"""Extractors for http://behoimi.org/"""
|
2015-04-15 22:24:27 +02:00
|
|
|
|
2020-12-01 15:31:28 +01:00
|
|
|
from . import moebooru
|
2015-04-15 22:24:27 +02:00
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2020-12-01 15:31:28 +01:00
|
|
|
class _3dbooruBase():
|
2015-11-21 01:48:44 +01:00
|
|
|
"""Base class for 3dbooru extractors"""
|
|
|
|
category = "3dbooru"
|
2020-12-01 15:31:28 +01:00
|
|
|
basecategory = "booru"
|
|
|
|
root = "http://behoimi.org"
|
2015-04-15 22:24:27 +02:00
|
|
|
|
2018-01-03 23:52:01 +01:00
|
|
|
def __init__(self, match):
|
|
|
|
super().__init__(match)
|
|
|
|
self.session.headers.update({
|
|
|
|
"Referer": "http://behoimi.org/post/show/",
|
|
|
|
"Accept-Encoding": "identity",
|
|
|
|
})
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2018-01-03 23:52:01 +01:00
|
|
|
|
2020-12-01 15:31:28 +01:00
|
|
|
class _3dbooruTagExtractor(_3dbooruBase, moebooru.MoebooruTagExtractor):
|
2016-09-12 10:20:57 +02:00
|
|
|
"""Extractor for images from behoimi.org based on search-tags"""
|
2019-02-08 13:45:40 +01:00
|
|
|
pattern = (r"(?:https?://)?(?:www\.)?behoimi\.org/post"
|
|
|
|
r"(?:/(?:index)?)?\?tags=(?P<tags>[^&#]+)")
|
|
|
|
test = ("http://behoimi.org/post?tags=himekawa_azuru+dress", {
|
2015-12-22 03:10:52 +01:00
|
|
|
"url": "ecb30c6aaaf8a6ff8f55255737a9840832a483c1",
|
|
|
|
"content": "11cbda40c287e026c1ce4ca430810f761f2d0b2a",
|
2019-02-08 13:45:40 +01:00
|
|
|
})
|
2015-04-15 22:24:27 +02:00
|
|
|
|
2020-12-01 15:31:28 +01:00
|
|
|
def posts(self):
|
|
|
|
params = {"tags": self.tags}
|
|
|
|
return self._pagination(self.root + "/post/index.json", params)
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2020-12-01 15:31:28 +01:00
|
|
|
|
|
|
|
class _3dbooruPoolExtractor(_3dbooruBase, moebooru.MoebooruPoolExtractor):
|
2016-09-12 10:20:57 +02:00
|
|
|
"""Extractor for image-pools from behoimi.org"""
|
2019-02-08 13:45:40 +01:00
|
|
|
pattern = r"(?:https?://)?(?:www\.)?behoimi\.org/pool/show/(?P<pool>\d+)"
|
|
|
|
test = ("http://behoimi.org/pool/show/27", {
|
2015-12-14 03:00:58 +01:00
|
|
|
"url": "da75d2d1475449d5ef0c266cb612683b110a30f2",
|
2015-12-22 03:10:52 +01:00
|
|
|
"content": "fd5b37c5c6c2de4b4d6f1facffdefa1e28176554",
|
2019-02-08 13:45:40 +01:00
|
|
|
})
|
2015-11-21 01:48:44 +01:00
|
|
|
|
2020-12-01 15:31:28 +01:00
|
|
|
def posts(self):
|
|
|
|
params = {"tags": "pool:" + self.pool_id}
|
|
|
|
return self._pagination(self.root + "/post/index.json", params)
|
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2020-12-01 15:31:28 +01:00
|
|
|
class _3dbooruPostExtractor(_3dbooruBase, moebooru.MoebooruPostExtractor):
|
2016-09-12 10:20:57 +02:00
|
|
|
"""Extractor for single images from behoimi.org"""
|
2019-02-08 13:45:40 +01:00
|
|
|
pattern = r"(?:https?://)?(?:www\.)?behoimi\.org/post/show/(?P<post>\d+)"
|
|
|
|
test = ("http://behoimi.org/post/show/140852", {
|
2015-12-14 03:00:58 +01:00
|
|
|
"url": "ce874ea26f01d6c94795f3cc3aaaaa9bc325f2f6",
|
2015-12-22 03:10:52 +01:00
|
|
|
"content": "26549d55b82aa9a6c1686b96af8bfcfa50805cd4",
|
2018-07-01 22:28:52 +02:00
|
|
|
"options": (("tags", True),),
|
|
|
|
"keyword": {
|
|
|
|
"tags_character": "furude_rika",
|
|
|
|
"tags_copyright": "higurashi_no_naku_koro_ni",
|
|
|
|
"tags_model": "himekawa_azuru",
|
|
|
|
"tags_general": str,
|
|
|
|
},
|
2019-02-08 13:45:40 +01:00
|
|
|
})
|
2017-08-26 23:08:52 +02:00
|
|
|
|
2020-12-01 15:31:28 +01:00
|
|
|
def posts(self):
|
|
|
|
params = {"tags": "id:" + self.post_id}
|
|
|
|
return self._pagination(self.root + "/post/index.json", params)
|
|
|
|
|
2017-08-26 23:08:52 +02:00
|
|
|
|
2020-12-01 15:31:28 +01:00
|
|
|
class _3dbooruPopularExtractor(
|
|
|
|
_3dbooruBase, moebooru.MoebooruPopularExtractor):
|
2017-08-26 23:08:52 +02:00
|
|
|
"""Extractor for popular images from behoimi.org"""
|
2019-02-08 13:45:40 +01:00
|
|
|
pattern = (r"(?:https?://)?(?:www\.)?behoimi\.org"
|
2018-01-03 23:52:01 +01:00
|
|
|
r"/post/popular_(?P<scale>by_(?:day|week|month)|recent)"
|
2019-02-08 13:45:40 +01:00
|
|
|
r"(?:\?(?P<query>[^#]*))?")
|
|
|
|
test = ("http://behoimi.org/post/popular_by_month?month=2&year=2013", {
|
2020-02-27 17:10:08 +01:00
|
|
|
"pattern": r"http://behoimi\.org/data/../../[0-9a-f]{32}\.jpg",
|
2017-08-26 23:08:52 +02:00
|
|
|
"count": 20,
|
2019-02-08 13:45:40 +01:00
|
|
|
})
|