mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
They changed the login form again. Now it's more complex to solve because they have several steps, reCaptcha and Google cookie.
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
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.Models;
|
using Jackett.Common.Models;
|
||||||
@@ -17,8 +17,6 @@ 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.php";
|
private string SearchUrl => SiteLink + "browse.php";
|
||||||
|
|
||||||
public override string[] AlternativeSiteLinks { get; protected set; } = {
|
public override string[] AlternativeSiteLinks { get; protected set; } = {
|
||||||
@@ -26,23 +24,23 @@ namespace Jackett.Common.Indexers
|
|||||||
"https://speed.click/"
|
"https://speed.click/"
|
||||||
};
|
};
|
||||||
|
|
||||||
private new ConfigurationDataBasicLogin configData => (ConfigurationDataBasicLogin)base.configData;
|
private new ConfigurationDataCookie configData => (ConfigurationDataCookie)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",
|
||||||
description: "Your home now!",
|
description: "Your home now!",
|
||||||
link: "https://speed.cd/",
|
link: "https://speed.cd/",
|
||||||
caps: new TorznabCapabilities
|
caps: new TorznabCapabilities
|
||||||
{
|
{
|
||||||
SupportsImdbMovieSearch = true
|
SupportsImdbMovieSearch = true
|
||||||
// SupportsImdbTVSearch = true (supported by the site but disabled due to #8107)
|
// SupportsImdbTVSearch = true (supported by the site but disabled due to #8107)
|
||||||
},
|
},
|
||||||
configService: configService,
|
configService: configService,
|
||||||
client: wc,
|
client: wc,
|
||||||
logger: l,
|
logger: l,
|
||||||
p: ps,
|
p: ps,
|
||||||
configData: new ConfigurationDataBasicLogin(
|
configData: new ConfigurationDataCookie(
|
||||||
@"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'."))
|
||||||
{
|
{
|
||||||
@@ -86,39 +84,21 @@ namespace Jackett.Common.Indexers
|
|||||||
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||||
{
|
{
|
||||||
LoadValuesFromJson(configJson);
|
LoadValuesFromJson(configJson);
|
||||||
await DoLogin();
|
CookieHeader = configData.Cookie.Value;
|
||||||
return IndexerConfigurationStatus.RequiresTesting;
|
try
|
||||||
}
|
|
||||||
|
|
||||||
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 ExceptionWithConfigData("Error parsing the login form", configData);
|
|
||||||
var token = matches.Groups[1].Value;
|
|
||||||
|
|
||||||
// second request with token and password
|
|
||||||
pairs = new Dictionary<string, string> {
|
|
||||||
{ "a", token },
|
|
||||||
{ "b", configData.Password.Value },
|
|
||||||
};
|
|
||||||
result = await RequestLoginAndFollowRedirect(LoginUrl2, pairs, result.Cookies, true, null, SiteLink);
|
|
||||||
|
|
||||||
await ConfigureIfOK(result.Cookies, result.Content?.Contains("/browse.php") == true, () =>
|
|
||||||
{
|
{
|
||||||
var parser = new HtmlParser();
|
var results = await PerformQuery(new TorznabQuery());
|
||||||
var dom = parser.ParseDocument(result.Content);
|
if (!results.Any())
|
||||||
var errorMessage = dom.QuerySelector("h5")?.TextContent;
|
throw new Exception("Found 0 results in the tracker");
|
||||||
if (result.Content.Contains("Wrong Captcha!"))
|
IsConfigured = true;
|
||||||
errorMessage = "Captcha required due to a failed login attempt. Login via a browser to whitelist your IP and then reconfigure Jackett.";
|
SaveConfig();
|
||||||
throw new ExceptionWithConfigData(errorMessage, configData);
|
return IndexerConfigurationStatus.Completed;
|
||||||
});
|
}
|
||||||
|
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)
|
||||||
@@ -140,11 +120,9 @@ namespace Jackett.Common.Indexers
|
|||||||
|
|
||||||
var searchUrl = SearchUrl + "?" + qc.GetQueryString();
|
var searchUrl = SearchUrl + "?" + qc.GetQueryString();
|
||||||
var response = await RequestStringWithCookiesAndRetry(searchUrl);
|
var response = await RequestStringWithCookiesAndRetry(searchUrl);
|
||||||
if (!response.Content.Contains("/logout.php")) // re-login
|
if (!response.Content.Contains("/logout.php"))
|
||||||
{
|
throw new Exception("The user is not logged in. It is possible that the cookie has expired or you " +
|
||||||
await DoLogin();
|
"made a mistake when copying it. Please check the settings.");
|
||||||
response = await RequestStringWithCookiesAndRetry(searchUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user