Cardigann: set referer on captcha request

This commit is contained in:
kaso17
2017-01-17 12:32:11 +01:00
parent 7bdbc4a025
commit 7c0d619f2f
2 changed files with 5 additions and 4 deletions

View File

@@ -357,14 +357,14 @@ namespace Jackett.Indexers
return response.Content; return response.Content;
} }
protected async Task<WebClientByteResult> RequestBytesWithCookiesAndRetry(string url, string cookieOverride = null, RequestType method = RequestType.GET) protected async Task<WebClientByteResult> RequestBytesWithCookiesAndRetry(string url, string cookieOverride = null, RequestType method = RequestType.GET, string referer = null)
{ {
Exception lastException = null; Exception lastException = null;
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
try try
{ {
return await RequestBytesWithCookies(url, cookieOverride, method); return await RequestBytesWithCookies(url, cookieOverride, method, referer);
} }
catch (Exception e) catch (Exception e)
{ {
@@ -416,13 +416,14 @@ namespace Jackett.Indexers
throw lastException; throw lastException;
} }
protected async Task<WebClientByteResult> RequestBytesWithCookies(string url, string cookieOverride = null, RequestType method = RequestType.GET) protected async Task<WebClientByteResult> RequestBytesWithCookies(string url, string cookieOverride = null, RequestType method = RequestType.GET, string referer = null)
{ {
var request = new Utils.Clients.WebRequest() var request = new Utils.Clients.WebRequest()
{ {
Url = url, Url = url,
Type = method, Type = method,
Cookies = cookieOverride ?? CookieHeader, Cookies = cookieOverride ?? CookieHeader,
Referer = referer,
Encoding = Encoding Encoding = Encoding
}; };

View File

@@ -653,7 +653,7 @@ namespace Jackett.Indexers
var captchaElement = landingResultDocument.QuerySelector(Captcha.Image); var captchaElement = landingResultDocument.QuerySelector(Captcha.Image);
if (captchaElement != null) { if (captchaElement != null) {
var CaptchaUrl = resolvePath(captchaElement.GetAttribute("src")); var CaptchaUrl = resolvePath(captchaElement.GetAttribute("src"));
var captchaImageData = await RequestBytesWithCookies(CaptchaUrl.ToString(), landingResult.Cookies); var captchaImageData = await RequestBytesWithCookies(CaptchaUrl.ToString(), landingResult.Cookies, RequestType.GET, LoginUrl.ToString());
var CaptchaImage = new ImageItem { Name = "Captcha Image" }; var CaptchaImage = new ImageItem { Name = "Captcha Image" };
var CaptchaText = new StringItem { Name = "Captcha Text" }; var CaptchaText = new StringItem { Name = "Captcha Text" };