From 1f82b9fb78798a4e734e28d1d2a170654f14ce45 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Mon, 11 Dec 2023 21:41:19 +0200 Subject: [PATCH] New: Rate limiting for Trakt connection --- src/NzbDrone.Core/Notifications/Trakt/TraktProxy.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Notifications/Trakt/TraktProxy.cs b/src/NzbDrone.Core/Notifications/Trakt/TraktProxy.cs index c9768fc69..802dd6ae0 100644 --- a/src/NzbDrone.Core/Notifications/Trakt/TraktProxy.cs +++ b/src/NzbDrone.Core/Notifications/Trakt/TraktProxy.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using NLog; using NzbDrone.Common.Extensions; @@ -75,6 +76,7 @@ public TraktAuthRefreshResource RefreshAuthToken(string refreshToken) { var request = new HttpRequestBuilder(RenewUri) .AddQueryParam("refresh_token", refreshToken) + .WithRateLimit(2) .Build(); return _httpClient.Get(request)?.Resource ?? null; @@ -83,9 +85,11 @@ public TraktAuthRefreshResource RefreshAuthToken(string refreshToken) private HttpRequest BuildRequest(string resource, HttpMethod method, string accessToken) { var request = new HttpRequestBuilder(URL).Resource(resource).Build(); + + request.RateLimit = TimeSpan.FromSeconds(2); + request.Headers.Accept = HttpAccept.Json.Value; request.Method = method; - request.Headers.Accept = HttpAccept.Json.Value; request.Headers.Add("trakt-api-version", "2"); request.Headers.Add("trakt-api-key", ClientId);