Fixed: (Indexers) Hide errors with SuppressHttpErrorStatusCodes

pull/1624/head
Bogdan 2 years ago
parent 43f881c442
commit d2ba52cdce

@ -118,12 +118,14 @@ namespace NzbDrone.Core.History
public void Handle(IndexerQueryEvent message) public void Handle(IndexerQueryEvent message)
{ {
var response = message.QueryResult.Response;
var history = new History var history = new History
{ {
Date = DateTime.UtcNow, Date = DateTime.UtcNow,
IndexerId = message.IndexerId, IndexerId = message.IndexerId,
EventType = message.Query.IsRssSearch ? HistoryEventType.IndexerRss : HistoryEventType.IndexerQuery, EventType = message.Query.IsRssSearch ? HistoryEventType.IndexerRss : HistoryEventType.IndexerQuery,
Successful = message.QueryResult.Response?.StatusCode == HttpStatusCode.OK Successful = response?.StatusCode == HttpStatusCode.OK || (response is { Request: { SuppressHttpError: true, SuppressHttpErrorStatusCodes: not null } } && response.Request.SuppressHttpErrorStatusCodes.Contains(response.StatusCode))
}; };
if (message.Query is MovieSearchCriteria) if (message.Query is MovieSearchCriteria)

@ -67,9 +67,9 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz
_logger.Debug("Avistaz authentication succeeded."); _logger.Debug("Avistaz authentication succeeded.");
} }
protected override bool CheckIfLoginNeeded(HttpResponse response) protected override bool CheckIfLoginNeeded(HttpResponse httpResponse)
{ {
return response.StatusCode == HttpStatusCode.Unauthorized || response.StatusCode == HttpStatusCode.PreconditionFailed; return httpResponse.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.PreconditionFailed;
} }
protected override void ModifyRequest(IndexerRequest request) protected override void ModifyRequest(IndexerRequest request)

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net;
using NLog; using NLog;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http; using NzbDrone.Common.Http;
@ -85,10 +86,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz
var request = new IndexerRequest(searchUrl, HttpAccept.Html); var request = new IndexerRequest(searchUrl, HttpAccept.Html);
request.HttpRequest.Headers.Add("Authorization", $"Bearer {Settings.Token}"); request.HttpRequest.Headers.Add("Authorization", $"Bearer {Settings.Token}");
if (searchParameters.Any(p => p.Key is "imdb" or "tmdb" or "tvdb")) request.HttpRequest.SuppressHttpErrorStatusCodes = new[] { HttpStatusCode.NotFound };
{
request.HttpRequest.LogHttpError = false;
}
yield return request; yield return request;
} }

@ -508,7 +508,7 @@ namespace NzbDrone.Core.Indexers
} }
// Throw common http errors here before we try to parse // Throw common http errors here before we try to parse
if (response.HasHttpError) if (response.HasHttpError && (request.HttpRequest.SuppressHttpErrorStatusCodes == null || !request.HttpRequest.SuppressHttpErrorStatusCodes.Contains(response.StatusCode)))
{ {
if (response.Request.LogHttpError) if (response.Request.LogHttpError)
{ {

Loading…
Cancel
Save