1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

[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
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
4 changed files with 25 additions and 0 deletions

View File

@ -1313,6 +1313,18 @@ Description
* ``"new"``: Expect the *new* site layout
extractor.gelbooru.api-key & .user-id
-------------------------------------
Type
``string``
Default
``null``
Description
Values from the API Access Credentials section found at the bottom of your
`Account Options <https://gelbooru.com/index.php?page=account&s=options>`__
page.
extractor.generic.enabled
-------------------------
Type

View File

@ -109,6 +109,11 @@
"include": "gallery",
"layout": "auto"
},
"gelbooru":
{
"api-key": null,
"user-id": null
},
"gfycat":
{
"format": ["mp4", "webm", "mobile", "gif"]

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: