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.
Radarr/NzbDrone.Core/IndexerSearch/SeriesSearchService.cs

45 lines
1.6 KiB

using System.Linq;
using NLog;
using NzbDrone.Core.Download;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Messaging;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.IndexerSearch
{
public class SeriesSearchService : IExecute<SeriesSearchCommand>
{
private readonly ISeriesService _seriesService;
private readonly ISearchForNzb _nzbSearchService;
private readonly IDownloadApprovedReports _downloadApprovedReports;
private readonly Logger _logger;
public SeriesSearchService(ISeriesService seriesService,
ISearchForNzb nzbSearchService,
IDownloadApprovedReports downloadApprovedReports,
Logger logger)
{
_seriesService = seriesService;
_nzbSearchService = nzbSearchService;
_downloadApprovedReports = downloadApprovedReports;
_logger = logger;
}
public void Execute(SeriesSearchCommand message)
{
var series = _seriesService.GetSeries(message.SeriesId);
var downloadedCount = 0;
foreach (var season in series.Seasons)
{
var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, season.SeasonNumber);
downloadedCount += _downloadApprovedReports.DownloadApproved(decisions).Count;
}
_logger.ProgressInfo("Series search completed. {0} reports downloaded.", downloadedCount);
}
}
}