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()