Recommend artist (user) api

This commit is contained in:
Harry 2014-12-30 12:05:34 -04:00
parent 6788074731
commit 5d452642a6
3 changed files with 19 additions and 3 deletions

View File

@ -2,8 +2,11 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using IF.Lastfm.Core.Api.Commands.ArtistApi;
using IF.Lastfm.Core.Api.Commands.UserApi;
using IF.Lastfm.Core.Api.Helpers;
using IF.Lastfm.Core.Objects;
using AddShoutCommand = IF.Lastfm.Core.Api.Commands.ArtistApi.AddShoutCommand;
using GetTopAlbumsCommand = IF.Lastfm.Core.Api.Commands.ArtistApi.GetTopAlbumsCommand;
namespace IF.Lastfm.Core.Api
{
@ -70,6 +73,16 @@ public async Task<PageResponse<LastTrack>> GetTopTracksForArtistAsync(string art
return await command.ExecuteAsync();
}
public async Task<PageResponse<LastArtist>> GetRecommendedArtistsAsync(int page = 1, int itemsPerPage = LastFm.DefaultPageLength)
{
var command = new GetRecommendedArtistsCommand(Auth)
{
Page = page,
Count = itemsPerPage
};
return await command.ExecuteAsync();
}
public async Task<PageResponse<LastArtist>> GetSimilarArtistsAsync(string artistname, bool autocorrect = false, int limit = 100)
{
var command = new GetSimilarArtistsCommand(Auth, artistname)

View File

@ -28,10 +28,9 @@ public async override Task<PageResponse<LastArtist>> HandleResponse(HttpResponse
if (LastFm.IsResponseValid(json, out error) && response.IsSuccessStatusCode)
{
var jtoken = JsonConvert.DeserializeObject<JToken>(json);
var resultsToken = jtoken.SelectToken("results");
var itemsToken = resultsToken.SelectToken("recommendations").SelectToken("artist");
var resultsToken = jtoken.SelectToken("recommendations");
return PageResponse<LastArtist>.CreateSuccessResponse(itemsToken, resultsToken, LastArtist.ParseJToken, true);
return PageResponse<LastArtist>.CreateSuccessResponse(resultsToken.SelectToken("artist"), resultsToken.SelectToken("@attr"), LastArtist.ParseJToken);
}
else
{

View File

@ -30,6 +30,10 @@ Task<PageResponse<LastTrack>> GetTopTracksForArtistAsync(string artist,
int page = 1,
int itemsPerPage = LastFm.DefaultPageLength);
Task<PageResponse<LastArtist>> GetRecommendedArtistsAsync(
int page = 1,
int itemsPerPage = LastFm.DefaultPageLength);
Task<PageResponse<LastTag>> GetUserTagsForArtistAsync(string artist,
string username,
bool autocorrect = false,