mirror of
https://github.com/Sonarr/Sonarr
synced 2025-01-19 05:38:53 +00:00
Fixed: Tweaked ratelimit logic for rarbg api.
This commit is contained in:
parent
e0d1e08f94
commit
7ef1ca8a00
2 changed files with 13 additions and 3 deletions
|
@ -22,6 +22,7 @@ namespace NzbDrone.Common.Http
|
|||
public bool UseSimplifiedUserAgent { get; set; }
|
||||
public bool AllowAutoRedirect { get; set; }
|
||||
public bool ConnectionKeepAlive { get; set; }
|
||||
public TimeSpan RateLimit { get; set; }
|
||||
public bool LogResponseContent { get; set; }
|
||||
public NetworkCredential NetworkCredential { get; set; }
|
||||
public Dictionary<string, string> Cookies { get; private set; }
|
||||
|
@ -75,7 +76,7 @@ namespace NzbDrone.Common.Http
|
|||
protected virtual HttpUri CreateUri()
|
||||
{
|
||||
var url = BaseUrl.CombinePath(ResourceUrl).AddQueryParams(QueryParams.Concat(SuffixQueryParams));
|
||||
|
||||
|
||||
if (Segments.Any())
|
||||
{
|
||||
var fullUri = url.FullUri;
|
||||
|
@ -103,6 +104,7 @@ namespace NzbDrone.Common.Http
|
|||
request.UseSimplifiedUserAgent = UseSimplifiedUserAgent;
|
||||
request.AllowAutoRedirect = AllowAutoRedirect;
|
||||
request.ConnectionKeepAlive = ConnectionKeepAlive;
|
||||
request.RateLimit = RateLimit;
|
||||
request.LogResponseContent = LogResponseContent;
|
||||
|
||||
if (NetworkCredential != null)
|
||||
|
@ -245,6 +247,13 @@ namespace NzbDrone.Common.Http
|
|||
return this;
|
||||
}
|
||||
|
||||
public virtual HttpRequestBuilder WithRateLimit(double seconds)
|
||||
{
|
||||
RateLimit = TimeSpan.FromSeconds(seconds);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public virtual HttpRequestBuilder Post()
|
||||
{
|
||||
Method = HttpMethod.POST;
|
||||
|
@ -371,4 +380,4 @@ namespace NzbDrone.Common.Http
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,8 @@ namespace NzbDrone.Core.Indexers.Rarbg
|
|||
return _tokenCache.Get(settings.BaseUrl, () =>
|
||||
{
|
||||
var requestBuilder = new HttpRequestBuilder(settings.BaseUrl.Trim('/'))
|
||||
.Resource("/pubapi_v2.php?get_token=get_token")
|
||||
.WithRateLimit(3.0)
|
||||
.Resource("/pubapi_v2.php?get_token=get_token&app_id=Sonarr")
|
||||
.Accept(HttpAccept.Json);
|
||||
|
||||
if (settings.CaptchaToken.IsNotNullOrWhiteSpace())
|
||||
|
|
Loading…
Reference in a new issue