mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-23 06:45:19 -07:00
Merge pull request #598 from vertigo235/delay-profile-patch
Delay Profile: Upgradable Check Fix
This commit is contained in:
commit
520836f475
2 changed files with 13 additions and 7 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,12 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
|
|||
var delay = delayProfile.GetProtocolDelay(subject.Release.DownloadProtocol);
|
||||
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)
|
||||
{
|
||||
_logger.Debug("Profile does not require a waiting period before download for {0}.", subject.Release.DownloadProtocol);
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -70,9 +76,9 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
|
|||
var bestQualityInProfile = new QualityModel(profile.LastAllowedQuality());
|
||||
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…
Add table
Add a link
Reference in a new issue