sonarr-repo-only/NzbDrone.Core/DecisionEngine/QualityUpgradeSpecification.cs

37 lines
1.0 KiB
C#
Raw Normal View History

using System.Linq;
using NLog;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
2012-04-15 01:09:51 +00:00
using NzbDrone.Core.Repository.Quality;
2013-02-19 02:19:38 +00:00
namespace NzbDrone.Core.DecisionEngine
{
2012-04-15 01:09:51 +00:00
public class QualityUpgradeSpecification
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
2012-10-13 21:15:21 +00:00
public virtual bool IsSatisfiedBy(QualityModel currentQuality, QualityModel newQuality, QualityTypes cutOff)
{
2012-04-15 01:09:51 +00:00
if (currentQuality >= newQuality)
{
2012-04-15 01:09:51 +00:00
logger.Trace("existing item has better or equal quality. skipping");
return false;
}
2012-10-14 00:36:16 +00:00
if (currentQuality.Quality == newQuality.Quality && newQuality.Proper)
2012-04-15 01:09:51 +00:00
{
logger.Trace("Upgrading existing item to proper.");
return true;
}
2012-10-14 00:36:16 +00:00
if (currentQuality.Quality >= cutOff)
2012-04-15 01:09:51 +00:00
{
logger.Trace("Existing item meets cut-off. skipping.");
return false;
}
return true;
}
}
}