2013-09-04 05:01:28 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Common.Instrumentation;
|
|
|
|
|
using NzbDrone.Common.Messaging;
|
2013-06-29 00:35:21 +00:00
|
|
|
|
using NzbDrone.Core.Download;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.IndexerSearch
|
|
|
|
|
{
|
|
|
|
|
public class EpisodeSearchService : IExecute<EpisodeSearchCommand>
|
|
|
|
|
{
|
|
|
|
|
private readonly ISearchForNzb _nzbSearchService;
|
|
|
|
|
private readonly IDownloadApprovedReports _downloadApprovedReports;
|
2013-09-04 05:01:28 +00:00
|
|
|
|
private readonly Logger _logger;
|
2013-06-29 00:35:21 +00:00
|
|
|
|
|
2013-09-04 05:01:28 +00:00
|
|
|
|
public EpisodeSearchService(ISearchForNzb nzbSearchService,
|
|
|
|
|
IDownloadApprovedReports downloadApprovedReports,
|
|
|
|
|
Logger logger)
|
2013-06-29 00:35:21 +00:00
|
|
|
|
{
|
|
|
|
|
_nzbSearchService = nzbSearchService;
|
|
|
|
|
_downloadApprovedReports = downloadApprovedReports;
|
2013-09-04 05:01:28 +00:00
|
|
|
|
_logger = logger;
|
2013-06-29 00:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Execute(EpisodeSearchCommand message)
|
|
|
|
|
{
|
|
|
|
|
var decisions = _nzbSearchService.EpisodeSearch(message.EpisodeId);
|
2013-09-04 05:01:28 +00:00
|
|
|
|
var downloaded = _downloadApprovedReports.DownloadApproved(decisions);
|
|
|
|
|
|
|
|
|
|
_logger.Complete("Episode search completed. {0} reports downloaded.", downloaded.Count);
|
2013-06-29 00:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|