|
|
|
@ -6,6 +6,7 @@ using NzbDrone.Core.Datastore;
|
|
|
|
|
using NzbDrone.Core.Download;
|
|
|
|
|
using NzbDrone.Core.Instrumentation.Extensions;
|
|
|
|
|
using NzbDrone.Core.Messaging.Commands;
|
|
|
|
|
using NzbDrone.Core.Queue;
|
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.IndexerSearch
|
|
|
|
@ -15,16 +16,19 @@ namespace NzbDrone.Core.IndexerSearch
|
|
|
|
|
private readonly ISearchForNzb _nzbSearchService;
|
|
|
|
|
private readonly IDownloadApprovedReports _downloadApprovedReports;
|
|
|
|
|
private readonly IEpisodeService _episodeService;
|
|
|
|
|
private readonly IQueueService _queueService;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
public MissingEpisodeSearchService(ISearchForNzb nzbSearchService,
|
|
|
|
|
IDownloadApprovedReports downloadApprovedReports,
|
|
|
|
|
IEpisodeService episodeService,
|
|
|
|
|
IQueueService queueService,
|
|
|
|
|
Logger logger)
|
|
|
|
|
{
|
|
|
|
|
_nzbSearchService = nzbSearchService;
|
|
|
|
|
_downloadApprovedReports = downloadApprovedReports;
|
|
|
|
|
_episodeService = episodeService;
|
|
|
|
|
_queueService = queueService;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -53,13 +57,15 @@ namespace NzbDrone.Core.IndexerSearch
|
|
|
|
|
FilterExpression = v => v.Monitored == true && v.Series.Monitored == true
|
|
|
|
|
}).Records.ToList();
|
|
|
|
|
|
|
|
|
|
var missing = episodes.Where(e => _queueService.GetQueue().Select(q => q.Episode.Id).Contains(e.Id));
|
|
|
|
|
|
|
|
|
|
_logger.ProgressInfo("Performing missing search for {0} episodes", episodes.Count);
|
|
|
|
|
var downloadedCount = 0;
|
|
|
|
|
|
|
|
|
|
//Limit requests to indexers at 100 per minute
|
|
|
|
|
using (var rateGate = new RateGate(100, TimeSpan.FromSeconds(60)))
|
|
|
|
|
{
|
|
|
|
|
foreach (var episode in episodes)
|
|
|
|
|
foreach (var episode in missing)
|
|
|
|
|
{
|
|
|
|
|
rateGate.WaitToProceed();
|
|
|
|
|
var decisions = _nzbSearchService.EpisodeSearch(episode);
|
|
|
|
|