|
|
@ -11,7 +11,12 @@ using NzbDrone.Core.Tv;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.IndexerSearch
|
|
|
|
namespace NzbDrone.Core.IndexerSearch
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class MissingEpisodeSearchService : IExecute<EpisodeSearchCommand>, IExecute<MissingEpisodeSearchCommand>
|
|
|
|
public interface IEpisodeSearchService
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
void MissingEpisodesAiredAfter(DateTime dateTime);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class MissingEpisodeSearchService : IEpisodeSearchService, IExecute<EpisodeSearchCommand>, IExecute<MissingEpisodeSearchCommand>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly ISearchForNzb _nzbSearchService;
|
|
|
|
private readonly ISearchForNzb _nzbSearchService;
|
|
|
|
private readonly IDownloadApprovedReports _downloadApprovedReports;
|
|
|
|
private readonly IDownloadApprovedReports _downloadApprovedReports;
|
|
|
@ -32,6 +37,26 @@ namespace NzbDrone.Core.IndexerSearch
|
|
|
|
_logger = logger;
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void MissingEpisodesAiredAfter(DateTime dateTime)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var missing = _episodeService.EpisodesBetweenDates(dateTime, DateTime.UtcNow)
|
|
|
|
|
|
|
|
.Where(e => !e.HasFile &&
|
|
|
|
|
|
|
|
!_queueService.GetQueue().Select(q => q.Episode.Id).Contains(e.Id))
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var downloadedCount = 0;
|
|
|
|
|
|
|
|
_logger.Info("Searching for {0} missing episodes since last RSS Sync", missing.Count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var episode in missing)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var decisions = _nzbSearchService.EpisodeSearch(episode);
|
|
|
|
|
|
|
|
var downloaded = _downloadApprovedReports.DownloadApproved(decisions);
|
|
|
|
|
|
|
|
downloadedCount += downloaded.Count;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.ProgressInfo("Completed search for {0} episodes. {1} reports downloaded.", missing.Count, downloadedCount);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Execute(EpisodeSearchCommand message)
|
|
|
|
public void Execute(EpisodeSearchCommand message)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach (var episodeId in message.EpisodeIds)
|
|
|
|
foreach (var episodeId in message.EpisodeIds)
|
|
|
@ -57,9 +82,9 @@ namespace NzbDrone.Core.IndexerSearch
|
|
|
|
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));
|
|
|
|
var missing = episodes.Where(e => !_queueService.GetQueue().Select(q => q.Episode.Id).Contains(e.Id)).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
_logger.ProgressInfo("Performing missing search for {0} episodes", episodes.Count);
|
|
|
|
_logger.ProgressInfo("Performing missing search for {0} episodes", missing.Count);
|
|
|
|
var downloadedCount = 0;
|
|
|
|
var downloadedCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
//Limit requests to indexers at 100 per minute
|
|
|
|
//Limit requests to indexers at 100 per minute
|
|
|
@ -71,12 +96,10 @@ namespace NzbDrone.Core.IndexerSearch
|
|
|
|
var decisions = _nzbSearchService.EpisodeSearch(episode);
|
|
|
|
var decisions = _nzbSearchService.EpisodeSearch(episode);
|
|
|
|
var downloaded = _downloadApprovedReports.DownloadApproved(decisions);
|
|
|
|
var downloaded = _downloadApprovedReports.DownloadApproved(decisions);
|
|
|
|
downloadedCount += downloaded.Count;
|
|
|
|
downloadedCount += downloaded.Count;
|
|
|
|
|
|
|
|
|
|
|
|
_logger.ProgressInfo("Episode search completed. {0} reports downloaded.", downloaded.Count);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_logger.ProgressInfo("Completed missing search for {0} episodes. {1} reports downloaded.", episodes.Count, downloadedCount);
|
|
|
|
_logger.ProgressInfo("Completed missing search for {0} episodes. {1} reports downloaded.", missing.Count, downloadedCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|