mirror of https://github.com/Jackett/Jackett
cardigann: check for page size
This commit is contained in:
parent
9e5973af5c
commit
f59cc953ec
|
@ -10,6 +10,8 @@ links:
|
||||||
- https://movietorrent.co/
|
- https://movietorrent.co/
|
||||||
|
|
||||||
caps:
|
caps:
|
||||||
|
limitsDefault: 36
|
||||||
|
limitsMax: 36
|
||||||
categorymappings:
|
categorymappings:
|
||||||
- {id: 1, cat: Movies, desc: "Bollywood"}
|
- {id: 1, cat: Movies, desc: "Bollywood"}
|
||||||
- {id: 2, cat: Movies/HD, desc: "1080p"}
|
- {id: 2, cat: Movies/HD, desc: "1080p"}
|
||||||
|
@ -74,6 +76,9 @@ download:
|
||||||
- name: validfilename
|
- name: validfilename
|
||||||
|
|
||||||
search:
|
search:
|
||||||
|
pageSize: 12
|
||||||
|
pageable: true
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
- path: "?s={{ .Keywords }}"
|
- path: "?s={{ .Keywords }}"
|
||||||
- path: "/page/2/?s={{ .Keywords }}"
|
- path: "/page/2/?s={{ .Keywords }}"
|
||||||
|
|
|
@ -93,6 +93,14 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"limitsDefault": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 1
|
||||||
|
},
|
||||||
|
"limitsMax": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 1
|
||||||
|
},
|
||||||
"categories": {
|
"categories": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
@ -482,6 +490,13 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"pageSize": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 1
|
||||||
|
},
|
||||||
|
"pageable": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
"path": {
|
"path": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace Jackett.Common.Indexers
|
||||||
public virtual string Type { get; protected set; }
|
public virtual string Type { get; protected set; }
|
||||||
|
|
||||||
public virtual bool SupportsPagination => false;
|
public virtual bool SupportsPagination => false;
|
||||||
|
public virtual int PageSize => 0;
|
||||||
|
|
||||||
public virtual bool IsConfigured { get; protected set; }
|
public virtual bool IsConfigured { get; protected set; }
|
||||||
public virtual string[] Tags { get; protected set; }
|
public virtual string[] Tags { get; protected set; }
|
||||||
|
|
|
@ -27,6 +27,8 @@ namespace Jackett.Common.Indexers
|
||||||
{
|
{
|
||||||
public class CardigannIndexer : BaseWebIndexer
|
public class CardigannIndexer : BaseWebIndexer
|
||||||
{
|
{
|
||||||
|
public override int PageSize => Definition.Search != null && Definition.Search.PageSize > 0 ? Definition.Search.PageSize : 1;
|
||||||
|
|
||||||
protected IndexerDefinition Definition;
|
protected IndexerDefinition Definition;
|
||||||
protected WebResult landingResult;
|
protected WebResult landingResult;
|
||||||
protected IHtmlDocument landingResultDocument;
|
protected IHtmlDocument landingResultDocument;
|
||||||
|
@ -124,6 +126,8 @@ namespace Jackett.Common.Indexers
|
||||||
TorznabCaps = new TorznabCapabilities();
|
TorznabCaps = new TorznabCapabilities();
|
||||||
TorznabCaps.ParseCardigannSearchModes(Definition.Caps.Modes);
|
TorznabCaps.ParseCardigannSearchModes(Definition.Caps.Modes);
|
||||||
TorznabCaps.SupportsRawSearch = Definition.Caps.Allowrawsearch;
|
TorznabCaps.SupportsRawSearch = Definition.Caps.Allowrawsearch;
|
||||||
|
TorznabCaps.LimitsDefault = Definition.Caps.LimitsDefault ?? TorznabCaps.LimitsDefault;
|
||||||
|
TorznabCaps.LimitsMax = Definition.Caps.LimitsMax ?? TorznabCaps.LimitsMax;
|
||||||
|
|
||||||
// init config Data
|
// init config Data
|
||||||
configData = new ConfigurationData();
|
configData = new ConfigurationData();
|
||||||
|
@ -1353,6 +1357,8 @@ namespace Jackett.Common.Indexers
|
||||||
variables[".Query.Keywords"] = string.Join(" ", KeywordTokens);
|
variables[".Query.Keywords"] = string.Join(" ", KeywordTokens);
|
||||||
variables[".Keywords"] = applyFilters((string)variables[".Query.Keywords"], Search.Keywordsfilters, variables);
|
variables[".Keywords"] = applyFilters((string)variables[".Query.Keywords"], Search.Keywordsfilters, variables);
|
||||||
|
|
||||||
|
var pageSize = PageSize;
|
||||||
|
|
||||||
// TODO: prepare queries first and then send them parallel
|
// TODO: prepare queries first and then send them parallel
|
||||||
var SearchPaths = Search.Paths;
|
var SearchPaths = Search.Paths;
|
||||||
foreach (var SearchPath in SearchPaths)
|
foreach (var SearchPath in SearchPaths)
|
||||||
|
@ -1734,14 +1740,28 @@ namespace Jackett.Common.Indexers
|
||||||
OnParseError(results, ex);
|
OnParseError(results, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pageSize = pageSize == 1 ? releases.Count : pageSize;
|
||||||
|
|
||||||
|
if (Search.Pageable && !IsFullPage(releases, pageSize))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.Limit > 0)
|
if (query.Limit > 0)
|
||||||
|
{
|
||||||
releases = releases.Take(query.Limit).ToList();
|
releases = releases.Take(query.Limit).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
return releases;
|
return releases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual bool IsFullPage(IList<ReleaseInfo> page, int pageSize)
|
||||||
|
{
|
||||||
|
return pageSize != 0 && page.Count >= pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
protected async Task<WebResult> handleRequest(requestBlock request, Dictionary<string, object> variables = null, string referer = null)
|
protected async Task<WebResult> handleRequest(requestBlock request, Dictionary<string, object> variables = null, string referer = null)
|
||||||
{
|
{
|
||||||
var requestLinkStr = resolvePath(applyGoTemplateText(request.Path, variables)).ToString();
|
var requestLinkStr = resolvePath(applyGoTemplateText(request.Path, variables)).ToString();
|
||||||
|
|
|
@ -69,6 +69,8 @@ namespace Jackett.Common.Models
|
||||||
|
|
||||||
public class capabilitiesBlock
|
public class capabilitiesBlock
|
||||||
{
|
{
|
||||||
|
public int? LimitsMax { get; set; }
|
||||||
|
public int? LimitsDefault { get; set; }
|
||||||
public Dictionary<string, string> Categories { get; set; }
|
public Dictionary<string, string> Categories { get; set; }
|
||||||
public List<CategorymappingBlock> Categorymappings { get; set; }
|
public List<CategorymappingBlock> Categorymappings { get; set; }
|
||||||
public Dictionary<string, List<string>> Modes { get; set; }
|
public Dictionary<string, List<string>> Modes { get; set; }
|
||||||
|
@ -137,6 +139,8 @@ namespace Jackett.Common.Models
|
||||||
|
|
||||||
public class searchBlock
|
public class searchBlock
|
||||||
{
|
{
|
||||||
|
public int PageSize { get; set; }
|
||||||
|
public bool Pageable { get; set; }
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
public List<searchPathBlock> Paths { get; set; }
|
public List<searchPathBlock> Paths { get; set; }
|
||||||
public Dictionary<string, List<string>> Headers { get; set; }
|
public Dictionary<string, List<string>> Headers { get; set; }
|
||||||
|
|
Loading…
Reference in New Issue