|
|
|
@ -997,15 +997,6 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|
|
|
|
|
|
|
|
|
private IEnumerable<IndexerRequest> GetRequest(Dictionary<string, object> variables, SearchCriteriaBase searchCriteria)
|
|
|
|
|
{
|
|
|
|
|
var limit = searchCriteria.Limit;
|
|
|
|
|
var offset = searchCriteria.Offset;
|
|
|
|
|
|
|
|
|
|
if (offset > 0 && limit > 0 && offset / limit > 0)
|
|
|
|
|
{
|
|
|
|
|
// Pagination doesn't work yet, this is to prevent fetching the first page multiple times.
|
|
|
|
|
yield break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var search = _definition.Search;
|
|
|
|
|
|
|
|
|
|
var mappedCategories = _categories.MapTorznabCapsToTrackers((int[])variables[".Query.Categories"]);
|
|
|
|
@ -1035,8 +1026,31 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|
|
|
|
variables[".Query.Keywords"] = string.Join(" ", keywordTokens);
|
|
|
|
|
variables[".Keywords"] = ApplyFilters((string)variables[".Query.Keywords"], search.Keywordsfilters, variables);
|
|
|
|
|
|
|
|
|
|
var pageSize = search.PageSize;
|
|
|
|
|
var minPage = 0;
|
|
|
|
|
var maxPage = 0;
|
|
|
|
|
|
|
|
|
|
if (pageSize > 0)
|
|
|
|
|
{
|
|
|
|
|
variables[".PageSize"] = pageSize;
|
|
|
|
|
minPage = (searchCriteria.Offset / pageSize) + search.FirstPageNumber;
|
|
|
|
|
maxPage = ((searchCriteria.Offset + searchCriteria.Limit - 1) / pageSize) + search.FirstPageNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pageSize == 0 && searchCriteria.Offset >= 100)
|
|
|
|
|
{
|
|
|
|
|
// Indexer doesn't support pagination
|
|
|
|
|
yield break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: prepare queries first and then send them parallel
|
|
|
|
|
var searchPaths = search.Paths;
|
|
|
|
|
|
|
|
|
|
// Grab all pages we will need to return user requested limit and offset
|
|
|
|
|
for (var page = minPage; page <= maxPage; page++)
|
|
|
|
|
{
|
|
|
|
|
variables[".Query.Page"] = page;
|
|
|
|
|
|
|
|
|
|
foreach (var searchPath in searchPaths)
|
|
|
|
|
{
|
|
|
|
|
// skip path if categories don't match
|
|
|
|
@ -1157,4 +1171,5 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|