diff --git a/src/IF.Lastfm.Core.Tests/Resources/Tag/GetTopAlbumsSingle.json b/src/IF.Lastfm.Core.Tests/Resources/Tag/GetTopAlbumsSingle.json index 7a2e89f5..ee30831d 100644 --- a/src/IF.Lastfm.Core.Tests/Resources/Tag/GetTopAlbumsSingle.json +++ b/src/IF.Lastfm.Core.Tests/Resources/Tag/GetTopAlbumsSingle.json @@ -1,5 +1,5 @@ { - "topalbums": { + "albums": { "album": { "name": "Number Ones", "mbid": "12cc16cb-5649-4e1a-bd10-a8a496280990", diff --git a/src/IF.Lastfm.Core.Tests/Resources/Tag/GetTopAlbumsSuccess.json b/src/IF.Lastfm.Core.Tests/Resources/Tag/GetTopAlbumsSuccess.json index 1d7f489a..112aee40 100644 --- a/src/IF.Lastfm.Core.Tests/Resources/Tag/GetTopAlbumsSuccess.json +++ b/src/IF.Lastfm.Core.Tests/Resources/Tag/GetTopAlbumsSuccess.json @@ -1,5 +1,5 @@ { - "topalbums": { + "albums": { "album": [ { "name": "Number Ones", diff --git a/src/IF.Lastfm.Core/Api/Commands/Tag/GetTopAlbumsCommand.cs b/src/IF.Lastfm.Core/Api/Commands/Tag/GetTopAlbumsCommand.cs index aac843e2..85e1022e 100644 --- a/src/IF.Lastfm.Core/Api/Commands/Tag/GetTopAlbumsCommand.cs +++ b/src/IF.Lastfm.Core/Api/Commands/Tag/GetTopAlbumsCommand.cs @@ -33,7 +33,7 @@ public override async Task> HandleResponse(HttpResponseM if (LastFm.IsResponseValid(json, out status) && response.IsSuccessStatusCode) { var jtoken = JsonConvert.DeserializeObject(json); - var resultsToken = jtoken.SelectToken("topalbums"); + var resultsToken = jtoken.SelectToken("albums"); var itemsToken = resultsToken.SelectToken("album"); return PageResponse.CreateSuccessResponse(itemsToken, resultsToken, LastAlbum.ParseJToken, LastPageResultsType.Attr); diff --git a/src/IF.Lastfm.Core/Api/Commands/Tag/GetTopTracksCommand.cs b/src/IF.Lastfm.Core/Api/Commands/Tag/GetTopTracksCommand.cs index 9ca4b664..2e804975 100644 --- a/src/IF.Lastfm.Core/Api/Commands/Tag/GetTopTracksCommand.cs +++ b/src/IF.Lastfm.Core/Api/Commands/Tag/GetTopTracksCommand.cs @@ -33,7 +33,7 @@ public override async Task> HandleResponse(HttpResponseM if (LastFm.IsResponseValid(json, out status) && response.IsSuccessStatusCode) { var jtoken = JsonConvert.DeserializeObject(json); - var resultsToken = jtoken.SelectToken("toptracks"); + var resultsToken = jtoken.SelectToken("tracks"); var itemsToken = resultsToken.SelectToken("track"); return PageResponse.CreateSuccessResponse(itemsToken, resultsToken, LastTrack.ParseJToken, LastPageResultsType.Attr); diff --git a/src/IF.Lastfm.Core/Objects/LastTag.cs b/src/IF.Lastfm.Core/Objects/LastTag.cs index a9ebc233..252309ce 100644 --- a/src/IF.Lastfm.Core/Objects/LastTag.cs +++ b/src/IF.Lastfm.Core/Objects/LastTag.cs @@ -35,6 +35,12 @@ public LastTag(string name, string uri, int? count = null) Count = count; } + public LastTag(string name, int? count = null) + { + Name = name; + Count = count; + } + internal static LastTag ParseJToken(JToken token) { return ParseJToken(token, null); @@ -43,7 +49,11 @@ internal static LastTag ParseJToken(JToken token) internal static LastTag ParseJToken(JToken token, string relatedTag) { var name = token.Value("name"); - var url = token.Value("url"); + + Uri uri = null; + var urlToken = token.Value("url"); + if (!String.IsNullOrWhiteSpace(urlToken)) + uri = new Uri(urlToken, UriKind.RelativeOrAbsolute); int? count = null; var countToken = token.SelectToken("count") ?? token.SelectToken("taggings"); @@ -66,8 +76,9 @@ internal static LastTag ParseJToken(JToken token, string relatedTag) reach = reachToken.ToObject(); } - return new LastTag(name, url, count) + return new LastTag(name, count) { + Url = uri, Streamable = streamable, RelatedTo = relatedTag, Reach = reach