[BUG] `get_beatmap_scores` mods param should be of array type
EnricoBaivo opened this issue · comments
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.
keep in mind that it does conversion to Mods meaning
def __init__(self, mods: Union[list[str], str, int]) -> None:
super().__init__(self)
self.data = []
if isinstance(mods, int): # Bitwise representation of mods
self.data = [mod for mod in list(Mod) if mod & mods]
return
if isinstance(mods, str): # string of mods
mods = [mods[i : i + 2] for i in range(0, len(mods), 2)]
if isinstance(mods, list) or isinstance(mods, Mods): # List of Mod types
self.data = [Mod(mod) for mod in mods] # type: ignore
return
raise TypeError(
f"Mods must be a list of Mod types, a string, or an int. Not {type(mods)}",
)
you don't have to do a list of ints
the Mod type itself can get either the mod acronym or the int value