2012-02-07 06:08:07 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
2013-02-27 04:19:22 +01:00
|
|
|
|
using NzbDrone.Core.Qualities;
|
2013-02-19 07:01:03 +01:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2013-02-19 03:19:38 +01:00
|
|
|
|
using NzbDrone.Core.Providers;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
|
2013-02-19 03:19:38 +01:00
|
|
|
|
namespace NzbDrone.Core.DecisionEngine
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
|
|
|
|
public class UpgradePossibleSpecification
|
|
|
|
|
{
|
2013-02-27 04:19:22 +01:00
|
|
|
|
private readonly IQualityProfileService _qualityProvider;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
2013-02-27 04:19:22 +01:00
|
|
|
|
public UpgradePossibleSpecification(IQualityProfileService qualityProvider)
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
|
|
|
|
_qualityProvider = qualityProvider;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UpgradePossibleSpecification()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual bool IsSatisfiedBy(Episode subject)
|
|
|
|
|
{
|
|
|
|
|
//Used to check if the existing episode can be upgraded by searching (Before we search)
|
|
|
|
|
if (subject.EpisodeFileId == 0)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
var profile = _qualityProvider.Get(subject.Series.QualityProfileId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO:How about proper?
|
|
|
|
|
if (subject.EpisodeFile.Quality >= profile.Cutoff)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true; ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|