@ -34,23 +34,27 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
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 ignoredTerm s = 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 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
return Decision . Accept ( ) ;
return Decision . Accept ( ) ;
}
}
private static Boolean ContainsAny ( List < String > terms , S tring title )
private static List< string > ContainsAny ( List < string > terms , s tring title )
{
{
return terms . Any ( t = > title . ToLowerInvariant ( ) . Contains ( t . ToLowerInvariant ( ) ) ) ;
return terms . Where ( t = > title . ToLowerInvariant ( ) . Contains ( t . ToLowerInvariant ( ) ) ) . ToList ( ) ;
}
}
}
}
}
}