using Newtonsoft.Json; namespace ZonyLrcTools.Common.Lyrics.Providers.NetEase.JsonModel { public class SongSearchResponse { [JsonProperty("result")] public InnerListItemModel Items { get; set; } = null!; [JsonProperty("code")] public int StatusCode { get; set; } public long GetFirstMatchSongId(string songName, long? duration) { var perfectMatch = Items.SongItems.FirstOrDefault(x => x.Name == songName); if (perfectMatch != null) { return perfectMatch.Id; } if (duration is null or 0) { return Items.SongItems.First().Id; } return Items.SongItems.OrderBy(t => Math.Abs(t.Duration - duration.Value)).First().Id; } } public class InnerListItemModel { [JsonProperty("songs")] public IList SongItems { get; set; } = null!; [JsonProperty("songCount")] public int SongCount { get; set; } } public class SongModel { /// /// 歌曲的名称。 /// [JsonProperty("name")] public string? Name { get; set; } /// /// 歌曲的 Sid (Song Id)。 /// [JsonProperty("id")] public long Id { get; set; } /// /// 歌曲的演唱者。 /// [JsonProperty("artists")] public IList? Artists { get; set; } /// /// 歌曲的专辑信息。 /// [JsonProperty("album")] public SongAlbumModel? Album { get; set; } /// /// 歌曲的实际长度。 /// [JsonProperty("duration")] public long Duration { get; set; } } public class SongArtistModel { /// /// 歌手/艺术家的名称。 /// [JsonProperty("name")] public string? Name { get; set; } } public class SongAlbumModel { /// /// 专辑的名称。 /// [JsonProperty("name")] public string? Name { get; set; } /// /// 专辑图像的 Url 地址。 /// [JsonProperty("img1v1Url")] public string? PictureUrl { get; set; } } }