Fixed: (Indexers) Hide errors with SuppressHttpErrorStatusCodes

This commit is contained in:
Bogdan
2023-04-23 06:56:24 +03:00
parent 43f881c442
commit d2ba52cdce
4 changed files with 8 additions and 8 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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;
} }

View File

@@ -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)
{ {