niceaesth / aiosu Goto Github PK
View Code? Open in Web Editor NEWSimple and fast asynchronous osu! API v1 and v2 library
Home Page: https://aiosu.readthedocs.io
License: GNU General Public License v3.0
Simple and fast asynchronous osu! API v1 and v2 library
Home Page: https://aiosu.readthedocs.io
License: GNU General Public License v3.0
Examples show close() as not awaited
Lazer appends proprietary replay data at the end of replay files in order to maintain compatibility. Would be nice to potentially parse that as well.
https://github.com/ppy/osu-web/blob/master/routes/web.php#L38
As far as I can tell this would require HTML parsing. If it does, it will not be implemented as scraping counts as abuse.
Add support for specifying custom difficulty attribute processors. (e.g. https://github.com/SunnyCord/DifficultyAttributeService)
Would be via a ctor argument where it would fall back to base_url
if unset.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
This repository currently has no open or pending branches.
.github/workflows/mypy.yml
actions/checkout v4
.github/workflows/publish.yml
actions/checkout v4
actions/setup-python v5
ncipollo/release-action v1
.github/workflows/pytest.yml
actions/checkout v4
actions/setup-python v5
pyproject.toml
pyproject.toml
python ^3.9
aiohttp ^3.8.3
aiolimiter ^1.0.0
emojiflags ^0.1.1
orjson ^3.8.3
pydantic ^2.0.3
pytest ^8.0.0
pytest-asyncio ^0.23.5
pytest-mock ^3.10.0
toml ^0.10.2
sphinx ^7.0.0
furo ^2024.0.0
pyjwt ^2.6.0
pytest ^8.0.0
pytest-asyncio ^0.23.5
pytest-mock ^3.10.0
mypy ^1.0
toml ^0.10.2
sphinx ^7.0.0
furo ^2024.0.0
pytest-cov ^5.0.0
black ^24.0.0
pre-commit ^3.2.2
python-dotenv ^1.0.0
To consider before merge:
Originally posted by @NiceAesth in SunnyCord/bot#57 (comment)
Describe the bug
trying to use get_user_beatmap_scores and the function throws the following error:
File c:\Python311\Lib\site-packages\pydantic\main.py:866, in BaseModel.repr(self)
865 def repr(self) -> str:
--> 866 return f'{self.repr_name()}({self.repr_str(", ")})'
File c:\Python311\Lib\site-packages\pydantic_internal_repr.py:55, in Representation.repr_str(self, join_str)
54 def repr_str(self, join_str: str) -> str:
---> 55 return join_str.join(repr(v) if a is None else f'{a}={v!r}' for a, v in self.repr_args())
File c:\Python311\Lib\site-packages\pydantic_internal_repr.py:55, in (.0)
54 def repr_str(self, join_str: str) -> str:
---> 55 return join_str.join(repr(v) if a is None else f'{a}={v!r}' for a, v in self.repr_args())
File c:\Python311\Lib\site-packages\pydantic\main.py:876, in BaseModel.repr_args(self)
874 if pydantic_extra is not None:
875 yield from ((k, v) for k, v in pydantic_extra.items())
--> 876 yield from ((k, getattr(self, k)) for k, v in self.model_computed_fields.items() if v.repr)
...
--> 171 raise ValueError("Beatmap object is not set.")
173 if self.passed:
174 return 100.0
ValueError: Beatmap object is not set.
`
To Reproduce
Steps to reproduce the behavior:
try:
user_beatmap_scores = await client.get_user_beatmap_scores(user_id=7562902, beatmap_id=46827)
await print(user_beatmap_scores)
except exceptions.APIException as e:
print("error", e.status)
Expected behavior
The function should return a List of scores from the OSU v2 API
Library version: latest
Python version: 3.11
Could perhaps integrate with the endpoints that provide .osu
files (although I am not a fan of using anything from utils in the clients, instead I think the clients should return BytesIO which utils should accept alongside any file object)
there is no clean way to get updated mod definitions and i do not wish to ship the json with the library
also, the stable mods model should be deprecated and we should be using lazer mods only going forward.
Describe the bug
the paramers are not propebly passt to the OSU apiv2
thats the result of the current api call url
https://osu.ppy.sh/api/v2/beatmaps/3593235/scores?mode=osu&mods=DTHR
To Reproduce
mods_list_int = [64, 16]
beatmap_scores: list[any] = await client.get_beatmap_scores(beatmap_id, mods= mods_list_int, mode="osu")
Expected behavior
the api needs a mods[] param chain which is used as follows
https://osu.ppy.sh/beatmaps/1074246/scores?mode=osu&mods[]=NC&mods[]=HD&type=global
@prepare_token
@check_token
@requires_scope(Scopes.PUBLIC)
async def get_beatmap_scores(self, beatmap_id: int, **kwargs: Any) -> list[Score]:
r"""Get scores submitted on a specific beatmap.
:param beatmap_id: Beatmap ID to search by
:type beatmap_id: int
:param \**kwargs:
See below
:Keyword Arguments:
* *mode* (``aiosu.models.gamemode.Gamemode``) --
Optional, gamemode to search for
* *mods* (``aiosu.models.mods.Mods``) --
Optional, mods to search for
* *type* (``str``) --
Optional, beatmap score ranking type
:raises APIException: Contains status code and error message
:return: List of requested scores
:rtype: list[aiosu.models.score.Score]
"""
url = f"{self.base_url}/api/v2/beatmaps/{beatmap_id}/scores"
params: dict[str, Any] = {}
add_param(params, kwargs, key="mode", converter=lambda x: str(Gamemode(x)))
add_param(params, kwargs, key="mods[]", converter=lambda x: str(Mods(x)))
add_param(params, kwargs, key="type")
# Print the full URL before making the request
full_url = url + "?" + "&".join([f"{param}={value}" for param, value in params.items()])
print("Full URL:", full_url)
json = await self._request("GET", url, params=params)
return from_list(Score.model_validate, json.get("scores", []))
Library version: 2.03
Python version: 3.11.0
Additional context
Add any other context about the problem here.
All library side changes have been done. Waiting on updates to osu-web
. Keeping open for tracking.
Progress:
text/plain
content-type in _request
methodosu.ppy.sh/osu/<bmapid>
endpointsWill return io.BytesIO
like Client v2 download replay. Parsers should accept BytesIO objects.
Not sure if I want to do this yet, but could potentially type baserepo as -> Any:
to allow users to do whatever they want
(e.g. allow returning None in add, update etc.)
Can be copied over from API v2
Not sure if worth it, they are quite fast as it stands
Describe the bug
Title
Expected behavior
Any score that has completion lower than 100 should not have ranks different than "F". osu! API returns D on lazer scores. Would be trivial to add a validator for this.
Library version: 1.0.0
Python version: n/a
Depends on #70
MIGHT need an .olz
parser depending on ppy/osu#24186
Pydantic v2
has recently been released, and introduces many breaking changes. Since this library is one that the user might potentially be using in their own project as well, I am unsure about how to proceed regarding whether to migrate to v2
yet or not. Would appreciate some thoughts on this.
Migration would result in significant performance improvements, at the cost of requiring people to migrate their own projects to pydantic v2
if they are also using the library (or at least change imports to pydantic.v1
as the library still provides those)
If I proceed with migration, relevant libraries such as aiordr
will also be migrated to v2
alongside everything else.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.