mirror of
https://github.com/Sarsoo/IF.Lastfm.git
synced 2024-10-16 23:13:07 +01:00
Recommend artist (user) api
This commit is contained in:
parent
6788074731
commit
5d452642a6
@ -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)
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user