[gelbooru] add support for api_key and user_id (#2767)
This commit is contained in:
@@ -1313,6 +1313,18 @@ Description
|
|||||||
* ``"new"``: Expect the *new* site layout
|
* ``"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
|
extractor.generic.enabled
|
||||||
-------------------------
|
-------------------------
|
||||||
Type
|
Type
|
||||||
|
|||||||
@@ -109,6 +109,11 @@
|
|||||||
"include": "gallery",
|
"include": "gallery",
|
||||||
"layout": "auto"
|
"layout": "auto"
|
||||||
},
|
},
|
||||||
|
"gelbooru":
|
||||||
|
{
|
||||||
|
"api-key": null,
|
||||||
|
"user-id": null
|
||||||
|
},
|
||||||
"gfycat":
|
"gfycat":
|
||||||
{
|
{
|
||||||
"format": ["mp4", "webm", "mobile", "gif"]
|
"format": ["mp4", "webm", "mobile", "gif"]
|
||||||
|
|||||||
@@ -21,10 +21,15 @@ class GelbooruBase():
|
|||||||
root = "https://gelbooru.com"
|
root = "https://gelbooru.com"
|
||||||
|
|
||||||
def _api_request(self, params):
|
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"
|
url = self.root + "/index.php?page=dapi&s=post&q=index&json=1"
|
||||||
data = self.request(url, params=params).json()
|
data = self.request(url, params=params).json()
|
||||||
|
|
||||||
if "post" not in data:
|
if "post" not in data:
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
posts = data["post"]
|
posts = data["post"]
|
||||||
if not isinstance(posts, list):
|
if not isinstance(posts, list):
|
||||||
return (posts,)
|
return (posts,)
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ class GelbooruV02Extractor(booru.BooruExtractor):
|
|||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
booru.BooruExtractor.__init__(self, match)
|
booru.BooruExtractor.__init__(self, match)
|
||||||
|
self.api_key = self.config("api-key")
|
||||||
|
self.user_id = self.config("user-id")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.api_root = INSTANCES[self.category]["api_root"]
|
self.api_root = INSTANCES[self.category]["api_root"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|||||||
Reference in New Issue
Block a user