From 5cc044aa8fbc7ba62d9c32442d8125b9b347d28a Mon Sep 17 00:00:00 2001 From: Qstick Date: Mon, 2 Jan 2023 17:16:46 -0600 Subject: [PATCH] Rarbg Rate Limit Tweaks, Additional back-off level --- .../Indexers/Definitions/Rarbg/Rarbg.cs | 3 +-- .../Indexers/Definitions/Rarbg/RarbgParser.cs | 14 ++------------ .../ThingiProvider/Status/EscalationBackOff.cs | 3 ++- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/Rarbg/Rarbg.cs b/src/NzbDrone.Core/Indexers/Definitions/Rarbg/Rarbg.cs index 123547357..82dc52844 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Rarbg/Rarbg.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Rarbg/Rarbg.cs @@ -107,7 +107,6 @@ namespace NzbDrone.Core.Indexers.Rarbg var response = await FetchIndexerResponse(request); // try and recover from token errors - // Response of 200 and rate_limt of 1 requires a 5 minute backoff. Handle in Response Parsing & do not page further if rate_limit is populated. var jsonResponse = new HttpResponse(response.HttpResponse); if (jsonResponse.Resource.error_code.HasValue) @@ -126,7 +125,7 @@ namespace NzbDrone.Core.Indexers.Rarbg } else if (jsonResponse.Resource.error_code == 5) { - _logger.Debug("Rarbg temp rate limit hit, retying request"); + _logger.Debug("Rarbg temp rate limit hit, retrying request"); response = await FetchIndexerResponse(request); } } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Rarbg/RarbgParser.cs b/src/NzbDrone.Core/Indexers/Definitions/Rarbg/RarbgParser.cs index e837279e1..e33f083d8 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Rarbg/RarbgParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Rarbg/RarbgParser.cs @@ -23,19 +23,15 @@ namespace NzbDrone.Core.Indexers.Rarbg public IList ParseResponse(IndexerResponse indexerResponse) { var results = new List(); - var retryTime = TimeSpan.FromMinutes(1); var responseCode = (int)indexerResponse.HttpResponse.StatusCode; switch (responseCode) { case (int)HttpStatusCode.TooManyRequests: - retryTime = TimeSpan.FromMinutes(2); - throw new TooManyRequestsException(indexerResponse.HttpRequest, indexerResponse.HttpResponse, retryTime); + throw new TooManyRequestsException(indexerResponse.HttpRequest, indexerResponse.HttpResponse, TimeSpan.FromMinutes(2)); case 520: - retryTime = TimeSpan.FromMinutes(3); - throw new TooManyRequestsException(indexerResponse.HttpRequest, indexerResponse.HttpResponse, retryTime); + throw new TooManyRequestsException(indexerResponse.HttpRequest, indexerResponse.HttpResponse, TimeSpan.FromMinutes(3)); case (int)HttpStatusCode.OK: - retryTime = TimeSpan.FromMinutes(5); break; default: throw new IndexerException(indexerResponse, "Indexer API call returned an unexpected StatusCode [{0}]", responseCode); @@ -43,12 +39,6 @@ namespace NzbDrone.Core.Indexers.Rarbg var jsonResponse = new HttpResponse(indexerResponse.HttpResponse); - // Handle 200 Rate Limiting - if (jsonResponse.Resource.rate_limit == 1) - { - throw new TooManyRequestsException(indexerResponse.HttpRequest, indexerResponse.HttpResponse, retryTime); - } - if (jsonResponse.Resource.error_code.HasValue) { if (jsonResponse.Resource.error_code == 20 || jsonResponse.Resource.error_code == 8 diff --git a/src/NzbDrone.Core/ThingiProvider/Status/EscalationBackOff.cs b/src/NzbDrone.Core/ThingiProvider/Status/EscalationBackOff.cs index 304613d58..71dafe7e4 100644 --- a/src/NzbDrone.Core/ThingiProvider/Status/EscalationBackOff.cs +++ b/src/NzbDrone.Core/ThingiProvider/Status/EscalationBackOff.cs @@ -1,10 +1,11 @@ -namespace NzbDrone.Core.ThingiProvider.Status +namespace NzbDrone.Core.ThingiProvider.Status { public static class EscalationBackOff { public static readonly int[] Periods = { 0, + 60, 5 * 60, 15 * 60, 30 * 60,