mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-22 22:14:44 -04:00
74a38415cf
Indexes are created with the same uniqueness when copying a table New: Non-English episode support New: Renamed Quality Profiles to Profiles and made them more powerful New: Configurable wait time before grabbing a release to wait for a better quality
62 lines
2.0 KiB
C#
62 lines
2.0 KiB
C#
using System;
|
|
using System.Linq;
|
|
using NLog;
|
|
using NzbDrone.Core.Configuration;
|
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
|
|
{
|
|
public class ProperSpecification : IDecisionEngineSpecification
|
|
{
|
|
private readonly QualityUpgradableSpecification _qualityUpgradableSpecification;
|
|
private readonly IConfigService _configService;
|
|
private readonly Logger _logger;
|
|
|
|
public ProperSpecification(QualityUpgradableSpecification qualityUpgradableSpecification, IConfigService configService, Logger logger)
|
|
{
|
|
_qualityUpgradableSpecification = qualityUpgradableSpecification;
|
|
_configService = configService;
|
|
_logger = logger;
|
|
}
|
|
|
|
public string RejectionReason
|
|
{
|
|
get
|
|
{
|
|
return "Proper for old episode";
|
|
}
|
|
}
|
|
|
|
public RejectionType Type { get { return RejectionType.Permanent; } }
|
|
|
|
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
|
|
{
|
|
if (searchCriteria != null)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value))
|
|
{
|
|
if (_qualityUpgradableSpecification.IsProperUpgrade(file.Quality, subject.ParsedEpisodeInfo.Quality))
|
|
{
|
|
if (file.DateAdded < DateTime.Today.AddDays(-7))
|
|
{
|
|
_logger.Debug("Proper for old file, rejecting: {0}", subject);
|
|
return false;
|
|
}
|
|
|
|
if (!_configService.AutoDownloadPropers)
|
|
{
|
|
_logger.Debug("Auto downloading of propers is disabled");
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|