1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-29 11:05:44 +00:00
Lidarr/NzbDrone.Core/IndexerSearch/SeriesSearchService.cs

47 lines
1.7 KiB
C#
Raw Normal View History

2013-07-22 02:52:53 +00:00
using System.Linq;
using NLog;
using NzbDrone.Common.Instrumentation;
2013-07-22 02:52:53 +00:00
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;
private readonly Logger _logger;
2013-07-22 02:52:53 +00:00
public SeriesSearchService(ISeasonService seasonService,
ISearchForNzb nzbSearchService,
IDownloadApprovedReports downloadApprovedReports,
Logger logger)
2013-07-22 02:52:53 +00:00
{
_seasonService = seasonService;
_nzbSearchService = nzbSearchService;
_downloadApprovedReports = downloadApprovedReports;
_logger = logger;
2013-07-22 02:52:53 +00:00
}
public void Execute(SeriesSearchCommand message)
{
var seasons = _seasonService.GetSeasonsBySeries(message.SeriesId)
.Where(s => s.SeasonNumber > 0)
.OrderBy(s => s.SeasonNumber)
.ToList();
var downloadedCount = 0;
2013-07-22 02:52:53 +00:00
foreach (var season in seasons)
{
var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, season.SeasonNumber);
downloadedCount += _downloadApprovedReports.DownloadApproved(decisions).Count;
2013-07-22 02:52:53 +00:00
}
_logger.Complete("Series search completed. {0} reports downloaded.", downloadedCount);
2013-07-22 02:52:53 +00:00
}
}
}