diff --git a/nise-backend/src/main/kotlin/com/nisemoe/nise/osu/OsuApi.kt b/nise-backend/src/main/kotlin/com/nisemoe/nise/osu/OsuApi.kt index 0346bfb..87f2244 100644 --- a/nise-backend/src/main/kotlin/com/nisemoe/nise/osu/OsuApi.kt +++ b/nise-backend/src/main/kotlin/com/nisemoe/nise/osu/OsuApi.kt @@ -137,6 +137,19 @@ class OsuApi( } } + fun getBeatmapFromId(beatmapId: Int): OsuApiModels.Beatmap? { + val response = doRequest("https://osu.ppy.sh/api/v2/beatmaps/$beatmapId", emptyMap()) + if (response == null) { + this.logger.info("Error loading beatmap $beatmapId") + return null + } + + return when (response.statusCode()) { + 200 -> serializer.decodeFromString(response.body()) + else -> null + } + } + /** * Retrieves the replay data for a given score ID from the osu!api. * Efficiently cycles through the API keys to avoid rate limiting. @@ -215,7 +228,7 @@ class OsuApi( } fun getUserBeatmapScores(userId: Long, beatmapId: Int): OsuApiModels.BeatmapScores? { - val response = doRequest("https://osu.ppy.sh/api/v2/beatmaps/$beatmapId/scores/users/$userId/all", mapOf()) + val response = doRequest("https://osu.ppy.sh/api/v2/beatmaps/$beatmapId/scores/users/$userId/all", emptyMap()) if(response == null) { this.logger.info("Error getting scores on beatmap $beatmapId for user $userId") @@ -249,7 +262,7 @@ class OsuApi( } fun checkIfUserBanned(userId: Long): Boolean? { - val response = this.doRequest("https://osu.ppy.sh/api/v2/users/$userId/osu?key=id", mapOf()) + val response = this.doRequest("https://osu.ppy.sh/api/v2/users/$userId/osu?key=id", emptyMap()) if(response == null) { this.logger.info("Error loading user with userId = $userId") return null