diff --git a/src/NzbDrone.Core/Indexers/Definitions/Avistaz/AvistazBase.cs b/src/NzbDrone.Core/Indexers/Definitions/Avistaz/AvistazBase.cs index f0158aef4..6461950c9 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Avistaz/AvistazBase.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Avistaz/AvistazBase.cs @@ -98,6 +98,12 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz var jsonResponse = new HttpResponse(ex.Response); return new ValidationFailure(string.Empty, jsonResponse.Resource?.Message ?? "Unauthorized request to indexer"); } + else if (ex.Response.StatusCode == HttpStatusCode.TooManyRequests) + { + _logger.Warn(ex, "Too Many Requests"); + + return new ValidationFailure(string.Empty, "Too Many Requests"); + } else { _logger.Warn(ex, "Unable to connect to indexer"); diff --git a/src/NzbDrone.Core/Indexers/Definitions/Avistaz/AvistazParser.cs b/src/NzbDrone.Core/Indexers/Definitions/Avistaz/AvistazParser.cs index 4bb24fdfd..5c108c6b7 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Avistaz/AvistazParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Avistaz/AvistazParser.cs @@ -24,24 +24,26 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz { var torrentInfos = new List(); - if (indexerResponse.HttpResponse.StatusCode == HttpStatusCode.NotFound) - { - return torrentInfos.ToArray(); - } - - if (indexerResponse.HttpResponse.StatusCode == HttpStatusCode.TooManyRequests) + if (!indexerResponse.HttpResponse.Headers.ContentType.Contains(HttpAccept.Json.Value)) { - throw new RequestLimitReachedException(indexerResponse, "API Request Limit Reached"); + throw new IndexerException(indexerResponse, $"Unexpected response header {indexerResponse.HttpResponse.Headers.ContentType} from API request, expected {HttpAccept.Json.Value}"); } if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) { - throw new IndexerException(indexerResponse, $"Unexpected response status {indexerResponse.HttpResponse.StatusCode} code from API request"); - } + if (indexerResponse.HttpResponse.StatusCode == HttpStatusCode.NotFound) + { + // No results found + return torrentInfos.ToArray(); + } - if (!indexerResponse.HttpResponse.Headers.ContentType.Contains(HttpAccept.Json.Value)) - { - throw new IndexerException(indexerResponse, $"Unexpected response header {indexerResponse.HttpResponse.Headers.ContentType} from API request, expected {HttpAccept.Json.Value}"); + HttpResponse jsonErrorResponse = new HttpResponse(indexerResponse.HttpResponse); + if (indexerResponse.HttpResponse.StatusCode == HttpStatusCode.Unauthorized) + { + throw new IndexerAuthException(string.Empty, jsonErrorResponse.Resource?.Message ?? "Unauthorized request to indexer"); + } + + throw new IndexerException(indexerResponse, $"Unexpected response status {indexerResponse.HttpResponse.StatusCode} code from API request"); } var jsonResponse = new HttpResponse(indexerResponse.HttpResponse);