diff --git a/src/IF.Lastfm.Core/Api/ArtistApi.cs b/src/IF.Lastfm.Core/Api/ArtistApi.cs index 0f6b7741..3a0f2562 100644 --- a/src/IF.Lastfm.Core/Api/ArtistApi.cs +++ b/src/IF.Lastfm.Core/Api/ArtistApi.cs @@ -67,8 +67,21 @@ public async Task> GetTopTracksAsync(string artist, bool public async Task> GetSimilarAsync(string artistname, bool autocorrect = false, int limit = LastFm.DefaultPageLength) { - var command = new GetSimilarCommand(Auth, artistname) + var command = new GetSimilarCommand(Auth) { + ArtistName = artistname, + Autocorrect = autocorrect, + Limit = limit, + HttpClient = HttpClient + }; + return await command.ExecuteAsync(); + } + + public async Task> GetSimilarAsyncMbidAsync(string mbid, bool autocorrect = false, int limit = LastFm.DefaultPageLength) + { + var command = new GetSimilarCommand(Auth) + { + ArtistMbid = mbid, Autocorrect = autocorrect, Limit = limit, HttpClient = HttpClient diff --git a/src/IF.Lastfm.Core/Api/Commands/Artist/GetSimilarCommand.cs b/src/IF.Lastfm.Core/Api/Commands/Artist/GetSimilarCommand.cs index 2366b943..e9f9b023 100644 --- a/src/IF.Lastfm.Core/Api/Commands/Artist/GetSimilarCommand.cs +++ b/src/IF.Lastfm.Core/Api/Commands/Artist/GetSimilarCommand.cs @@ -14,19 +14,28 @@ internal class GetSimilarCommand : GetAsyncCommandBase> { public bool Autocorrect { get; set; } + public string ArtistMbid { get; set; } + public string ArtistName { get; set; } public int? Limit { get; set; } - public GetSimilarCommand(ILastAuth auth, string artistName) - : base(auth) - { - ArtistName = artistName; - } + public GetSimilarCommand(ILastAuth auth) + : base(auth){} + public override void SetParameters() { - Parameters.Add("artist", ArtistName); + + if (ArtistMbid != null) + { + Parameters.Add("mbid", ArtistMbid); + } + else + { + Parameters.Add("artist", ArtistName); + } + Parameters.Add("autocorrect", Convert.ToInt32(Autocorrect).ToString()); if (Limit != null) @@ -37,7 +46,7 @@ public override void SetParameters() DisableCaching(); } - public async override Task> HandleResponse(HttpResponseMessage response) + public override async Task> HandleResponse(HttpResponseMessage response) { var json = await response.Content.ReadAsStringAsync(); diff --git a/src/IF.Lastfm.Core/Api/IArtistApi.cs b/src/IF.Lastfm.Core/Api/IArtistApi.cs index 447fe908..31e7aab3 100644 --- a/src/IF.Lastfm.Core/Api/IArtistApi.cs +++ b/src/IF.Lastfm.Core/Api/IArtistApi.cs @@ -20,6 +20,8 @@ Task> GetInfoByMbidAsync(string mbid, string bioLang = Task> GetSimilarAsync(string artistname, bool autocorrect = false, int limit = 100); + Task> GetSimilarAsyncMbidAsync(string mbid, bool autocorrect = false, int limit = 100); + Task> GetTopAlbumsAsync(string artist, bool autocorrect = false, int page = 1,