From 9b10cea5567bcc8e87c274ead72543bdce8b06d7 Mon Sep 17 00:00:00 2001 From: Bakerboy448 <55419169+bakerboy448@users.noreply.github.com> Date: Sun, 30 Apr 2023 11:49:36 -0500 Subject: [PATCH] Fixed: Improve Rarbg Rate Limit Messaging --- src/NzbDrone.Core/Indexers/Definitions/Rarbg/Rarbg.cs | 6 ++++-- src/NzbDrone.Core/Indexers/Definitions/Rarbg/RarbgParser.cs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/Rarbg/Rarbg.cs b/src/NzbDrone.Core/Indexers/Definitions/Rarbg/Rarbg.cs index 3455964da..5c1312a28 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Rarbg/Rarbg.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Rarbg/Rarbg.cs @@ -45,15 +45,17 @@ namespace NzbDrone.Core.Indexers.Definitions.Rarbg return new RarbgParser(Capabilities, _logger); } - public static void CheckResponseByStatusCode(IndexerResponse response) + public static void CheckResponseByStatusCode(IndexerResponse response, Logger logger) { var responseCode = (int)response.HttpResponse.StatusCode; switch (responseCode) { case (int)HttpStatusCode.TooManyRequests: + logger.Warn("Indexer API limit reached."); throw new TooManyRequestsException(response.HttpRequest, response.HttpResponse, TimeSpan.FromMinutes(2)); case 520: + logger.Warn("Indexer API error, likely rate limited by origin server."); throw new TooManyRequestsException(response.HttpRequest, response.HttpResponse, TimeSpan.FromMinutes(3)); case (int)HttpStatusCode.OK: break; @@ -116,7 +118,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Rarbg { var response = await base.FetchIndexerResponse(request); - CheckResponseByStatusCode(response); + CheckResponseByStatusCode(response, _logger); // try and recover from token errors var jsonResponse = new HttpResponse(response.HttpResponse); diff --git a/src/NzbDrone.Core/Indexers/Definitions/Rarbg/RarbgParser.cs b/src/NzbDrone.Core/Indexers/Definitions/Rarbg/RarbgParser.cs index a347ae2e7..dc057e40a 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Rarbg/RarbgParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Rarbg/RarbgParser.cs @@ -28,7 +28,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Rarbg { var results = new List(); - Rarbg.CheckResponseByStatusCode(indexerResponse); + Rarbg.CheckResponseByStatusCode(indexerResponse, _logger); var jsonResponse = new HttpResponse(indexerResponse.HttpResponse);