mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-05 18:42:42 +01:00
Limit TMDb requests when importing via IMDBid (#703)
This commit is contained in:
parent
fe0dfef83c
commit
31e657d052
@ -232,7 +232,19 @@ public Movie GetMovieInfo(string ImdbId)
|
||||
request.AllowAutoRedirect = true;
|
||||
request.SuppressHttpError = true;
|
||||
|
||||
var resources = _httpClient.Get<FindRoot>(request).Resource;
|
||||
var response = _httpClient.Get<FindRoot>(request);
|
||||
|
||||
// The dude abides, so should us, Lets be nice to TMDb
|
||||
// var allowed = int.Parse(response.Headers.GetValues("X-RateLimit-Limit").First()); // get allowed
|
||||
// var reset = long.Parse(response.Headers.GetValues("X-RateLimit-Reset").First()); // get time when it resets
|
||||
var remaining = int.Parse(response.Headers.GetValues("X-RateLimit-Remaining").First());
|
||||
if (remaining <= 5)
|
||||
{
|
||||
_logger.Trace("Waiting 5 seconds to get information for the next 35 movies");
|
||||
Thread.Sleep(5000);
|
||||
}
|
||||
|
||||
var resources = response.Resource;
|
||||
|
||||
return resources.movie_results.SelectList(MapMovie).FirstOrDefault();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user