[gelbooru] add support for api_key and user_id (#2767)

This commit is contained in:
Mike Fährmann
2022-07-18 18:46:31 +02:00
parent 77bdd8fe0f
commit f225247670
4 changed files with 25 additions and 0 deletions

View File

@@ -21,10 +21,15 @@ class GelbooruBase():
root = "https://gelbooru.com"
def _api_request(self, params):
params["api_key"] = self.api_key
params["user_id"] = self.user_id
url = self.root + "/index.php?page=dapi&s=post&q=index&json=1"
data = self.request(url, params=params).json()
if "post" not in data:
return ()
posts = data["post"]
if not isinstance(posts, list):
return (posts,)

View File

@@ -21,6 +21,9 @@ class GelbooruV02Extractor(booru.BooruExtractor):
def __init__(self, match):
booru.BooruExtractor.__init__(self, match)
self.api_key = self.config("api-key")
self.user_id = self.config("user-id")
try:
self.api_root = INSTANCES[self.category]["api_root"]
except KeyError: