1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00

Only list the matching ignored terms in the rejection.

This commit is contained in:
Taloth Saldono 2015-08-02 21:26:47 +02:00
parent b1d0d422e9
commit 2d968a725c

View File

@ -34,23 +34,27 @@ public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase
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 @@ public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase
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();
}
}
}