diff --git a/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistShoutsCommand.cs b/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistShoutsCommand.cs index 3d2f572..2342df3 100644 --- a/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistShoutsCommand.cs +++ b/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistShoutsCommand.cs @@ -54,7 +54,8 @@ public async override Task> HandleResponse(HttpResponseMessa var shouts = new List(); if (shoutsToken != null && pageresponse.TotalItems > 0) { - if (pageresponse.TotalItems == 1) + if (pageresponse.Page == pageresponse.TotalPages + && pageresponse.TotalItems % pageresponse.PageSize == 1) { // array notation isn't used on the api if there is only one shout. shouts.Add(Shout.ParseJToken(shoutsToken)); diff --git a/IF.Lastfm.Core/Api/Commands/TrackApi/GetTrackShoutsCommand.cs b/IF.Lastfm.Core/Api/Commands/TrackApi/GetTrackShoutsCommand.cs index 3318089..0461912 100644 --- a/IF.Lastfm.Core/Api/Commands/TrackApi/GetTrackShoutsCommand.cs +++ b/IF.Lastfm.Core/Api/Commands/TrackApi/GetTrackShoutsCommand.cs @@ -57,7 +57,8 @@ public async override Task> HandleResponse(HttpResponseMessa var shouts = new List(); if (shoutsToken != null && pageresponse.TotalItems > 0) { - if (pageresponse.TotalItems == 1) + if (pageresponse.Page == pageresponse.TotalPages + && pageresponse.TotalItems % pageresponse.PageSize == 1) { // array notation isn't used on the api if there is only one shout. shouts.Add(Shout.ParseJToken(shoutsToken)); diff --git a/IF.Lastfm.Core/Api/Helpers/PageResponse.cs b/IF.Lastfm.Core/Api/Helpers/PageResponse.cs index 33c7031..e90a9ad 100644 --- a/IF.Lastfm.Core/Api/Helpers/PageResponse.cs +++ b/IF.Lastfm.Core/Api/Helpers/PageResponse.cs @@ -23,6 +23,7 @@ public PageResponse() public int Page { get; set; } public int TotalPages { get; set; } public int TotalItems { get; set; } + public int PageSize { get; set; } #endregion @@ -112,6 +113,9 @@ public void AddPageInfoFromJToken(JToken attrToken) var totalItems = attrToken.Value("total"); TotalItems = !string.IsNullOrWhiteSpace(totalItems) ? Convert.ToInt32(totalItems) : 1; + + var pagesize = attrToken.Value("perPage"); + PageSize = !string.IsNullOrWhiteSpace(pagesize) ? Convert.ToInt32(pagesize) : 1; } // {"@attr": {