You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
42 lines
1.2 KiB
using System.Linq;
|
|
using NzbDrone.Common.Extensions;
|
|
using NzbDrone.Core.Download;
|
|
using NzbDrone.Core.History;
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators
|
|
{
|
|
public class AggregateReleaseInfo : IAggregateLocalEpisode
|
|
{
|
|
public int Order => 1;
|
|
|
|
private readonly IHistoryService _historyService;
|
|
|
|
public AggregateReleaseInfo(IHistoryService historyService)
|
|
{
|
|
_historyService = historyService;
|
|
}
|
|
|
|
public LocalEpisode Aggregate(LocalEpisode localEpisode, DownloadClientItem downloadClientItem)
|
|
{
|
|
if (downloadClientItem == null)
|
|
{
|
|
return localEpisode;
|
|
}
|
|
|
|
var grabbedHistories = _historyService.FindByDownloadId(downloadClientItem.DownloadId)
|
|
.Where(h => h.EventType == EpisodeHistoryEventType.Grabbed)
|
|
.ToList();
|
|
|
|
if (grabbedHistories.Empty())
|
|
{
|
|
return localEpisode;
|
|
}
|
|
|
|
localEpisode.Release = new GrabbedReleaseInfo(grabbedHistories);
|
|
|
|
return localEpisode;
|
|
}
|
|
}
|
|
}
|