mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-24 22:55:21 -04:00
Fixed: (Rarbg) Improve RateLimit Handling
Fixed: (Rarbg) Increase delay to 4s to reduce Rate Limiting Fixes #1169
This commit is contained in:
@@ -23,20 +23,32 @@ namespace NzbDrone.Core.Indexers.Rarbg
|
||||
public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
||||
{
|
||||
var results = new List<ReleaseInfo>();
|
||||
var retryTime = TimeSpan.FromMinutes(1);
|
||||
var responseCode = (int)indexerResponse.HttpResponse.StatusCode;
|
||||
|
||||
switch (indexerResponse.HttpResponse.StatusCode)
|
||||
switch (responseCode)
|
||||
{
|
||||
default:
|
||||
if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
throw new IndexerException(indexerResponse, "Indexer API call returned an unexpected StatusCode [{0}]", indexerResponse.HttpResponse.StatusCode);
|
||||
}
|
||||
|
||||
case (int)HttpStatusCode.TooManyRequests:
|
||||
retryTime = TimeSpan.FromMinutes(2);
|
||||
throw new TooManyRequestsException(indexerResponse.HttpRequest, indexerResponse.HttpResponse, retryTime);
|
||||
case 520:
|
||||
retryTime = TimeSpan.FromMinutes(3);
|
||||
throw new TooManyRequestsException(indexerResponse.HttpRequest, indexerResponse.HttpResponse, retryTime);
|
||||
case (int)HttpStatusCode.OK:
|
||||
retryTime = TimeSpan.FromMinutes(5);
|
||||
break;
|
||||
default:
|
||||
throw new IndexerException(indexerResponse, "Indexer API call returned an unexpected StatusCode [{0}]", responseCode);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user