mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-17 07:49:45 +02:00
Check paged requests using PageSize for Import Lists
This commit is contained in:
parent
d5d77a4f1a
commit
49501a55ae
@ -20,12 +20,14 @@ namespace NzbDrone.Core.ImportLists
|
|||||||
public abstract class HttpImportListBase<TSettings> : ImportListBase<TSettings>
|
public abstract class HttpImportListBase<TSettings> : ImportListBase<TSettings>
|
||||||
where TSettings : IProviderConfig, new()
|
where TSettings : IProviderConfig, new()
|
||||||
{
|
{
|
||||||
|
protected const int MaxNumResultsPerQuery = 1000;
|
||||||
|
|
||||||
protected readonly IHttpClient _httpClient;
|
protected readonly IHttpClient _httpClient;
|
||||||
|
|
||||||
public override bool Enabled => true;
|
public override bool Enabled => true;
|
||||||
public bool SupportsPaging => PageSize > 20;
|
public override bool EnableAuto => false;
|
||||||
|
|
||||||
public virtual int PageSize => 20;
|
public virtual int PageSize => 0;
|
||||||
public virtual TimeSpan RateLimit => TimeSpan.FromSeconds(2);
|
public virtual TimeSpan RateLimit => TimeSpan.FromSeconds(2);
|
||||||
|
|
||||||
public abstract IImportListRequestGenerator GetRequestGenerator();
|
public abstract IImportListRequestGenerator GetRequestGenerator();
|
||||||
@ -71,6 +73,16 @@ protected virtual ImportListFetchResult FetchMovies(Func<IImportListRequestGener
|
|||||||
var page = FetchPage(request, parser);
|
var page = FetchPage(request, parser);
|
||||||
|
|
||||||
pagedMovies.AddRange(page);
|
pagedMovies.AddRange(page);
|
||||||
|
|
||||||
|
if (pagedMovies.Count >= MaxNumResultsPerQuery)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsFullPage(page))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
movies.AddRange(pagedMovies.Where(IsValidItem));
|
movies.AddRange(pagedMovies.Where(IsValidItem));
|
||||||
@ -161,6 +173,11 @@ protected virtual bool IsValidItem(ImportListMovie listItem)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual bool IsFullPage(IList<ImportListMovie> page)
|
||||||
|
{
|
||||||
|
return PageSize != 0 && page.Count >= PageSize;
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual IList<ImportListMovie> FetchPage(ImportListRequest request, IParseImportListResponse parser)
|
protected virtual IList<ImportListMovie> FetchPage(ImportListRequest request, IParseImportListResponse parser)
|
||||||
{
|
{
|
||||||
var response = FetchImportListResponse(request);
|
var response = FetchImportListResponse(request);
|
||||||
|
Loading…
Reference in New Issue
Block a user