1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-10 21:12:56 +01:00
Radarr/NzbDrone.Core/Providers/DecisionEngine/UpgradeDiskSpecification.cs
Mark McDowall 5bbe310af5 Merge branch 'xem' into 'master'
Conflicts:
	NzbDrone.Common/DiskProvider.cs
	NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs
	NzbDrone.Core/Providers/DecisionEngine/CustomStartDateSpecification.cs
	NzbDrone.Core/Providers/DiskScanProvider.cs
	NzbDrone.Core/Providers/DownloadProvider.cs
2012-10-20 16:07:04 -07:00

38 lines
1.3 KiB
C#

using System.Linq;
using NLog;
using Ninject;
using NzbDrone.Core.Model;
namespace NzbDrone.Core.Providers.DecisionEngine
{
public class UpgradeDiskSpecification
{
private readonly EpisodeProvider _episodeProvider;
private readonly QualityUpgradeSpecification _qualityUpgradeSpecification;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
[Inject]
public UpgradeDiskSpecification(EpisodeProvider episodeProvider, QualityUpgradeSpecification qualityUpgradeSpecification)
{
_episodeProvider = episodeProvider;
_qualityUpgradeSpecification = qualityUpgradeSpecification;
}
public UpgradeDiskSpecification()
{
}
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
{
foreach (var file in subject.Episodes.Select(c => c.EpisodeFile).Where(c => c != null))
{
logger.Trace("Comparing file quality with report. Existing file is {0} proper:{1}", file.Quality, file.Proper);
if (!_qualityUpgradeSpecification.IsSatisfiedBy(new QualityModel { Quality = file.Quality, Proper = file.Proper }, subject.Quality, subject.Series.QualityProfile.Cutoff))
return false;
}
return true;
}
}
}