1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone.Core/DecisionEngine/DownloadDirector.cs

32 lines
977 B
C#
Raw Normal View History

2013-03-07 04:51:47 +03:00
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Model;
namespace NzbDrone.Core.DecisionEngine
{
public interface IDownloadDirector
{
DownloadDecision GetDownloadDecision(EpisodeParseResult episodeParseResult);
}
public class DownloadDirector : IDownloadDirector
{
private readonly IEnumerable<IFetchableSpecification> _specifications;
public DownloadDirector(IEnumerable<IFetchableSpecification> specifications)
{
_specifications = specifications;
}
public DownloadDecision GetDownloadDecision(EpisodeParseResult episodeParseResult)
{
var rejections = _specifications
.Where(spec => !spec.IsSatisfiedBy(episodeParseResult))
.Select(spec => spec.RejectionReason).ToArray();
episodeParseResult.Decision = new DownloadDecision(rejections);
return episodeParseResult.Decision;
}
}
}