From c5ae63326f65b25f662b55cc2ee997e2f7539a78 Mon Sep 17 00:00:00 2001 From: King-of-the-all-Cookies Date: Fri, 1 May 2026 16:26:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=BA=20VNDB=20API=20=D0=B8=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82?= =?UTF-8?q?=D1=83=D1=80=D1=8B=20=D0=BF=D0=BE=D0=BB=D0=B5=D0=B9=20=D0=B2=20?= =?UTF-8?q?=D0=BE=D1=82=D0=B2=D0=B5=D1=82=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot.py | 12 ++++++------ vndb_client.py | 26 ++++++++------------------ 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/bot.py b/bot.py index 9c17680..ad42940 100644 --- a/bot.py +++ b/bot.py @@ -182,8 +182,8 @@ Staff: {stats.get('staff', 0)} ) results = await vndb_client.query_vn( - filters=["search", "=", query], - fields=["title", "id", "image{url}"], + filters=["search", "=", query], # ✔️ без вложенности + fields=["id", "title", "image{url}"], results=10 ) @@ -228,8 +228,8 @@ Staff: {stats.get('staff', 0)} return ConversationHandler.END results = await vndb_client.query_character( - filters=["search", "=", query], - fields=["name", "id", "image{url}"], + filters=["search", "=", query], # ✔️ важно + fields=["id", "name", "image{url}"], results=10 ) @@ -255,8 +255,8 @@ Staff: {stats.get('staff', 0)} query = " ".join(context.args) results = await vndb_client.query_release( - filters=["search", "=", query], - fields=["title", "id"], + filters=["search", "=", query], # ✔️ важно + fields=["id", "title"], results=10 ) diff --git a/vndb_client.py b/vndb_client.py index b7603b1..60ba300 100644 --- a/vndb_client.py +++ b/vndb_client.py @@ -55,30 +55,20 @@ class VndbClient: method: str = "GET", data: Optional[Dict[str, Any]] = None, ) -> Dict[str, Any]: - """ - Make HTTP request to VNDB API - - Args: - endpoint: API endpoint - method: HTTP method (GET, POST, PATCH, DELETE) - data: Request body data - - Returns: - Response JSON - - Raises: - httpx.HTTPError: On HTTP errors - json.JSONDecodeError: On invalid JSON response - """ + url = f"{self.base_url}{endpoint}" - - async with httpx.AsyncClient(timeout=10) as client: + + async with httpx.AsyncClient(timeout=15) as client: response = await client.request( method, url, headers=self.headers, - content=json.dumps(data) if data else None, + json=data if data else None, # 🔥 ВАЖНО: json= вместо content= ) + + if response.status_code >= 400: + print("VNDB ERROR:", response.status_code, response.text) + response.raise_for_status() return response.json()