2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-06-08 11:21:12 +08:00
|
|
|
|
|
2024-10-30 15:00:57 +08:00
|
|
|
|
using System.Globalization;
|
2021-10-26 11:04:18 +08:00
|
|
|
|
using osu.Framework.IO.Network;
|
2018-06-08 11:21:12 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Online.API.Requests
|
|
|
|
|
{
|
|
|
|
|
public class GetBeatmapRequest : APIRequest<APIBeatmap>
|
|
|
|
|
{
|
2024-10-30 15:00:57 +08:00
|
|
|
|
public readonly int OnlineID = -1;
|
|
|
|
|
public readonly string? MD5Hash;
|
|
|
|
|
public readonly string? Filename;
|
2018-06-08 11:21:12 +08:00
|
|
|
|
|
2021-10-25 14:59:40 +08:00
|
|
|
|
public GetBeatmapRequest(IBeatmapInfo beatmapInfo)
|
2018-06-08 11:21:12 +08:00
|
|
|
|
{
|
2024-10-30 15:00:57 +08:00
|
|
|
|
OnlineID = beatmapInfo.OnlineID;
|
|
|
|
|
MD5Hash = beatmapInfo.MD5Hash;
|
2022-09-27 19:30:41 +08:00
|
|
|
|
Filename = (beatmapInfo as BeatmapInfo)?.Path ?? string.Empty;
|
2018-06-08 11:21:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-10-30 15:00:57 +08:00
|
|
|
|
public GetBeatmapRequest(string md5Hash)
|
|
|
|
|
{
|
|
|
|
|
MD5Hash = md5Hash;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-26 11:04:18 +08:00
|
|
|
|
protected override WebRequest CreateWebRequest()
|
|
|
|
|
{
|
|
|
|
|
var request = base.CreateWebRequest();
|
|
|
|
|
|
2024-10-30 15:00:57 +08:00
|
|
|
|
if (OnlineID > 0)
|
|
|
|
|
request.AddParameter(@"id", OnlineID.ToString(CultureInfo.InvariantCulture));
|
|
|
|
|
if (!string.IsNullOrEmpty(MD5Hash))
|
|
|
|
|
request.AddParameter(@"checksum", MD5Hash);
|
2022-09-27 19:30:41 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(Filename))
|
|
|
|
|
request.AddParameter(@"filename", Filename);
|
2021-10-26 11:04:18 +08:00
|
|
|
|
|
|
|
|
|
return request;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string Target => @"beatmaps/lookup";
|
2018-06-08 11:21:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|