feat(fetcher): add data fetcher

This commit is contained in:
MingxuanGame
2025-07-26 16:06:53 +08:00
parent 585cb9d98a
commit cca4a2f1be
13 changed files with 880 additions and 639 deletions

18
app/fetcher/beatmap.py Normal file
View File

@@ -0,0 +1,18 @@
from __future__ import annotations
from app.database.beatmap import BeatmapResp
from ._base import BaseFetcher
from httpx import AsyncClient
class BeatmapFetcher(BaseFetcher):
async def get_beatmap(self, beatmap_id: int) -> BeatmapResp:
async with AsyncClient() as client:
response = await client.get(
f"https://osu.ppy.sh/api/v2/beatmaps/{beatmap_id}",
headers=self.header,
)
response.raise_for_status()
return BeatmapResp.model_validate(response.json())