mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 09:44:50 +00:00
* style: format code with isort, Ruff Formatter and Yapf This commit fixes the style issues introduced inf9f107eaccording to the output from isort, Ruff Formatter and Yapf. Details: None * refactor: autofix issues in 2 files Resolved issues in the following files with DeepSource Autofix: 1. misskaty/plugins/download_upload.py 2. misskaty/plugins/nightmodev2.py * style: format code with isort, Ruff Formatter and Yapf This commit fixes the style issues introduced in1bc1345according to the output from isort, Ruff Formatter and Yapf. Details: https://github.com/yasirarism/MissKatyPyro/pull/300 * refactor: autofix issues in 2 files Resolved issues in the following files with DeepSource Autofix: 1. misskaty/plugins/dev.py 2. misskaty/plugins/misc_tools.py * style: format code with isort, Ruff Formatter and Yapf This commit fixes the style issues introduced in58d2f1aaccording to the output from isort, Ruff Formatter and Yapf. Details: https://github.com/yasirarism/MissKatyPyro/pull/300 --------- Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> Co-authored-by: Yasir Aris M <git@yasirdev.my.id>
65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
from asyncio import gather
|
|
|
|
from aiohttp import ClientSession
|
|
from httpx import AsyncClient, Timeout
|
|
|
|
# Aiohttp Async Client
|
|
session = ClientSession()
|
|
|
|
# HTTPx Async Client
|
|
fetch = AsyncClient(
|
|
http2=True,
|
|
verify=False,
|
|
headers={
|
|
"Accept-Language": "en-US,en;q=0.9,id-ID;q=0.8,id;q=0.7",
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edge/107.0.1418.42",
|
|
},
|
|
timeout=Timeout(20),
|
|
)
|
|
|
|
|
|
async def get(url: str, *args, **kwargs):
|
|
async with session.get(url, *args, **kwargs) as resp:
|
|
try:
|
|
data = await resp.json()
|
|
except Exception:
|
|
data = await resp.text()
|
|
return data
|
|
|
|
|
|
async def head(url: str, *args, **kwargs):
|
|
async with session.head(url, *args, **kwargs) as resp:
|
|
try:
|
|
data = await resp.json()
|
|
except Exception:
|
|
data = await resp.text()
|
|
return data
|
|
|
|
|
|
async def post(url: str, *args, **kwargs):
|
|
async with session.post(url, *args, **kwargs) as resp:
|
|
try:
|
|
data = await resp.json()
|
|
except Exception:
|
|
data = await resp.text()
|
|
return data
|
|
|
|
|
|
async def multiget(url: str, times: int, *args, **kwargs):
|
|
return await gather(*[get(url, *args, **kwargs) for _ in range(times)])
|
|
|
|
|
|
async def multihead(url: str, times: int, *args, **kwargs):
|
|
return await gather(*[head(url, *args, **kwargs) for _ in range(times)])
|
|
|
|
|
|
async def multipost(url: str, times: int, *args, **kwargs):
|
|
return await gather(*[post(url, *args, **kwargs) for _ in range(times)])
|
|
|
|
|
|
async def resp_get(url: str, *args, **kwargs):
|
|
return await session.get(url, *args, **kwargs)
|
|
|
|
|
|
async def resp_post(url: str, *args, **kwargs):
|
|
return await session.post(url, *args, **kwargs)
|