Fix downloading releases without an indexer

This commit is contained in:
Bogdan 2023-05-01 20:05:52 +03:00 committed by Qstick
parent b0773ae7e3
commit ca8b26138e
3 changed files with 9 additions and 3 deletions

View File

@ -71,7 +71,6 @@ namespace NzbDrone.Core.Download
// Get the seed configuration for this release. // Get the seed configuration for this release.
remoteEpisode.SeedConfiguration = _seedConfigProvider.GetSeedConfiguration(remoteEpisode); remoteEpisode.SeedConfiguration = _seedConfigProvider.GetSeedConfiguration(remoteEpisode);
var indexer = _indexerFactory.GetInstance(_indexerFactory.Get(remoteEpisode.Release.IndexerId));
// Limit grabs to 2 per second. // Limit grabs to 2 per second.
if (remoteEpisode.Release.DownloadUrl.IsNotNullOrWhiteSpace() && !remoteEpisode.Release.DownloadUrl.StartsWith("magnet:")) if (remoteEpisode.Release.DownloadUrl.IsNotNullOrWhiteSpace() && !remoteEpisode.Release.DownloadUrl.StartsWith("magnet:"))
@ -80,6 +79,13 @@ namespace NzbDrone.Core.Download
_rateLimitService.WaitAndPulse(url.Host, TimeSpan.FromSeconds(2)); _rateLimitService.WaitAndPulse(url.Host, TimeSpan.FromSeconds(2));
} }
IIndexer indexer = null;
if (remoteEpisode.Release.IndexerId > 0)
{
indexer = _indexerFactory.GetInstance(_indexerFactory.Get(remoteEpisode.Release.IndexerId));
}
string downloadClientId; string downloadClientId;
try try
{ {

View File

@ -127,7 +127,7 @@ namespace NzbDrone.Core.Download
try try
{ {
var request = indexer.GetDownloadRequest(torrentUrl); var request = indexer?.GetDownloadRequest(torrentUrl) ?? new HttpRequest(torrentUrl);
request.RateLimitKey = remoteEpisode?.Release?.IndexerId.ToString(); request.RateLimitKey = remoteEpisode?.Release?.IndexerId.ToString();
request.Headers.Accept = "application/x-bittorrent"; request.Headers.Accept = "application/x-bittorrent";
request.AllowAutoRedirect = false; request.AllowAutoRedirect = false;

View File

@ -43,7 +43,7 @@ namespace NzbDrone.Core.Download
try try
{ {
var request = indexer.GetDownloadRequest(url); var request = indexer?.GetDownloadRequest(url) ?? new HttpRequest(url);
request.RateLimitKey = remoteEpisode?.Release?.IndexerId.ToString(); request.RateLimitKey = remoteEpisode?.Release?.IndexerId.ToString();
nzbData = _httpClient.Get(request).ResponseData; nzbData = _httpClient.Get(request).ResponseData;