From d5a6bfffd1e60c5b56de21bc185f716fdba3f57a Mon Sep 17 00:00:00 2001 From: Miwory Date: Mon, 15 Dec 2025 19:28:50 +0300 Subject: [PATCH] =?UTF-8?q?=D0=90=D0=BF=D0=B8=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81?= =?UTF-8?q?=D0=BA=D0=BE=D1=80=D0=BE=D0=B2=20=D0=BD=D0=B0=20=D0=BA=D0=B0?= =?UTF-8?q?=D1=80=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- src/osuclient/api.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 45cd18f..768a78e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "osuclient" -version = "0.5.5" +version = "0.6.0" description = "Client for osu! API" readme = "README.md" authors = [ diff --git a/src/osuclient/api.py b/src/osuclient/api.py index d794184..77256d8 100644 --- a/src/osuclient/api.py +++ b/src/osuclient/api.py @@ -117,6 +117,40 @@ class osuAPIClient(AioHTTPXClient): self.logger.error(req.text) raise s.Error(500, 'Internal Server Error') + async def get_user_beatmap_scores( + self, + access_token: str, + beatmap_id: int, + user_id: int, + legacy_only: Literal[0, 1] = 0, + ruleset: Literal['osu', 'taiko', 'fruits', 'mania'] | None = None, + ): + req = await self.get( + f'/beatmaps/{beatmap_id}/scores/users/{user_id}/all', + params=self.clean_dict( + {'legacy_only': legacy_only, 'ruleset': ruleset} + ), + headers=self.clean_dict( + { + 'Authorization': f'Bearer {access_token}', + } + ), + ) + + match req.status_code: + case st.OK: + return [s.Score.model_validate(score) for score in req.json()] + + case st.NOT_FOUND: + raise s.Error(req.status_code, 'Not Found') + + case st.UNAUTHORIZED: + raise s.Error(req.status_code, 'Unauthorized') + + case _: + self.logger.error(req.text) + raise s.Error(500, 'Internal Server Error') + async def get_user( self, access_token: str,