mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 13:33:34 -07:00
cleaned up parsing logic and structure.
This commit is contained in:
parent
cd2761d07d
commit
6e88f55a54
120 changed files with 2149 additions and 3064 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue