anidex: fix ddos-guard challenge with flaresolverr. closes #1335 (#13171)

Required FlareSolverr >= 2.2.4
This commit is contained in:
Diego Heras
2022-04-17 09:49:25 +02:00
committed by GitHub
parent e14935c923
commit c14f32482c
2 changed files with 6 additions and 20 deletions

View File

@@ -65,6 +65,11 @@ namespace Jackett.Common.Indexers
AddCategoryMapping(15, TorznabCatType.XXX, "Adult Video");
AddCategoryMapping(16, TorznabCatType.Other, "Other");
configData.AddDynamic(
"DDoS-Guard",
new DisplayInfoConfigurationItem("", "This site may use DDoS-Guard Protection, therefore Jackett requires <a href='https://github.com/Jackett/Jackett#configuring-flaresolverr' target='_blank'>FlareSolverr</a> to access it.")
);
AddLanguageConfiguration();
// Configure the sort selects
@@ -182,13 +187,6 @@ namespace Jackett.Common.Indexers
var searchUri = GetAbsoluteUrl("?" + queryParameters.GetQueryString() + catString + langIds);
var response = await RequestWithCookiesAndRetryAsync(searchUri.AbsoluteUri);
// Check for DDOS Guard
if (response.Status == HttpStatusCode.Forbidden)
{
await ConfigureDDoSGuardCookieAsync();
response = await RequestWithCookiesAndRetryAsync(searchUri.AbsoluteUri);
}
if (response.Status != HttpStatusCode.OK)
throw new WebException($"Anidex search returned unexpected result. Expected 200 OK but got {response.Status}.", WebExceptionStatus.ProtocolError);
@@ -243,18 +241,6 @@ namespace Jackett.Common.Indexers
}
}
private async Task ConfigureDDoSGuardCookieAsync()
{
const string ddosPostUrl = "https://check.ddos-guard.net/check.js";
var response = await RequestWithCookiesAsync(ddosPostUrl, string.Empty);
if (response.Status != HttpStatusCode.OK)
throw new WebException($"Unexpected DDOS Guard response: Status: {response.Status}", WebExceptionStatus.ProtocolError);
if (response.IsRedirect)
throw new WebException($"Unexpected DDOS Guard response: Redirect: {response.RedirectingTo}", WebExceptionStatus.UnknownError);
if (string.IsNullOrWhiteSpace(response.Cookies))
throw new WebException("Unexpected DDOS Guard response: Empty cookie", WebExceptionStatus.ReceiveFailure);
}
private static TResult ParseValueFromRow<TResult>(IElement row, string propertyName, string selector,
Func<IElement, TResult> parseFunction)
{

View File

@@ -15,7 +15,7 @@
<PackageReference Include="Autofac" Version="6.3.0" />
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="BencodeNET" Version="4.0.0" />
<PackageReference Include="FlareSolverrSharp" Version="2.2.0" />
<PackageReference Include="FlareSolverrSharp" Version="2.2.4" />
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="DotNet4.SocksProxy" Version="1.4.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />