1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone.Core/IndexerSearch/SeriesSearchService.cs

44 lines
1.5 KiB
C#
Raw Normal View History

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