mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 01:32:55 +08:00
Merge pull request #15287 from peppy/get-beatmap-request-via-interface
Allow API beatmap requests using interface type
This commit is contained in:
commit
676e7ff2a6
@ -1,20 +1,38 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.IO.Network;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
namespace osu.Game.Online.API.Requests
|
namespace osu.Game.Online.API.Requests
|
||||||
{
|
{
|
||||||
public class GetBeatmapRequest : APIRequest<APIBeatmap>
|
public class GetBeatmapRequest : APIRequest<APIBeatmap>
|
||||||
{
|
{
|
||||||
private readonly BeatmapInfo beatmapInfo;
|
private readonly IBeatmapInfo beatmapInfo;
|
||||||
|
|
||||||
public GetBeatmapRequest(BeatmapInfo beatmapInfo)
|
private readonly string filename;
|
||||||
|
|
||||||
|
public GetBeatmapRequest(IBeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
this.beatmapInfo = beatmapInfo;
|
this.beatmapInfo = beatmapInfo;
|
||||||
|
|
||||||
|
filename = (beatmapInfo as BeatmapInfo)?.Path ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string Target => $@"beatmaps/lookup?id={beatmapInfo.OnlineBeatmapID}&checksum={beatmapInfo.MD5Hash}&filename={System.Uri.EscapeUriString(beatmapInfo.Path ?? string.Empty)}";
|
protected override WebRequest CreateWebRequest()
|
||||||
|
{
|
||||||
|
var request = base.CreateWebRequest();
|
||||||
|
|
||||||
|
request.AddParameter(@"id", beatmapInfo.OnlineID.ToString());
|
||||||
|
request.AddParameter(@"checksum", beatmapInfo.MD5Hash);
|
||||||
|
request.AddParameter(@"filename", filename);
|
||||||
|
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string Target => @"beatmaps/lookup";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user