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.
Lidarr/NzbDrone.Core/DecisionEngine/DownloadDecision.cs

39 lines
1.1 KiB

using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Model;
namespace NzbDrone.Core.DecisionEngine
{
public class DownloadDecision
{
public IndexerParseResult ParseResult { get; private set; }
public IEnumerable<string> Rejections { get; private set; }
public bool Approved
{
get
{
return !Rejections.Any();
}
}
public DownloadDecision(IndexerParseResult parseResult, params string[] rejections)
{
ParseResult = parseResult;
Rejections = rejections.ToList();
}
public static IndexerParseResult PickBestReport(IEnumerable<DownloadDecision> downloadDecisions)
{
var reports = downloadDecisions
.Where(c => c.Approved)
.Select(c => c.ParseResult)
.OrderByDescending(c => c.Quality)
.ThenBy(c => c.EpisodeNumbers.MinOrDefault())
.ThenBy(c => c.Age);
return reports.SingleOrDefault();
}
}
}