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:
parent
77bdd8fe0f
commit
f225247670
@ -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
|
||||
|
@ -109,6 +109,11 @@
|
||||
"include": "gallery",
|
||||
"layout": "auto"
|
||||
},
|
||||
"gelbooru":
|
||||
{
|
||||
"api-key": null,
|
||||
"user-id": null
|
||||
},
|
||||
"gfycat":
|
||||
{
|
||||
"format": ["mp4", "webm", "mobile", "gif"]
|
||||
|
@ -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,)
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user