mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
parent
15bafce8cc
commit
ac26bcddd9
@ -28,6 +28,7 @@ public PlexImport(IPlexTvService plexTvService,
|
||||
}
|
||||
|
||||
public override string Name => "Plex Watchlist";
|
||||
public override int PageSize => 50;
|
||||
public override bool Enabled => true;
|
||||
public override bool EnableAuto => false;
|
||||
|
||||
@ -46,7 +47,7 @@ public override IParseImportListResponse GetParser()
|
||||
|
||||
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 GetMovies()
|
||||
@ -24,9 +26,12 @@ public virtual ImportListPageableRequestChain GetMovies()
|
||||
|
||||
private IEnumerable<ImportListRequest> GetMoviesRequest()
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public interface IPlexTvService
|
||||
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 +94,7 @@ public void Ping(string authToken)
|
||||
_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 +110,9 @@ public HttpRequest GetWatchlist(string authToken)
|
||||
.AddQueryParam("includeFields", "title,type,year,ratingKey")
|
||||
.AddQueryParam("includeElements", "Guid")
|
||||
.AddQueryParam("sort", "watchlistedAt:desc")
|
||||
.AddQueryParam("type", (int)PlexMediaType.Movie);
|
||||
.AddQueryParam("type", (int)PlexMediaType.Movie)
|
||||
.AddQueryParam("X-Plex-Container-Size", pageSize)
|
||||
.AddQueryParam("X-Plex-Container-Start", pageOffset);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(authToken))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user