Private GIT

Skip to content
Snippets Groups Projects
Commit 5acaf9db authored by garreth.jeremiah@gmail.com's avatar garreth.jeremiah@gmail.com
Browse files

performQuery did not handle the situation where the credentials had timed out...

performQuery did not handle the situation where the credentials had timed out or the cloudflare DDoS was re-requested.  Added a temporary solution by re-doing the log-in process.  It is a little slow, so users of this indexer will see a 20s delay.  I will find a way to improve that in a subsequent fix.
parent a856aba9
Branches
Tags
No related merge requests found
...@@ -177,8 +177,38 @@ namespace Jackett.Indexers ...@@ -177,8 +177,38 @@ namespace Jackett.Indexers
{ "category", "0" }, { "category", "0" },
{ "include_dead_torrents", "no" } { "include_dead_torrents", "no" }
}; };
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value }
};
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, this.CookieHeader, true, null, SiteLink, true);
result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, result.Cookies, true, SearchUrl, SiteLink, true);
this.CookieHeader = result.Cookies;
var searchPage = await PostDataWithCookiesAndRetry(SearchUrl, searchParams); var attempt = 1;
var searchPage = await PostDataWithCookiesAndRetry(SearchUrl, searchParams,this.CookieHeader);
while (searchPage.IsRedirect && attempt < 3)
{
// add any cookies
var cookieString = this.CookieHeader;
if (searchPage.Cookies != null)
{
cookieString += " " + searchPage.Cookies;
// resolve cookie conflicts - really no need for this as the webclient will handle it
System.Text.RegularExpressions.Regex expression = new System.Text.RegularExpressions.Regex(@"([^\s]+)=([^=]+)(?:\s|$)");
Dictionary<string, string> cookieDIctionary = new Dictionary<string, string>();
var matches = expression.Match(cookieString);
while (matches.Success)
{
if (matches.Groups.Count > 2) cookieDIctionary[matches.Groups[1].Value] = matches.Groups[2].Value;
matches = matches.NextMatch();
}
cookieString = string.Join(" ", cookieDIctionary.Select(kv => kv.Key.ToString() + "=" + kv.Value.ToString()).ToArray());
}
this.CookieHeader = cookieString;
attempt++;
searchPage = await PostDataWithCookiesAndRetry(SearchUrl, searchParams, this.CookieHeader);
}
try try
{ {
CQ dom = searchPage.Content; CQ dom = searchPage.Content;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment