Skip to content

Commit

Permalink
Merge branch 'fckoppenol-master'. Closes #85
Browse files Browse the repository at this point in the history
  • Loading branch information
rikkit committed Apr 16, 2016
2 parents 66e4530 + e4c2a0f commit f91201a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
15 changes: 14 additions & 1 deletion src/IF.Lastfm.Core/Api/ArtistApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,21 @@ public async Task<PageResponse<LastTrack>> GetTopTracksAsync(string artist, bool

public async Task<PageResponse<LastArtist>> 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<PageResponse<LastArtist>> GetSimilarByMbidAsync(string mbid, bool autocorrect = false, int limit = LastFm.DefaultPageLength)
{
var command = new GetSimilarCommand(Auth)
{
ArtistMbid = mbid,
Autocorrect = autocorrect,
Limit = limit,
HttpClient = HttpClient
Expand Down
23 changes: 16 additions & 7 deletions src/IF.Lastfm.Core/Api/Commands/Artist/GetSimilarCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,28 @@ internal class GetSimilarCommand : GetAsyncCommandBase<PageResponse<LastArtist>>
{
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)
Expand All @@ -37,7 +46,7 @@ public override void SetParameters()
DisableCaching();
}

public async override Task<PageResponse<LastArtist>> HandleResponse(HttpResponseMessage response)
public override async Task<PageResponse<LastArtist>> HandleResponse(HttpResponseMessage response)
{
var json = await response.Content.ReadAsStringAsync();

Expand Down
2 changes: 2 additions & 0 deletions src/IF.Lastfm.Core/Api/IArtistApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Task<LastResponse<LastArtist>> GetInfoByMbidAsync(string mbid, string bioLang =

Task<PageResponse<LastArtist>> GetSimilarAsync(string artistname, bool autocorrect = false, int limit = 100);

Task<PageResponse<LastArtist>> GetSimilarByMbidAsync(string mbid, bool autocorrect = false, int limit = 100);

Task<PageResponse<LastAlbum>> GetTopAlbumsAsync(string artist,
bool autocorrect = false,
int page = 1,
Expand Down

0 comments on commit f91201a

Please sign in to comment.