Fixed: Dynamic page size for Cardigann search path paging

Fixes some indexers that have arbitrary paging paths in their search-paths definitions. Set page size based on first request, break out if a request down the line returns less results.
pull/225/head
Qstick 4 years ago
parent 5a1186639e
commit bbea256c85

@ -176,12 +176,16 @@ namespace NzbDrone.Core.Indexers
{
var pagedReleases = new List<ReleaseInfo>();
var pageSize = PageSize;
foreach (var request in pageableRequest)
{
url = request.Url.FullUri;
var page = await FetchPage(request, parser);
pageSize = pageSize == 1 ? page.Releases.Count : pageSize;
result.Queries.Add(page);
pagedReleases.AddRange(page.Releases);
@ -213,7 +217,7 @@ namespace NzbDrone.Core.Indexers
break;
}
if (!IsFullPage(page.Releases))
if (!IsFullPage(page.Releases, pageSize))
{
break;
}
@ -336,9 +340,9 @@ namespace NzbDrone.Core.Indexers
return Capabilities ?? ((IndexerDefinition)Definition).Capabilities;
}
protected virtual bool IsFullPage(IList<ReleaseInfo> page)
protected virtual bool IsFullPage(IList<ReleaseInfo> page, int pageSize)
{
return PageSize != 0 && page.Count >= PageSize;
return pageSize != 0 && page.Count >= pageSize;
}
protected virtual async Task<IndexerQueryResult> FetchPage(IndexerRequest request, IParseIndexerResponse parser)

Loading…
Cancel
Save