-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f70a51d
commit 436d7c7
Showing
5 changed files
with
71 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 32 additions & 2 deletions
34
osu.Game.Rulesets.IGPlayer/Feature/Player/Plugins/Bundle/CloudMusic/Misc/APISongInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Serialization; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Rulesets.IGPlayer.Feature.Player.Misc; | ||
using osu.Game.Rulesets.IGPlayer.Feature.Player.Plugins.Bundle.CloudMusic.Helper; | ||
|
||
namespace osu.Game.Rulesets.IGPlayer.Feature.Player.Plugins.Bundle.CloudMusic.Misc | ||
{ | ||
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] | ||
public class APISongInfo | ||
{ | ||
[JsonProperty("id")] | ||
public long ID { get; set; } | ||
|
||
[JsonProperty("name")] | ||
public string? Name { get; set; } | ||
|
||
public List<APIArtistInfo> Artists { get; set; } = []; | ||
|
||
/// <summary> | ||
/// 获取网易云歌曲标题和搜索标题的相似度 | ||
/// </summary> | ||
/// <returns>相似度百分比</returns> | ||
public float GetSimilarPercentage(WorkingBeatmap? beatmap) | ||
{ | ||
string neteaseTitle = Name?.ToLowerInvariant() ?? string.Empty; | ||
string ourTitle = beatmap?.Metadata.GetTitle().ToLowerInvariant() ?? string.Empty; | ||
|
||
string source = neteaseTitle.Length > ourTitle.Length ? neteaseTitle : ourTitle; | ||
string target = neteaseTitle.Length > ourTitle.Length ? ourTitle : neteaseTitle; | ||
|
||
if (string.IsNullOrEmpty(neteaseTitle) || string.IsNullOrEmpty(ourTitle)) return 0; | ||
|
||
int distance = LevenshteinDistance.Compute(source, target); | ||
float percentage = 1 - (distance / (float)source.Length); | ||
|
||
return Math.Abs(percentage); | ||
} | ||
|
||
public string GetArtist() => string.Join(' ', Artists.Select(a => a.Name)); | ||
} | ||
} |
30 changes: 18 additions & 12 deletions
30
osu.Game.Rulesets.IGPlayer/Feature/Player/Plugins/Bundle/CloudMusic/Misc/ArtistInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
#nullable disable | ||
|
||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Serialization; | ||
|
||
namespace osu.Game.Rulesets.IGPlayer.Feature.Player.Plugins.Bundle.CloudMusic.Misc | ||
{ | ||
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] | ||
public class APIArtistInfo | ||
{ | ||
public int id { get; set; } | ||
public string name { get; set; } | ||
public string picUrl { get; set; } | ||
public IList<string> alias { get; set; } | ||
public int albunSize { get; set; } | ||
public int picId { get; set; } | ||
public string img1v1Url { get; set; } | ||
public int img1v1 { get; set; } | ||
public string trans { get; set; } | ||
public int albumSize { get; set; } | ||
public int ID { get; set; } | ||
public string Name { get; set; } = string.Empty; | ||
public string PicUrl { get; set; } = string.Empty; | ||
public IList<string>? Alias { get; set; } | ||
public int AlbunSize { get; set; } | ||
public int PicId { get; set; } | ||
|
||
[JsonProperty("img1v1Url")] | ||
public string Img1V1Url { get; set; } = string.Empty; | ||
|
||
[JsonProperty("img1v1")] | ||
public int Img1V1 { get; set; } | ||
|
||
public string? Trans { get; set; } | ||
public int AlbumSize { get; set; } | ||
} | ||
} |