Coder Social home page Coder Social logo

niceaesth / aiosu Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 4.0 3.83 MB

Simple and fast asynchronous osu! API v1 and v2 library

Home Page: https://aiosu.readthedocs.io

License: GNU General Public License v3.0

Python 99.66% Makefile 0.34%
osu osu-api osu-api-v1 osu-api-v2 osu-libraries osu-web osugame python3 async

aiosu's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

aiosu's Issues

Dependency Dashboard

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.

Detected dependencies

github-actions
.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
pep621
pyproject.toml
poetry
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

  • Check this box to trigger a request for Renovate to run again on this repository

[BUG] get_user_beatmap_scores ERR

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

[utils] Add .osu parser

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)

[models] Unify mod classes

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.

[BUG] `get_beatmap_scores` mods param should be of array type

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.

[APIv2] `cursor_string` support

All library side changes have been done. Waiting on updates to osu-web. Keeping open for tracking.

Progress:

  • Rankings
  • Changelogs
  • Multiplayer (scores, profile page) (ppy/osu-web#9708, ppy/osu-web#9710) - deployed on the 4th of January 2022
  • Forum topics and posts
  • News listing (ppy/osu-web#9707) - deployed on the 4th of January 2022
  • Comments
  • Beatmapset discussions
  • Beatmapset discussion votes
  • Beatmapset discussion posts
  • Featured artists (ppy/osu-web#9706) - deployed on the 4th of January 2022

Add .osu file endpoint to Client v1

  • Handle text/plain content-type in _request method
  • Add function to call osu.ppy.sh/osu/<bmapid> endpoints

Will return io.BytesIO like Client v2 download replay. Parsers should accept BytesIO objects.

[pydantic] `v2` Breaking changes

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.

Relevant: https://docs.pydantic.dev/latest/migration/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.