feat(fetcher): refresh access_token automatically

This commit is contained in:
MingxuanGame
2025-08-10 11:44:09 +00:00
parent 02051289e9
commit f6c375caf3
3 changed files with 25 additions and 15 deletions

View File

@@ -5,8 +5,6 @@ from app.log import logger
from ._base import BaseFetcher
from httpx import AsyncClient
class BeatmapFetcher(BaseFetcher):
async def get_beatmap(
@@ -21,11 +19,10 @@ class BeatmapFetcher(BaseFetcher):
logger.opt(colors=True).debug(
f"<blue>[BeatmapFetcher]</blue> get_beatmap: <y>{params}</y>"
)
async with AsyncClient() as client:
response = await client.get(
return BeatmapResp.model_validate(
await self.request_api(
"https://osu.ppy.sh/api/v2/beatmaps/lookup",
headers=self.header,
params=params,
)
response.raise_for_status()
return BeatmapResp.model_validate(response.json())
)