-
-
Notifications
You must be signed in to change notification settings - Fork 242
/
DiscographySpecification.cs
38 lines (32 loc) · 1.33 KB
/
DiscographySpecification.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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();
}
}
}