1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-01 08:22:35 +01:00
Sonarr/NzbDrone.Core/IndexerSearch/SeriesSearchService.cs
2013-07-21 19:52:53 -07:00

38 lines
1.4 KiB
C#

using System.Linq;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Download;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.IndexerSearch
{
public class SeriesSearchService : IExecute<SeriesSearchCommand>
{
private readonly ISeasonService _seasonService;
private readonly ISearchForNzb _nzbSearchService;
private readonly IDownloadApprovedReports _downloadApprovedReports;
public SeriesSearchService(ISeasonService seasonService,
ISearchForNzb nzbSearchService,
IDownloadApprovedReports downloadApprovedReports)
{
_seasonService = seasonService;
_nzbSearchService = nzbSearchService;
_downloadApprovedReports = downloadApprovedReports;
}
public void Execute(SeriesSearchCommand message)
{
var seasons = _seasonService.GetSeasonsBySeries(message.SeriesId)
.Where(s => s.SeasonNumber > 0)
.OrderBy(s => s.SeasonNumber)
.ToList();
foreach (var season in seasons)
{
var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, season.SeasonNumber);
_downloadApprovedReports.DownloadApproved(decisions);
}
}
}
}