mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-26 20:11:49 +02:00
rewrite of indexer/episode search
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
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
|
||||
@@ -14,9 +17,23 @@ namespace NzbDrone.Core.DecisionEngine
|
||||
}
|
||||
}
|
||||
|
||||
public DownloadDecision(params string[] rejections)
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user