Files
AnyMusicBot/lib/ShazamIO/shazamio/client.py
BarsTiger 9d45084d98 Add lib
2023-10-07 22:51:05 +03:00

19 lines
667 B
Python

import aiohttp
from shazamio.exceptions import BadMethod
from shazamio.utils import validate_json
class HTTPClient:
@staticmethod
async def request(method: str, url: str, *args, **kwargs) -> dict:
async with aiohttp.ClientSession() as session:
if method.upper() == "GET":
async with session.get(url, **kwargs) as resp:
return await validate_json(resp, *args)
elif method.upper() == "POST":
async with session.post(url, **kwargs) as resp:
return await validate_json(resp, *args)
else:
raise BadMethod("Accept only GET/POST")