mirror of https://github.com/lidarr/Lidarr
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using NzbDrone.Core.Model;
|
|
|
|
namespace NzbDrone.Core.DecisionEngine
|
|
{
|
|
public class DownloadDecision
|
|
{
|
|
public EpisodeParseResult ParseResult { get; private set; }
|
|
public IEnumerable<string> Rejections { get; private set; }
|
|
|
|
public bool Approved
|
|
{
|
|
get
|
|
{
|
|
return !Rejections.Any();
|
|
}
|
|
}
|
|
|
|
public DownloadDecision(EpisodeParseResult parseResult, params string[] rejections)
|
|
{
|
|
ParseResult = parseResult;
|
|
Rejections = rejections.ToList();
|
|
}
|
|
|
|
|
|
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();
|
|
}
|
|
}
|
|
} |