mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-23 22:25:14 -04:00
[WIP] Additions to custom formats, such as rescanning old files. (#2949)
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.CustomFormats;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||
{
|
||||
public class CustomFormatAllowedbyProfileSpecification : IDecisionEngineSpecification
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
|
||||
public CustomFormatAllowedbyProfileSpecification(Logger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public RejectionType Type => RejectionType.Permanent;
|
||||
|
||||
public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria)
|
||||
{
|
||||
var formats = subject.ParsedMovieInfo.Quality.CustomFormats.WithNone();
|
||||
_logger.Debug("Checking if report meets custom format requirements. {0}", formats.ToExtendedString());
|
||||
var notAllowedFormats = subject.Movie.Profile.Value.FormatItems.Where(v => v.Allowed == false).Select(f => f.Format).ToList();
|
||||
var notWantedFormats = notAllowedFormats.Intersect(formats);
|
||||
if (notWantedFormats.Any())
|
||||
{
|
||||
_logger.Debug("Custom Formats {0} rejected by Movie's profile", notWantedFormats.ToExtendedString());
|
||||
return Decision.Reject("Custom Formats {0} not wanted in profile", notWantedFormats.ToExtendedString());
|
||||
}
|
||||
|
||||
return Decision.Accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user