From 5058d370dfea5f9846a53f3c5ed656b7591be8cc Mon Sep 17 00:00:00 2001 From: Harry Date: Tue, 7 Oct 2014 15:58:42 -0400 Subject: [PATCH] Add pagination to artist methods the get top tracks and albums. --- src/IF.Lastfm.Core/Api/ArtistApi.cs | 12 ++++++++++-- .../Commands/ArtistApi/GetArtistTopAlbumsCommand.cs | 4 ++-- .../Commands/ArtistApi/GetArtistTopTracksCommand.cs | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/IF.Lastfm.Core/Api/ArtistApi.cs b/src/IF.Lastfm.Core/Api/ArtistApi.cs index 2b8a0f1..76d5ce4 100644 --- a/src/IF.Lastfm.Core/Api/ArtistApi.cs +++ b/src/IF.Lastfm.Core/Api/ArtistApi.cs @@ -49,7 +49,11 @@ public async Task> GetTopAlbumsForArtistAsync(string art int page = 1, int itemsPerPage = LastFm.DefaultPageLength) { - var command = new GetArtistTopAlbumsCommand(Auth, artist); + var command = new GetArtistTopAlbumsCommand(Auth, artist) + { + Page = page, + Count = itemsPerPage + }; return await command.ExecuteAsync(); } @@ -58,7 +62,11 @@ public async Task> GetTopTracksForArtistAsync(string art int page = 1, int itemsPerPage = LastFm.DefaultPageLength) { - var command = new GetArtistTopTracksCommand(Auth, artist); + var command = new GetArtistTopTracksCommand(Auth, artist) + { + Page = page, + Count = itemsPerPage + }; return await command.ExecuteAsync(); } diff --git a/src/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistTopAlbumsCommand.cs b/src/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistTopAlbumsCommand.cs index 884a6dc..b351dc8 100644 --- a/src/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistTopAlbumsCommand.cs +++ b/src/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistTopAlbumsCommand.cs @@ -26,8 +26,8 @@ public GetArtistTopAlbumsCommand(IAuth auth, string artistname) public override void SetParameters() { Parameters.Add("artist", ArtistName); - - base.DisableCaching(); + AddPagingParameters(); + DisableCaching(); } public async override Task> HandleResponse(HttpResponseMessage response) diff --git a/src/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistTopTracksCommand.cs b/src/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistTopTracksCommand.cs index be3b3ee..757ec0d 100644 --- a/src/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistTopTracksCommand.cs +++ b/src/IF.Lastfm.Core/Api/Commands/ArtistApi/GetArtistTopTracksCommand.cs @@ -26,8 +26,8 @@ public GetArtistTopTracksCommand(IAuth auth, string artistname) public override void SetParameters() { Parameters.Add("artist", ArtistName); - - base.DisableCaching(); + AddPagingParameters(); + DisableCaching(); } public async override Task> HandleResponse(HttpResponseMessage response)