mirror of
https://github.com/Sarsoo/IF.Lastfm.git
synced 2024-10-17 07:13:09 +01:00
Added album.getTopTags API method to get top tags
This commit is contained in:
parent
ba85890c53
commit
6899cf86ee
@ -46,9 +46,15 @@ public Task<PageResponse<LastTag>> GetUserTagsForAlbumAsync(string artist, strin
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<PageResponse<LastTag>> GetTopTagsForAlbumAsync(string artist, string album, bool autocorrect = false)
|
public async Task<PageResponse<LastTag>> GetTopTagsForAlbumAsync(string artist, string album, bool autocorrect = false)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var command = new AlbumTopTagsCommand(Auth)
|
||||||
|
{
|
||||||
|
ArtistName = artist,
|
||||||
|
AlbumName = album
|
||||||
|
};
|
||||||
|
|
||||||
|
return await command.ExecuteAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<PageResponse<LastAlbum>> SearchForAlbumAsync(string albumname, int page = 1, int itemsPerPage = LastFm.DefaultPageLength)
|
public async Task<PageResponse<LastAlbum>> SearchForAlbumAsync(string albumname, int page = 1, int itemsPerPage = LastFm.DefaultPageLength)
|
||||||
|
@ -0,0 +1,75 @@
|
|||||||
|
using IF.Lastfm.Core.Api.Enums;
|
||||||
|
using IF.Lastfm.Core.Api.Helpers;
|
||||||
|
using IF.Lastfm.Core.Objects;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace IF.Lastfm.Core.Api.Commands.AlbumApi
|
||||||
|
{
|
||||||
|
internal class AlbumTopTagsCommand : GetAsyncCommandBase<PageResponse<LastTag>>
|
||||||
|
{
|
||||||
|
public string AlbumMbid { get; set; }
|
||||||
|
|
||||||
|
public string ArtistName { get; set; }
|
||||||
|
|
||||||
|
public string AlbumName { get; set; }
|
||||||
|
|
||||||
|
public bool Autocorrect { get; set; }
|
||||||
|
|
||||||
|
public AlbumTopTagsCommand(ILastAuth auth)
|
||||||
|
: base(auth)
|
||||||
|
{
|
||||||
|
Method = "album.gettoptags";
|
||||||
|
}
|
||||||
|
|
||||||
|
public AlbumTopTagsCommand(ILastAuth auth, string album, string artist)
|
||||||
|
: this(auth)
|
||||||
|
{
|
||||||
|
AlbumName = album;
|
||||||
|
ArtistName = artist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetParameters()
|
||||||
|
{
|
||||||
|
if (AlbumMbid != null)
|
||||||
|
{
|
||||||
|
Parameters.Add("mbid", AlbumMbid);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Parameters.Add("artist", ArtistName);
|
||||||
|
Parameters.Add("album", AlbumName);
|
||||||
|
}
|
||||||
|
|
||||||
|
Parameters.Add("autocorrect", Convert.ToInt32(Autocorrect).ToString());
|
||||||
|
|
||||||
|
AddPagingParameters();
|
||||||
|
DisableCaching();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async override Task<PageResponse<LastTag>> HandleResponse(HttpResponseMessage response)
|
||||||
|
{
|
||||||
|
var json = await response.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
LastFmApiError error;
|
||||||
|
if (LastFm.IsResponseValid(json, out error) && response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var jtoken = JsonConvert.DeserializeObject<JToken>(json);
|
||||||
|
var resultsToken = jtoken.SelectToken("toptags");
|
||||||
|
var itemsToken = resultsToken.SelectToken("tag");
|
||||||
|
|
||||||
|
return PageResponse<LastTag>.CreateSuccessResponse(itemsToken, resultsToken, LastTag.ParseJToken, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return LastResponse.CreateErrorResponse<PageResponse<LastTag>>(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -40,6 +40,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Api\AlbumApi.cs" />
|
<Compile Include="Api\AlbumApi.cs" />
|
||||||
<Compile Include="Api\ArtistApi.cs" />
|
<Compile Include="Api\ArtistApi.cs" />
|
||||||
|
<Compile Include="Api\Commands\AlbumApi\AlbumTopTagsCommand.cs" />
|
||||||
<Compile Include="Api\Commands\UserApi\GetRecommendedArtistsCommand.cs" />
|
<Compile Include="Api\Commands\UserApi\GetRecommendedArtistsCommand.cs" />
|
||||||
<Compile Include="Api\LastAuth.cs" />
|
<Compile Include="Api\LastAuth.cs" />
|
||||||
<Compile Include="Api\ChartApi.cs" />
|
<Compile Include="Api\ChartApi.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user