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.
41 lines
1.2 KiB
41 lines
1.2 KiB
using System.Linq;
|
|
using NLog;
|
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
|
using NzbDrone.Core.Parser.Model;
|
|
using NzbDrone.Core.Music;
|
|
|
|
|
|
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
|
{
|
|
public class AlbumRequestedSpecification : IDecisionEngineSpecification
|
|
{
|
|
private readonly Logger _logger;
|
|
|
|
public AlbumRequestedSpecification(Logger logger)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
public RejectionType Type => RejectionType.Permanent;
|
|
|
|
public Decision IsSatisfiedBy(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria)
|
|
{
|
|
if (searchCriteria == null)
|
|
{
|
|
return Decision.Accept();
|
|
}
|
|
|
|
var criteriaAlbum = searchCriteria.Albums.Select(v => v.Id).ToList();
|
|
var remoteAlbums = remoteAlbum.Albums.Select(v => v.Id).ToList();
|
|
|
|
if (!criteriaAlbum.Intersect(remoteAlbums).Any())
|
|
{
|
|
_logger.Debug("Release rejected since the album wasn't requested: {0}", remoteAlbum.ParsedAlbumInfo);
|
|
return Decision.Reject("Album wasn't requested");
|
|
}
|
|
|
|
return Decision.Accept();
|
|
}
|
|
}
|
|
}
|