mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-22 07:43:01 +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 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
|||
|
||||
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);
|
||||
return Decision.Reject("Does not contain one of the required terms: {0}", r.Required.Replace(",", ", "));
|
||||
var terms = string.Join(", ", requiredTerms);
|
||||
_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)
|
||||
{
|
||||
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);
|
||||
return Decision.Reject("Contains one or more ignored terms: {0}", r.Ignored.Replace(",", ", "));
|
||||
var terms = string.Join(", ", foundTerms);
|
||||
_logger.Debug("[{0}] contains these ignored terms: {1}", title, terms);
|
||||
return Decision.Reject("Contains these ignored terms: {0}", terms);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,9 +62,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
|||
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