mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
RARBG API request throttling
This commit is contained in:
@@ -107,7 +107,12 @@ namespace Jackett.Indexers
|
|||||||
return IndexerConfigurationStatus.Completed;
|
return IndexerConfigurationStatus.Completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
public Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||||
|
{
|
||||||
|
return PerformQuery(query, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query, int attempts = 0)
|
||||||
{
|
{
|
||||||
await CheckToken();
|
await CheckToken();
|
||||||
var releases = new List<ReleaseInfo>();
|
var releases = new List<ReleaseInfo>();
|
||||||
@@ -120,6 +125,7 @@ namespace Jackett.Indexers
|
|||||||
{
|
{
|
||||||
episodeSearchUrl += "&category=" + cats;
|
episodeSearchUrl += "&category=" + cats;
|
||||||
}
|
}
|
||||||
|
|
||||||
var response = await RequestStringWithCookiesAndRetry(episodeSearchUrl, string.Empty);
|
var response = await RequestStringWithCookiesAndRetry(episodeSearchUrl, string.Empty);
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -133,9 +139,17 @@ namespace Jackett.Indexers
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (errorCode > 0) // too many requests per second
|
if (errorCode > 0) // too many requests per second
|
||||||
|
{
|
||||||
|
if (attempts < 3)
|
||||||
|
{
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(2));
|
||||||
|
return await PerformQuery(query, ++attempts);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
throw new Exception(jsonContent.Value<string>("error"));
|
throw new Exception(jsonContent.Value<string>("error"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var item in jsonContent.Value<JArray>("torrent_results"))
|
foreach (var item in jsonContent.Value<JArray>("torrent_results"))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user