Merge pull request #598 from vertigo235/delay-profile-patch

Delay Profile: Upgradable Check Fix
pull/2/head
Devin Buhl 8 years ago committed by GitHub
commit 520836f475

@ -36,7 +36,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
return Decision.Accept();
}
public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria)
public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria)
{
if (subject.Movie.MovieFile.Value != null)
{

@ -39,7 +39,13 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
var profile = subject.Movie.Profile.Value;
var delayProfile = _delayProfileService.BestForTags(subject.Movie.Tags);
var delay = delayProfile.GetProtocolDelay(subject.Release.DownloadProtocol);
var isPreferredProtocol = subject.Release.DownloadProtocol == delayProfile.PreferredProtocol;
var isPreferredProtocol = subject.Release.DownloadProtocol == delayProfile.PreferredProtocol;
// Preferred word count
var title = subject.Release.Title;
var preferredWords = subject.Movie.Profile.Value.PreferredTags;
var preferredCount = preferredWords.AsEnumerable().Count(w => title.ToLower().Contains(w.ToLower()));
if (delay == 0)
{
@ -49,7 +55,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
var comparer = new QualityModelComparer(profile);
if (isPreferredProtocol)
if (isPreferredProtocol && (subject.Movie.MovieFileId != 0) && (preferredCount > 0 || preferredWords == null))
{
var upgradable = _qualityUpgradableSpecification.IsUpgradable(profile, subject.Movie.MovieFile.Value.Quality, subject.ParsedMovieInfo.Quality);
@ -59,7 +65,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
if (revisionUpgrade)
{
_logger.Debug("New quality is a better revision for existing quality, skipping delay");
_logger.Debug("New quality is a better revision for existing quality and preferred word count is {0}, skipping delay", preferredCount);
return Decision.Accept();
}
}
@ -68,11 +74,11 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
// If quality meets or exceeds the best allowed quality in the profile accept it immediately
var bestQualityInProfile = new QualityModel(profile.LastAllowedQuality());
var isBestInProfile = comparer.Compare(subject.ParsedMovieInfo.Quality, bestQualityInProfile) >= 0;
var isBestInProfile = comparer.Compare(subject.ParsedMovieInfo.Quality, bestQualityInProfile) >= 0;
if (isBestInProfile && isPreferredProtocol)
if (isBestInProfile && isPreferredProtocol && (preferredCount > 0 || preferredWords == null))
{
_logger.Debug("Quality is highest in profile for preferred protocol, will not delay");
_logger.Debug("Quality is highest in profile for preferred protocol and preferred word count is {0}, will not delay.", preferredCount);
return Decision.Accept();
}

Loading…
Cancel
Save