mirror of
https://github.com/Jackett/Jackett
synced 2025-01-01 12:46:23 +00:00
Fix soundpark search for lidarr
This commit is contained in:
parent
e230fe25c0
commit
424370a1c3
2 changed files with 61 additions and 2 deletions
|
@ -38,9 +38,9 @@
|
|||
|
||||
search:
|
||||
paths:
|
||||
- path: "{{if .Keywords}}search{{else}}music{{end}}"
|
||||
- path: "{{if or (.Query.Album) (.Query.Artist) (.Keywords) }}search{{else}}music{{end}}"
|
||||
inputs:
|
||||
q: "{{if .Query.Artist}}{{ .Query.Artist }}{{else}}{{ .Keywords }}{{end}}"
|
||||
q: "{{if or (.Query.Album) (.Query.Artist) }}{{ or (.Query.Album) (.Query.Artist) }}{{else}}{{ .Keywords }}{{end}}"
|
||||
num: 50
|
||||
|
||||
rows:
|
||||
|
|
|
@ -273,6 +273,65 @@ namespace Jackett.Common.Indexers
|
|||
JoinMatches = JoinMatches.NextMatch();
|
||||
}
|
||||
|
||||
// handle or, and functions
|
||||
Regex AndOrRegex = new Regex(@"(and|or)\s+\((\..+?)\)\s+\((\..+?)\)(\s+\((\..+?)\)){0,1}");
|
||||
var AndOrRegexMatches = AndOrRegex.Match(template);
|
||||
|
||||
while (AndOrRegexMatches.Success)
|
||||
{
|
||||
string functionResult = "";
|
||||
string all = AndOrRegexMatches.Groups[0].Value;
|
||||
string op = AndOrRegexMatches.Groups[1].Value;
|
||||
string first = AndOrRegexMatches.Groups[2].Value;
|
||||
string second = AndOrRegexMatches.Groups[3].Value;
|
||||
string third = "";
|
||||
if (AndOrRegexMatches.Groups.Count > 5)
|
||||
{
|
||||
third = AndOrRegexMatches.Groups[5].Value;
|
||||
}
|
||||
|
||||
var value = variables[first];
|
||||
if (op == "and")
|
||||
{
|
||||
functionResult = second;
|
||||
if (value == null || (value is string && string.IsNullOrWhiteSpace((string)value)))
|
||||
{
|
||||
functionResult = first;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(third))
|
||||
{
|
||||
functionResult = third;
|
||||
value = variables[second];
|
||||
if (value == null || (value is string && string.IsNullOrWhiteSpace((string)value)))
|
||||
{
|
||||
functionResult = second;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (op == "or")
|
||||
{
|
||||
functionResult = first;
|
||||
if (value == null || (value is string && string.IsNullOrWhiteSpace((string)value)))
|
||||
{
|
||||
functionResult = second;
|
||||
if (!string.IsNullOrWhiteSpace(third))
|
||||
{
|
||||
value = variables[second];
|
||||
if (value == null || (value is string && string.IsNullOrWhiteSpace((string)value)))
|
||||
{
|
||||
functionResult = third;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
template = template.Replace(all, functionResult);
|
||||
AndOrRegexMatches = AndOrRegexMatches.NextMatch();
|
||||
}
|
||||
|
||||
// handle if ... else ... expression
|
||||
Regex IfElseRegex = new Regex(@"{{\s*if\s*(.+?)\s*}}(.*?){{\s*else\s*}}(.*?){{\s*end\s*}}");
|
||||
var IfElseRegexMatches = IfElseRegex.Match(template);
|
||||
|
|
Loading…
Reference in a new issue