mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-01-03 22:36:22 +01:00
Rarbg Rate Limit Tweaks, Additional back-off level
This commit is contained in:
parent
de2fd92b6f
commit
5cc044aa8f
3 changed files with 5 additions and 15 deletions
|
|
@ -107,7 +107,6 @@ protected override async Task<IndexerQueryResult> FetchPage(IndexerRequest reque
|
|||
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<RarbgResponse>(response.HttpResponse);
|
||||
|
||||
if (jsonResponse.Resource.error_code.HasValue)
|
||||
|
|
@ -126,7 +125,7 @@ protected override async Task<IndexerQueryResult> FetchPage(IndexerRequest reque
|
|||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,19 +23,15 @@ public RarbgParser(IndexerCapabilities capabilities)
|
|||
public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
||||
{
|
||||
var results = new List<ReleaseInfo>();
|
||||
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 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
|
||||
var jsonResponse = new HttpResponse<RarbgResponse>(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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue