Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New: Increase rate limit for automatic searches #9862

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/NzbDrone.Core/Indexers/HttpIndexerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public override Task<IList<ReleaseInfo>> FetchRecent()
return Task.FromResult<IList<ReleaseInfo>>(Array.Empty<ReleaseInfo>());
}

return FetchReleases(g => g.GetRecentRequests(), true);
return FetchReleases(g => g.GetRecentRequests(), false, true);
}

public override Task<IList<ReleaseInfo>> Fetch(MovieSearchCriteria searchCriteria)
Expand All @@ -57,7 +57,7 @@ public override Task<IList<ReleaseInfo>> Fetch(MovieSearchCriteria searchCriteri
return Task.FromResult<IList<ReleaseInfo>>(Array.Empty<ReleaseInfo>());
}

return FetchReleases(g => g.GetSearchRequests(searchCriteria));
return FetchReleases(g => g.GetSearchRequests(searchCriteria), searchCriteria.InteractiveSearch);
}

protected IndexerPageableRequestChain GetRequestChain(SearchCriteriaBase searchCriteria = null)
Expand Down Expand Up @@ -92,11 +92,12 @@ public override HttpRequest GetDownloadRequest(string link)
return new HttpRequest(link);
}

protected virtual async Task<IList<ReleaseInfo>> FetchReleases(Func<IIndexerRequestGenerator, IndexerPageableRequestChain> pageableRequestChainSelector, bool isRecent = false)
protected virtual async Task<IList<ReleaseInfo>> FetchReleases(Func<IIndexerRequestGenerator, IndexerPageableRequestChain> pageableRequestChainSelector, bool interactiveSearch = false, bool isRecent = false)
{
var releases = new List<ReleaseInfo>();
var url = string.Empty;
var minimumBackoff = TimeSpan.FromHours(1);
var automaticSearchRateLimit = TimeSpan.FromSeconds(30);

try
{
Expand Down Expand Up @@ -128,6 +129,11 @@ protected virtual async Task<IList<ReleaseInfo>> FetchReleases(Func<IIndexerRequ
{
url = request.Url.FullUri;

if (!interactiveSearch && request.HttpRequest.RateLimit < automaticSearchRateLimit)
{
request.HttpRequest.RateLimit = automaticSearchRateLimit;
}

var page = await FetchPage(request, parser);

pagedReleases.AddRange(page);
Expand Down