Use proxied requests for indexers

pull/2054/head v1.14.2.4318
Bogdan 8 months ago
parent a25e79031f
commit 882152b911

@ -18,6 +18,7 @@ using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Indexers.Definitions
{
@ -43,7 +44,7 @@ namespace NzbDrone.Core.Indexers.Definitions
public override IParseIndexerResponse GetParser()
{
return new AnidubParser(Settings, Capabilities.Categories, RateLimit, _httpClient, _logger);
return new AnidubParser(Definition, Settings, Capabilities.Categories, RateLimit, _httpClient, _logger);
}
protected override async Task DoLogin()
@ -244,6 +245,7 @@ namespace NzbDrone.Core.Indexers.Definitions
public class AnidubParser : IParseIndexerResponse
{
private readonly ProviderDefinition _definition;
private readonly UserPassTorrentBaseSettings _settings;
private readonly IndexerCapabilitiesCategories _categories;
private readonly TimeSpan _rateLimit;
@ -270,8 +272,9 @@ namespace NzbDrone.Core.Indexers.Definitions
{ "/anons_ongoing", "12" }
};
public AnidubParser(UserPassTorrentBaseSettings settings, IndexerCapabilitiesCategories categories, TimeSpan rateLimit, IIndexerHttpClient httpClient, Logger logger)
public AnidubParser(ProviderDefinition definition, UserPassTorrentBaseSettings settings, IndexerCapabilitiesCategories categories, TimeSpan rateLimit, IIndexerHttpClient httpClient, Logger logger)
{
_definition = definition;
_settings = settings;
_categories = categories;
_rateLimit = rateLimit;
@ -479,7 +482,7 @@ namespace NzbDrone.Core.Indexers.Definitions
.Build();
var releaseIndexerRequest = new IndexerRequest(releaseRequest);
var releaseResponse = new IndexerResponse(releaseIndexerRequest, _httpClient.Execute(releaseIndexerRequest.HttpRequest));
var releaseResponse = new IndexerResponse(releaseIndexerRequest, _httpClient.ExecuteProxied(releaseIndexerRequest.HttpRequest, _definition));
// Throw common http errors here before we try to parse
if (releaseResponse.HttpResponse.HasHttpError)

@ -14,6 +14,7 @@ using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Indexers.Definitions
{
@ -40,7 +41,7 @@ namespace NzbDrone.Core.Indexers.Definitions
public override IParseIndexerResponse GetParser()
{
return new AnimediaParser(Settings, Capabilities.Categories, RateLimit, _httpClient);
return new AnimediaParser(Definition, Settings, Capabilities.Categories, RateLimit, _httpClient);
}
private IndexerCapabilities SetCapabilities()
@ -144,6 +145,7 @@ namespace NzbDrone.Core.Indexers.Definitions
public class AnimediaParser : IParseIndexerResponse
{
private readonly ProviderDefinition _definition;
private readonly NoAuthTorrentBaseSettings _settings;
private readonly IndexerCapabilitiesCategories _categories;
private readonly TimeSpan _rateLimit;
@ -157,8 +159,9 @@ namespace NzbDrone.Core.Indexers.Definitions
private static readonly Regex CategorieOVARegex = new Regex(@"ОВА|OVA|ОНА|ONA|Special", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex CategorieDoramaRegex = new Regex(@"Дорама", RegexOptions.Compiled | RegexOptions.IgnoreCase);
public AnimediaParser(NoAuthTorrentBaseSettings settings, IndexerCapabilitiesCategories categories, TimeSpan rateLimit, IIndexerHttpClient httpClient)
public AnimediaParser(ProviderDefinition definition, NoAuthTorrentBaseSettings settings, IndexerCapabilitiesCategories categories, TimeSpan rateLimit, IIndexerHttpClient httpClient)
{
_definition = definition;
_settings = settings;
_categories = categories;
_rateLimit = rateLimit;
@ -311,7 +314,7 @@ namespace NzbDrone.Core.Indexers.Definitions
.Build();
var releaseIndexerRequest = new IndexerRequest(releaseRequest);
var releaseResponse = new IndexerResponse(releaseIndexerRequest, _httpClient.Execute(releaseIndexerRequest.HttpRequest));
var releaseResponse = new IndexerResponse(releaseIndexerRequest, _httpClient.ExecuteProxied(releaseIndexerRequest.HttpRequest, _definition));
// Throw common http errors here before we try to parse
if (releaseResponse.HttpResponse.HasHttpError)

@ -205,7 +205,7 @@ namespace NzbDrone.Core.Indexers.Definitions
.AddQueryParam("request", "quick_user")
.Build();
var indexResponse = await _httpClient.ExecuteAsync(request).ConfigureAwait(false);
var indexResponse = await _httpClient.ExecuteProxiedAsync(request, Definition).ConfigureAwait(false);
var index = Json.Deserialize<GazelleGamesUserResponse>(indexResponse.Content);

@ -19,6 +19,7 @@ using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Indexers.Definitions;
@ -50,7 +51,7 @@ public class Shazbat : TorrentIndexerBase<ShazbatSettings>
public override IParseIndexerResponse GetParser()
{
return new ShazbatParser(Settings, RateLimit, _httpClient, _logger);
return new ShazbatParser(Definition, Settings, RateLimit, _httpClient, _logger);
}
protected override async Task DoLogin()
@ -202,6 +203,7 @@ public class ShazbatRequestGenerator : IIndexerRequestGenerator
public class ShazbatParser : IParseIndexerResponse
{
private readonly ProviderDefinition _definition;
private readonly ShazbatSettings _settings;
private readonly TimeSpan _rateLimit;
private readonly IIndexerHttpClient _httpClient;
@ -210,8 +212,9 @@ public class ShazbatParser : IParseIndexerResponse
private readonly Regex _torrentInfoRegex = new (@"\((?<size>\d+)\):(?<seeders>\d+) \/ :(?<leechers>\d+)$", RegexOptions.Compiled);
private readonly HashSet<string> _hdResolutions = new () { "1080p", "1080i", "720p" };
public ShazbatParser(ShazbatSettings settings, TimeSpan rateLimit, IIndexerHttpClient httpClient, Logger logger)
public ShazbatParser(ProviderDefinition definition, ShazbatSettings settings, TimeSpan rateLimit, IIndexerHttpClient httpClient, Logger logger)
{
_definition = definition;
_settings = settings;
_rateLimit = rateLimit;
_httpClient = httpClient;
@ -272,7 +275,7 @@ public class ShazbatParser : IParseIndexerResponse
_logger.Debug("Downloading Feed " + showRequest.ToString());
var releaseRequest = new IndexerRequest(showRequest);
var releaseResponse = new IndexerResponse(releaseRequest, _httpClient.Execute(releaseRequest.HttpRequest));
var releaseResponse = new IndexerResponse(releaseRequest, _httpClient.ExecuteProxied(releaseRequest.HttpRequest, _definition));
if (releaseResponse.HttpResponse.Content.ContainsIgnoreCase("sign in now"))
{

@ -32,7 +32,7 @@ namespace NzbDrone.Core.Indexers.Definitions.TorrentRss
public override IParseIndexerResponse GetParser()
{
return _torrentRssParserFactory.GetParser(Settings);
return _torrentRssParserFactory.GetParser(Settings, Definition);
}
public override IEnumerable<ProviderDefinition> DefaultDefinitions

@ -3,12 +3,13 @@ using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Indexers.Exceptions;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Indexers.Definitions.TorrentRss
{
public interface ITorrentRssParserFactory
{
TorrentRssParser GetParser(TorrentRssIndexerSettings settings);
TorrentRssParser GetParser(TorrentRssIndexerSettings settings, ProviderDefinition definition);
}
public class TorrentRssParserFactory : ITorrentRssParserFactory
@ -26,10 +27,10 @@ namespace NzbDrone.Core.Indexers.Definitions.TorrentRss
_logger = logger;
}
public TorrentRssParser GetParser(TorrentRssIndexerSettings indexerSettings)
public TorrentRssParser GetParser(TorrentRssIndexerSettings indexerSettings, ProviderDefinition definition)
{
var key = indexerSettings.ToJson();
var parserSettings = _settingsCache.Get(key, () => DetectParserSettings(indexerSettings), TimeSpan.FromDays(7));
var parserSettings = _settingsCache.Get(key, () => DetectParserSettings(indexerSettings, definition), TimeSpan.FromDays(7));
if (parserSettings.UseEZTVFormat)
{
@ -51,9 +52,9 @@ namespace NzbDrone.Core.Indexers.Definitions.TorrentRss
};
}
private TorrentRssIndexerParserSettings DetectParserSettings(TorrentRssIndexerSettings indexerSettings)
private TorrentRssIndexerParserSettings DetectParserSettings(TorrentRssIndexerSettings indexerSettings, ProviderDefinition definition)
{
var settings = _torrentRssSettingsDetector.Detect(indexerSettings);
var settings = _torrentRssSettingsDetector.Detect(indexerSettings, definition);
if (settings == null)
{

@ -9,28 +9,29 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers.Exceptions;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Indexers.Definitions.TorrentRss
{
public interface ITorrentRssSettingsDetector
{
TorrentRssIndexerParserSettings Detect(TorrentRssIndexerSettings settings);
TorrentRssIndexerParserSettings Detect(TorrentRssIndexerSettings settings, ProviderDefinition definition);
}
public class TorrentRssSettingsDetector : ITorrentRssSettingsDetector
{
private const long ValidSizeThreshold = 2 * 1024 * 1024;
private readonly IHttpClient _httpClient;
private readonly IIndexerHttpClient _httpClient;
private readonly Logger _logger;
public TorrentRssSettingsDetector(IHttpClient httpClient, Logger logger)
public TorrentRssSettingsDetector(IIndexerHttpClient httpClient, Logger logger)
{
_httpClient = httpClient;
_logger = logger;
}
public TorrentRssIndexerParserSettings Detect(TorrentRssIndexerSettings settings)
public TorrentRssIndexerParserSettings Detect(TorrentRssIndexerSettings settings, ProviderDefinition definition)
{
_logger.Debug("Evaluating TorrentRss feed '{0}'", settings.BaseUrl);
@ -43,7 +44,7 @@ namespace NzbDrone.Core.Indexers.Definitions.TorrentRss
try
{
httpResponse = _httpClient.Execute(request.HttpRequest);
httpResponse = _httpClient.ExecuteProxied(request.HttpRequest, definition);
}
catch (Exception ex)
{

Loading…
Cancel
Save