Улучшение обработки запросов к VNDB API и изменение структуры полей в ответах

This commit is contained in:
2026-05-01 16:26:33 +03:00
parent fefe522e46
commit c5ae63326f
2 changed files with 14 additions and 24 deletions

View File

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