From 91b17722eca08b0014be1d7c195d009cc28d1f0c Mon Sep 17 00:00:00 2001 From: sinkaroid Date: Thu, 12 May 2022 23:30:03 +0700 Subject: [PATCH] feat: make mock first to check the api --- booru/client/danbooru.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/booru/client/danbooru.py b/booru/client/danbooru.py index a5834a1..f1410c8 100644 --- a/booru/client/danbooru.py +++ b/booru/client/danbooru.py @@ -63,6 +63,13 @@ def __init__(self, api_key: str = "", login: str = ""): self.specs = {"api_key": self.api_key, "login": self.login} + if self.api_key and self.login: + self.data = requests.get(f"https://danbooru.donmai.us/profile.json?api_key={self.api_key}&login={self.login}") + + if self.data.status_code != 200: + raise ValueError(Booru.error_handling_invalid_auth) + + async def search( self, query: str,