mirror of
https://github.com/Jackett/Jackett
synced 2025-01-01 12:46:23 +00:00
parent
d6d6ae28a4
commit
7a04c87a35
1 changed files with 42 additions and 19 deletions
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AngleSharp.Html.Parser;
|
using AngleSharp.Html.Parser;
|
||||||
using Jackett.Common.Helpers;
|
using Jackett.Common.Helpers;
|
||||||
|
@ -18,6 +19,8 @@ namespace Jackett.Common.Indexers
|
||||||
{
|
{
|
||||||
public class SpeedCD : BaseWebIndexer
|
public class SpeedCD : BaseWebIndexer
|
||||||
{
|
{
|
||||||
|
private string LoginUrl1 => SiteLink + "checkpoint/API";
|
||||||
|
private string LoginUrl2 => SiteLink + "checkpoint/";
|
||||||
private string SearchUrl => SiteLink + "browse/";
|
private string SearchUrl => SiteLink + "browse/";
|
||||||
|
|
||||||
public override string[] AlternativeSiteLinks { get; protected set; } = {
|
public override string[] AlternativeSiteLinks { get; protected set; } = {
|
||||||
|
@ -25,7 +28,7 @@ namespace Jackett.Common.Indexers
|
||||||
"https://speed.click/"
|
"https://speed.click/"
|
||||||
};
|
};
|
||||||
|
|
||||||
private new ConfigurationDataCookie configData => (ConfigurationDataCookie)base.configData;
|
private new ConfigurationDataBasicLogin configData => (ConfigurationDataBasicLogin)base.configData;
|
||||||
|
|
||||||
public SpeedCD(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
public SpeedCD(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
||||||
: base("Speed.cd",
|
: base("Speed.cd",
|
||||||
|
@ -40,7 +43,7 @@ namespace Jackett.Common.Indexers
|
||||||
client: wc,
|
client: wc,
|
||||||
logger: l,
|
logger: l,
|
||||||
p: ps,
|
p: ps,
|
||||||
configData: new ConfigurationDataCookie(
|
configData: new ConfigurationDataBasicLogin(
|
||||||
@"Speed.Cd have increased their security. If you are having problems please check the security tab
|
@"Speed.Cd have increased their security. If you are having problems please check the security tab
|
||||||
in your Speed.Cd profile. Eg. Geo Locking, your seedbox may be in a different country to the one where you login via your
|
in your Speed.Cd profile. Eg. Geo Locking, your seedbox may be in a different country to the one where you login via your
|
||||||
web browser.<br><br>For best results, change the 'Torrents per page' setting to 100 in 'Profile Settings > Torrents'."))
|
web browser.<br><br>For best results, change the 'Torrents per page' setting to 100 in 'Profile Settings > Torrents'."))
|
||||||
|
@ -85,21 +88,39 @@ namespace Jackett.Common.Indexers
|
||||||
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||||
{
|
{
|
||||||
LoadValuesFromJson(configJson);
|
LoadValuesFromJson(configJson);
|
||||||
CookieHeader = configData.Cookie.Value;
|
await DoLogin();
|
||||||
try
|
return IndexerConfigurationStatus.RequiresTesting;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DoLogin()
|
||||||
|
{
|
||||||
|
// first request with username
|
||||||
|
var pairs = new Dictionary<string, string> {
|
||||||
|
{ "username", configData.Username.Value }
|
||||||
|
};
|
||||||
|
var result = await RequestLoginAndFollowRedirect(LoginUrl1, pairs, null, true, null, SiteLink);
|
||||||
|
var tokenRegex = new Regex(@"name=\\""a\\"" value=\\""([^""]+)\\""");
|
||||||
|
var matches = tokenRegex.Match(result.Content);
|
||||||
|
if (!matches.Success)
|
||||||
|
throw new Exception("Error parsing the login form");
|
||||||
|
var token = matches.Groups[1].Value;
|
||||||
|
|
||||||
|
// second request with token and password
|
||||||
|
pairs = new Dictionary<string, string> {
|
||||||
|
{ "pwd", configData.Password.Value },
|
||||||
|
{ "a", token }
|
||||||
|
};
|
||||||
|
result = await RequestLoginAndFollowRedirect(LoginUrl2, pairs, result.Cookies, true, null, SiteLink);
|
||||||
|
|
||||||
|
await ConfigureIfOK(result.Cookies, result.Content?.Contains("/browse.php") == true, () =>
|
||||||
{
|
{
|
||||||
var results = await PerformQuery(new TorznabQuery());
|
var parser = new HtmlParser();
|
||||||
if (!results.Any())
|
var dom = parser.ParseDocument(result.Content);
|
||||||
throw new Exception("Found 0 results in the tracker");
|
var errorMessage = dom.QuerySelector("h5")?.TextContent;
|
||||||
IsConfigured = true;
|
if (result.Content.Contains("Wrong Captcha!"))
|
||||||
SaveConfig();
|
errorMessage = "Captcha required due to a failed login attempt. Login via a browser to whitelist your IP and then reconfigure Jackett.";
|
||||||
return IndexerConfigurationStatus.Completed;
|
throw new Exception(errorMessage);
|
||||||
}
|
});
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
IsConfigured = false;
|
|
||||||
throw new Exception("Your cookie did not work: " + e.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||||
|
@ -127,9 +148,11 @@ namespace Jackett.Common.Indexers
|
||||||
|
|
||||||
var searchUrl = SearchUrl + string.Join("/", qc);
|
var searchUrl = SearchUrl + string.Join("/", qc);
|
||||||
var response = await RequestStringWithCookiesAndRetry(searchUrl);
|
var response = await RequestStringWithCookiesAndRetry(searchUrl);
|
||||||
if (!response.Content.Contains("/logout.php"))
|
if (!response.Content.Contains("/logout.php")) // re-login
|
||||||
throw new Exception("The user is not logged in. It is possible that the cookie has expired or you " +
|
{
|
||||||
"made a mistake when copying it. Please check the settings.");
|
await DoLogin();
|
||||||
|
response = await RequestStringWithCookiesAndRetry(searchUrl);
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue