mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-25 09:12:17 +00:00
Only list the matching ignored terms in the rejection.
This commit is contained in:
parent
b1d0d422e9
commit
2d968a725c
1 changed files with 14 additions and 10 deletions
|
@ -34,23 +34,27 @@ public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase
|
||||||
|
|
||||||
foreach (var r in required)
|
foreach (var r in required)
|
||||||
{
|
{
|
||||||
var split = r.Required.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList();
|
var requiredTerms = r.Required.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||||
|
|
||||||
if (!ContainsAny(split, title))
|
var foundTerms = ContainsAny(requiredTerms, title);
|
||||||
|
if (foundTerms.Empty())
|
||||||
{
|
{
|
||||||
_logger.Debug("[{0}] does not contain one of the required terms: {1}", title, r.Required);
|
var terms = string.Join(", ", requiredTerms);
|
||||||
return Decision.Reject("Does not contain one of the required terms: {0}", r.Required.Replace(",", ", "));
|
_logger.Debug("[{0}] does not contain one of the required terms: {1}", title, terms);
|
||||||
|
return Decision.Reject("Does not contain one of the required terms: {0}", terms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var r in ignored)
|
foreach (var r in ignored)
|
||||||
{
|
{
|
||||||
var split = r.Ignored.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
var ignoredTerms = r.Ignored.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||||
|
|
||||||
if (ContainsAny(split, title))
|
var foundTerms = ContainsAny(ignoredTerms, title);
|
||||||
|
if (foundTerms.Any())
|
||||||
{
|
{
|
||||||
_logger.Debug("[{0}] contains one or more ignored terms: {1}", title, r.Ignored);
|
var terms = string.Join(", ", foundTerms);
|
||||||
return Decision.Reject("Contains one or more ignored terms: {0}", r.Ignored.Replace(",", ", "));
|
_logger.Debug("[{0}] contains these ignored terms: {1}", title, terms);
|
||||||
|
return Decision.Reject("Contains these ignored terms: {0}", terms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,9 +62,9 @@ public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase
|
||||||
return Decision.Accept();
|
return Decision.Accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Boolean ContainsAny(List<String> terms, String title)
|
private static List<string> ContainsAny(List<string> terms, string title)
|
||||||
{
|
{
|
||||||
return terms.Any(t => title.ToLowerInvariant().Contains(t.ToLowerInvariant()));
|
return terms.Where(t => title.ToLowerInvariant().Contains(t.ToLowerInvariant())).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue