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:
parent
492ffb5714
commit
6133bc6db7
@ -6,6 +6,7 @@
|
||||
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 @@ public class MissingEpisodeSearchService : IExecute<EpisodeSearchCommand>, IExec
|
||||
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 @@ public void Execute(MissingEpisodeSearchCommand message)
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user