parent
17b9e4722a
commit
cfcf1ad1ab
|
@ -31,6 +31,7 @@ namespace NzbDrone.Core.ImportLists.Plex
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Name => "Plex Watchlist";
|
public override string Name => "Plex Watchlist";
|
||||||
|
public override int PageSize => 50;
|
||||||
|
|
||||||
public override IList<ImportListItemInfo> Fetch()
|
public override IList<ImportListItemInfo> Fetch()
|
||||||
{
|
{
|
||||||
|
@ -48,7 +49,7 @@ namespace NzbDrone.Core.ImportLists.Plex
|
||||||
|
|
||||||
public override IImportListRequestGenerator GetRequestGenerator()
|
public override IImportListRequestGenerator GetRequestGenerator()
|
||||||
{
|
{
|
||||||
return new PlexListRequestGenerator(_plexTvService)
|
return new PlexListRequestGenerator(_plexTvService, PageSize)
|
||||||
{
|
{
|
||||||
Settings = Settings
|
Settings = Settings
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,11 +6,13 @@ namespace NzbDrone.Core.ImportLists.Plex
|
||||||
public class PlexListRequestGenerator : IImportListRequestGenerator
|
public class PlexListRequestGenerator : IImportListRequestGenerator
|
||||||
{
|
{
|
||||||
private readonly IPlexTvService _plexTvService;
|
private readonly IPlexTvService _plexTvService;
|
||||||
|
private readonly int _pageSize;
|
||||||
public PlexListSettings Settings { get; set; }
|
public PlexListSettings Settings { get; set; }
|
||||||
|
|
||||||
public PlexListRequestGenerator(IPlexTvService plexTvService)
|
public PlexListRequestGenerator(IPlexTvService plexTvService, int pageSize)
|
||||||
{
|
{
|
||||||
_plexTvService = plexTvService;
|
_plexTvService = plexTvService;
|
||||||
|
_pageSize = pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual ImportListPageableRequestChain GetListItems()
|
public virtual ImportListPageableRequestChain GetListItems()
|
||||||
|
@ -24,9 +26,12 @@ namespace NzbDrone.Core.ImportLists.Plex
|
||||||
|
|
||||||
private IEnumerable<ImportListRequest> GetSeriesRequest()
|
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;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text;
|
|
||||||
using NzbDrone.Common.Cache;
|
using NzbDrone.Common.Cache;
|
||||||
using NzbDrone.Common.EnvironmentInfo;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
using NzbDrone.Common.Http;
|
using NzbDrone.Common.Http;
|
||||||
|
@ -15,7 +14,7 @@ namespace NzbDrone.Core.Notifications.Plex.PlexTv
|
||||||
PlexTvSignInUrlResponse GetSignInUrl(string callbackUrl, int pinId, string pinCode);
|
PlexTvSignInUrlResponse GetSignInUrl(string callbackUrl, int pinId, string pinCode);
|
||||||
string GetAuthToken(int pinId);
|
string GetAuthToken(int pinId);
|
||||||
void Ping(string authToken);
|
void Ping(string authToken);
|
||||||
HttpRequest GetWatchlist(string authToken);
|
HttpRequest GetWatchlist(string authToken, int pageSize, int pageOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlexTvService : IPlexTvService
|
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));
|
_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);
|
Ping(authToken);
|
||||||
|
|
||||||
|
@ -110,7 +109,9 @@ namespace NzbDrone.Core.Notifications.Plex.PlexTv
|
||||||
.AddQueryParam("includeFields", "title,type,year,ratingKey")
|
.AddQueryParam("includeFields", "title,type,year,ratingKey")
|
||||||
.AddQueryParam("includeElements", "Guid")
|
.AddQueryParam("includeElements", "Guid")
|
||||||
.AddQueryParam("sort", "watchlistedAt:desc")
|
.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))
|
if (!string.IsNullOrWhiteSpace(authToken))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue