cleaned up parsing logic and structure.

This commit is contained in:
kay.one 2013-04-14 18:41:39 -07:00
commit 6e88f55a54
120 changed files with 2149 additions and 3064 deletions

View file

@ -1,12 +1,14 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Model;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine
{
public class DownloadDecision
{
public IndexerParseResult ParseResult { get; private set; }
public RemoteEpisode Episode { get; private set; }
public IEnumerable<string> Rejections { get; private set; }
public bool Approved
@ -17,23 +19,10 @@ namespace NzbDrone.Core.DecisionEngine
}
}
public DownloadDecision(IndexerParseResult parseResult, params string[] rejections)
public DownloadDecision(RemoteEpisode episode, params string[] rejections)
{
ParseResult = parseResult;
Episode = episode;
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();
}
}
}