Shazbat: Relogin if necessary

This commit is contained in:
kaso17 2017-03-07 11:28:48 +01:00
parent 1aad9a5527
commit dba66976ff
1 changed files with 14 additions and 1 deletions

View File

@ -86,6 +86,17 @@ namespace Jackett.Indexers
return IndexerConfigurationStatus.RequiresTesting;
}
protected async Task<WebClientStringResult> ReloginIfNecessary(WebClientStringResult response)
{
if (!response.Content.Contains("onclick=\"document.location='logout'\""))
{
await ApplyConfiguration(null);
response.Request.Cookies = CookieHeader;
return await webclient.GetString(response.Request);
}
return response;
}
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>();
@ -102,6 +113,7 @@ namespace Jackett.Indexers
pairs.Add("search", query.SanitizedSearchTerm);
results = await PostDataWithCookiesAndRetry(SearchUrl, pairs, null, TorrentsUrl);
results = await ReloginIfNecessary(results);
CQ dom = results.Content;
var shows = dom.Find("div.show[data-id]");
foreach (var show in shows)
@ -120,6 +132,7 @@ namespace Jackett.Indexers
foreach (var searchUrl in searchUrls)
{
results = await RequestStringWithCookies(searchUrl);
results = await ReloginIfNecessary(results);
CQ dom = results.Content;
var rows = dom["#torrent-table tr"];