parent
9056bc1747
commit
485fa6a13d
@ -0,0 +1,67 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using NLog;
|
||||||
|
using NzbDrone.Common;
|
||||||
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||||
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||||
|
{
|
||||||
|
public class AnimeVersionUpgradeSpecification : IDecisionEngineSpecification
|
||||||
|
{
|
||||||
|
private readonly QualityUpgradableSpecification _qualityUpgradableSpecification;
|
||||||
|
private readonly Logger _logger;
|
||||||
|
|
||||||
|
public AnimeVersionUpgradeSpecification(QualityUpgradableSpecification qualityUpgradableSpecification, Logger logger)
|
||||||
|
{
|
||||||
|
_qualityUpgradableSpecification = qualityUpgradableSpecification;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string RejectionReason
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Version upgrade for a different release group";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public RejectionType Type { get { return RejectionType.Permanent; } }
|
||||||
|
|
||||||
|
public virtual bool IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
|
||||||
|
{
|
||||||
|
var releaseGroup = subject.ParsedEpisodeInfo.ReleaseGroup;
|
||||||
|
|
||||||
|
if (subject.Series.SeriesType != SeriesTypes.Anime)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value))
|
||||||
|
{
|
||||||
|
if (_qualityUpgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedEpisodeInfo.Quality))
|
||||||
|
{
|
||||||
|
if (file.ReleaseGroup.IsNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
_logger.Debug("Unable to compare release group, existing file's release group is unknown");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (releaseGroup.IsNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
_logger.Debug("Unable to compare release group, release's release group is unknown");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.ReleaseGroup != releaseGroup)
|
||||||
|
{
|
||||||
|
_logger.Debug("Existing Release group is: {0} - release's release group is: {1}", file.ReleaseGroup, releaseGroup);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue