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/beatmapset.py Normal file
View File

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