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

Missing episode search will skip already queued releases

This commit is contained in:
Mark McDowall 2014-04-08 17:25:56 -07:00
parent 492ffb5714
commit 6133bc6db7

View File

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