From 6267497fc007c6c3597eed939f50de6c52672b20 Mon Sep 17 00:00:00 2001 From: Robin Dadswell <19610103+RobinDadswell@users.noreply.github.com> Date: Mon, 15 Mar 2021 18:21:42 +0000 Subject: [PATCH] Fixed: User TMBd lists paging --- .../TMDb/User/TMDbUserRequestGenerator.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core/ImportLists/TMDb/User/TMDbUserRequestGenerator.cs b/src/NzbDrone.Core/ImportLists/TMDb/User/TMDbUserRequestGenerator.cs index 48a5baeee..cd5fd05b9 100644 --- a/src/NzbDrone.Core/ImportLists/TMDb/User/TMDbUserRequestGenerator.cs +++ b/src/NzbDrone.Core/ImportLists/TMDb/User/TMDbUserRequestGenerator.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Newtonsoft.Json; using NLog; using NzbDrone.Common.Http; @@ -15,7 +16,6 @@ public class TMDbUserRequestGenerator : IImportListRequestGenerator public TMDbUserRequestGenerator() { - MaxPages = 3; } public virtual ImportListPageableRequestChain GetMovies() @@ -55,7 +55,20 @@ private IEnumerable GetMoviesRequests() requestBuilder.Method = HttpMethod.GET; - yield return new ImportListRequest(requestBuilder.Build()); + var jsonResponse = JsonConvert.DeserializeObject(HttpClient.Execute(requestBuilder.Build()).Content); + + MaxPages = jsonResponse.TotalPages; + + for (var pageNumber = 1; pageNumber <= MaxPages; pageNumber++) + { + requestBuilder.AddQueryParam("page", pageNumber, true); + + var request = requestBuilder.Build(); + + Logger.Debug($"Importing TMDb movies from: {request.Url}"); + + yield return new ImportListRequest(request); + } } } }