osu-api icon indicating copy to clipboard operation
osu-api copied to clipboard

/get_match not returning the actual gamemode of the map

Open Erinaaaaaaa opened this issue 7 years ago • 5 comments

I'll refer to this match : https://osu.ppy.sh/mp/34133326 More specifically, an individual map played:

{
  "game_id": "183078881",
  "start_time": "2017-06-27 07:10:47",
  "end_time": "2017-06-27 07:12:47",
  "beatmap_id": "694153", // This is Electric Sister Bitch (diff NOVICE), 4K mania mapset
  "play_mode": "0",       // Yet it reports osu!standard.
  "match_type": "0",
  "scoring_type": "0",
  "team_type": "2",
  "mods": "0",
  "scores": [
      ...
  ]
}

The problem is pretty much all said. The problem doesn't only affect the API by the way but also the MP Link page itself, but it's a minor issue.

Here, I played with a few friends a few mania maps without noticing that the chosen gamemode in the map picker was standard. I thought it didn't matter but actually, it does (in the way that i'm using it, that is). I'm calling the beatmap endpoint to get info on it, feeding the gamemode info found here to make sure i get the right info but since it doesn't report the correct gamemode, then i don't feed the correct gamemode leading the beatmap endpoint to return an empty array ([]). I think it would be better to fix this for applications using this endpoing

Erinaaaaaaa avatar Jun 27 '17 20:06 Erinaaaaaaa

You can try call /get_beatmaps, feed it with beatmap_id from the match and get the gamemode from that, at least until they change play_mode from the multiplayer.

Xferno2 avatar Jun 28 '17 17:06 Xferno2

Interestingly enough, requesting https://osu.ppy.sh/api/get_beatmaps?k=[key]&b=694153&m=&a=&limit=500 returns the same empty array while explicitly not setting a gamemode (&m= in the middle of the request, immediately followed by &a=). Doing a request with no other settings (https://osu.ppy.sh/api/get_beatmaps?k=[key]&b=694153) does return stuff [edited that in, i missed it lol]. Should I open a new issue regarding this behavior or am I dumb for requesting with all the parameters even when they're unneeded? (I made myself a C# library to avoid rewriting the same thing over and over)

Erinaaaaaaa avatar Jun 28 '17 19:06 Erinaaaaaaa

If you request something with a empty parameter it will return a empty array because there is nothing that match a null parameter (at least that's what I think, not an expert in database stuff). requesting https://osu.ppy.sh/api/get_beatmaps?k=[key]&b=694153 actually returns data: (full return)

image

And here is the gamemode: image2

please open the images in a new window, they look so small here

With that you can just parse the json and get the mode.


Last thing only the parameters that have "required" in brackets are absolutely necessary to make a request(as the "k=" for api key), rest of them are optional (as "limit=" for beatmaps). Example: image3 This is from /get_beatmaps, you can make a request only with the key (https://osu.ppy.sh/api/get_beatmaps?k={key}) and it will return beatmaps, rest of the parameters are optional , they are there to help you filter your search.

Hope that this will help you ^^

Sorry if there are any spelling mistakes, if you don't understand something due to the spelling just ask again and i will try to reformulate.

Xferno2 avatar Jun 28 '17 21:06 Xferno2

Nope, no spelling mistakes at all ;D

Guess i'll reconsider my library in some other way to completely omit parameters when they are null. I won't open a new issue for that since it actually make sense that nothing matches "no gamemode" (since every map has a gamemode lol).

That said, the /get_match endpoint doesn't return the same mode as the map when it's a native non-standard gamemode and is the point of this issue

Erinaaaaaaa avatar Jun 28 '17 21:06 Erinaaaaaaa

Just make a logical switch that checks if the parameter is null. Example:

public {class_here} Beatmap (string k, string since = null, int? mode = null)
{
string url = "https://osu.ppy.sh/api/get_beatmaps?k=" + k;
if (since != null)
{
url += "&since=" + since;
}
else if (mode != null)
{
url += "&mode=" + mode;
}
// here the http request to dowload the string
}

And yes the endpoint from /get_match doesn't return the same mode as the map if is a native non-standard gamemode, even tho that's how it should work. It would be way easier if that would work but my method is just a work around.

Xferno2 avatar Jun 28 '17 21:06 Xferno2