You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
39 lines
1.3 KiB
using System;
|
|
using System.Linq;
|
|
using NLog;
|
|
using NzbDrone.Common.Extensions;
|
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
namespace NzbDrone.Core.DecisionEngine.Specifications
|
|
{
|
|
public class DiscographySpecification : IDecisionEngineSpecification
|
|
{
|
|
private readonly Logger _logger;
|
|
|
|
public DiscographySpecification(Logger logger)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
public SpecificationPriority Priority => SpecificationPriority.Default;
|
|
public RejectionType Type => RejectionType.Permanent;
|
|
|
|
public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria)
|
|
{
|
|
if (subject.ParsedAlbumInfo.Discography)
|
|
{
|
|
_logger.Debug("Checking if all albums in discography release have released. {0}", subject.Release.Title);
|
|
|
|
if (subject.Albums.Any(e => !e.ReleaseDate.HasValue || e.ReleaseDate.Value.After(DateTime.UtcNow.AddHours(24))))
|
|
{
|
|
_logger.Debug("Discography release {0} rejected. All albums haven't released yet.", subject.Release.Title);
|
|
return Decision.Reject("Discography release rejected. All albums haven't released yet.");
|
|
}
|
|
}
|
|
|
|
return Decision.Accept();
|
|
}
|
|
}
|
|
}
|