mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Added: Radarr now stores cookies for PTP beyond restarts. Should limit active sessions correctly. (#2643)
Fixes #2626
This commit is contained in:
@@ -45,10 +45,8 @@ namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
return new List<ReleaseInfo>();
|
||||
}
|
||||
|
||||
var generator = GetRequestGenerator();
|
||||
|
||||
return FetchReleases(generator.GetRecentRequests(), true);
|
||||
|
||||
return FetchReleases(GetRequestChain(), true);
|
||||
}
|
||||
|
||||
public override IList<ReleaseInfo> Fetch(MovieSearchCriteria searchCriteria)
|
||||
@@ -58,17 +56,48 @@ namespace NzbDrone.Core.Indexers
|
||||
return new List<ReleaseInfo>();
|
||||
}
|
||||
|
||||
var generator = GetRequestGenerator();
|
||||
|
||||
return FetchReleases(generator.GetSearchRequests(searchCriteria));
|
||||
return FetchReleases(GetRequestChain(searchCriteria));
|
||||
}
|
||||
|
||||
protected IndexerPageableRequestChain GetRequestChain(SearchCriteriaBase searchCriteria = null)
|
||||
{
|
||||
var generator = GetRequestGenerator();
|
||||
|
||||
//A func ensures cookies are always updated to the latest. This way, the first page could update the cookies and then can be reused by the second page.
|
||||
|
||||
generator.GetCookies = () =>
|
||||
{
|
||||
var cookies = _indexerStatusService.GetIndexerCookies(Definition.Id);
|
||||
var expiration = _indexerStatusService.GetIndexerCookiesExpirationDate(Definition.Id);
|
||||
if (expiration < DateTime.Now)
|
||||
{
|
||||
cookies = null;
|
||||
}
|
||||
|
||||
return cookies;
|
||||
};
|
||||
|
||||
var requests = searchCriteria == null ? generator.GetRecentRequests() : generator.GetSearchRequests(searchCriteria as MovieSearchCriteria);
|
||||
|
||||
generator.CookiesUpdater = (cookies, expiration) =>
|
||||
{
|
||||
_indexerStatusService.UpdateCookies(Definition.Id, cookies, expiration);
|
||||
};
|
||||
|
||||
return requests;
|
||||
}
|
||||
|
||||
|
||||
protected virtual IList<ReleaseInfo> FetchReleases(IndexerPageableRequestChain pageableRequestChain, bool isRecent = false)
|
||||
{
|
||||
var releases = new List<ReleaseInfo>();
|
||||
var url = string.Empty;
|
||||
|
||||
var parser = GetParser();
|
||||
parser.CookiesUpdater = (cookies, expiration) =>
|
||||
{
|
||||
_indexerStatusService.UpdateCookies(Definition.Id, cookies, expiration);
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
@@ -261,8 +290,11 @@ namespace NzbDrone.Core.Indexers
|
||||
try
|
||||
{
|
||||
var parser = GetParser();
|
||||
var generator = GetRequestGenerator();
|
||||
var releases = FetchPage(generator.GetRecentRequests().GetAllTiers().First().First(), parser);
|
||||
parser.CookiesUpdater = (cookies, expiration) =>
|
||||
{
|
||||
_indexerStatusService.UpdateCookies(Definition.Id, cookies, expiration);
|
||||
};
|
||||
var releases = FetchPage(GetRequestChain().GetAllTiers().First().First(), parser);
|
||||
|
||||
if (releases.Empty())
|
||||
{
|
||||
|
Reference in New Issue
Block a user