1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 20:42:37 +01:00
Radarr/NzbDrone.Core/DecisionEngine/DownloadDecision.cs

39 lines
1.1 KiB
C#
Raw Normal View History

2013-03-07 02:51:47 +01:00
using System.Collections.Generic;
using System.Linq;
2013-04-07 09:30:37 +02:00
using NzbDrone.Core.Model;
2013-03-07 02:51:47 +01:00
namespace NzbDrone.Core.DecisionEngine
{
public class DownloadDecision
{
2013-04-07 09:30:37 +02:00
public EpisodeParseResult ParseResult { get; private set; }
2013-03-07 02:51:47 +01:00
public IEnumerable<string> Rejections { get; private set; }
2013-04-07 09:30:37 +02:00
2013-03-07 02:51:47 +01:00
public bool Approved
{
get
{
return !Rejections.Any();
}
}
2013-04-07 09:30:37 +02:00
public DownloadDecision(EpisodeParseResult parseResult, params string[] rejections)
2013-03-07 02:51:47 +01:00
{
2013-04-07 09:30:37 +02:00
ParseResult = parseResult;
2013-03-07 02:51:47 +01:00
Rejections = rejections.ToList();
}
2013-04-07 09:30:37 +02:00
public static EpisodeParseResult 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();
}
2013-03-07 02:51:47 +01:00
}
}