Fixed: Page Plex Watchlist results

Closes #5118
pull/5493/head
Mark McDowall 1 year ago
parent 17b9e4722a
commit cfcf1ad1ab

@ -31,6 +31,7 @@ namespace NzbDrone.Core.ImportLists.Plex
}
public override string Name => "Plex Watchlist";
public override int PageSize => 50;
public override IList<ImportListItemInfo> Fetch()
{
@ -48,7 +49,7 @@ namespace NzbDrone.Core.ImportLists.Plex
public override IImportListRequestGenerator GetRequestGenerator()
{
return new PlexListRequestGenerator(_plexTvService)
return new PlexListRequestGenerator(_plexTvService, PageSize)
{
Settings = Settings
};

@ -6,11 +6,13 @@ namespace NzbDrone.Core.ImportLists.Plex
public class PlexListRequestGenerator : IImportListRequestGenerator
{
private readonly IPlexTvService _plexTvService;
private readonly int _pageSize;
public PlexListSettings Settings { get; set; }
public PlexListRequestGenerator(IPlexTvService plexTvService)
public PlexListRequestGenerator(IPlexTvService plexTvService, int pageSize)
{
_plexTvService = plexTvService;
_pageSize = pageSize;
}
public virtual ImportListPageableRequestChain GetListItems()
@ -24,9 +26,12 @@ namespace NzbDrone.Core.ImportLists.Plex
private IEnumerable<ImportListRequest> GetSeriesRequest()
{
var request = new ImportListRequest(_plexTvService.GetWatchlist(Settings.AccessToken));
var maxPages = 10;
yield return request;
for (var page = 0; page < maxPages; page++)
{
yield return new ImportListRequest(_plexTvService.GetWatchlist(Settings.AccessToken, _pageSize, page * _pageSize));
}
}
}
}

@ -1,7 +1,6 @@
using System;
using System.Linq;
using System.Net.Http;
using System.Text;
using NzbDrone.Common.Cache;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Http;
@ -15,7 +14,7 @@ namespace NzbDrone.Core.Notifications.Plex.PlexTv
PlexTvSignInUrlResponse GetSignInUrl(string callbackUrl, int pinId, string pinCode);
string GetAuthToken(int pinId);
void Ping(string authToken);
HttpRequest GetWatchlist(string authToken);
HttpRequest GetWatchlist(string authToken, int pageSize, int pageOffset);
}
public class PlexTvService : IPlexTvService
@ -94,7 +93,7 @@ namespace NzbDrone.Core.Notifications.Plex.PlexTv
_cache.Get(authToken, () => _proxy.Ping(_configService.PlexClientIdentifier, authToken), TimeSpan.FromHours(24));
}
public HttpRequest GetWatchlist(string authToken)
public HttpRequest GetWatchlist(string authToken, int pageSize, int pageOffset)
{
Ping(authToken);
@ -110,7 +109,9 @@ namespace NzbDrone.Core.Notifications.Plex.PlexTv
.AddQueryParam("includeFields", "title,type,year,ratingKey")
.AddQueryParam("includeElements", "Guid")
.AddQueryParam("sort", "watchlistedAt:desc")
.AddQueryParam("type", (int)PlexMediaType.Show);
.AddQueryParam("type", (int)PlexMediaType.Show)
.AddQueryParam("X-Plex-Container-Size", pageSize)
.AddQueryParam("X-Plex-Container-Start", pageOffset);
if (!string.IsNullOrWhiteSpace(authToken))
{

Loading…
Cancel
Save