mirror of
https://github.com/Jackett/Jackett
synced 2024-12-28 02:39:26 +00:00
iptorrents: remove login with user/pass. resolves #7063 resolves #6850 resolves #6485 resolves #6402 resolves #4624 (#7294)
This commit is contained in:
parent
d806bb18a2
commit
12b2de2725
1 changed files with 15 additions and 75 deletions
|
@ -10,7 +10,6 @@ using Jackett.Common.Models;
|
||||||
using Jackett.Common.Models.IndexerConfig;
|
using Jackett.Common.Models.IndexerConfig;
|
||||||
using Jackett.Common.Services.Interfaces;
|
using Jackett.Common.Services.Interfaces;
|
||||||
using Jackett.Common.Utils;
|
using Jackett.Common.Utils;
|
||||||
using Jackett.Common.Utils.Clients;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
|
@ -18,8 +17,6 @@ namespace Jackett.Common.Indexers
|
||||||
{
|
{
|
||||||
public class IPTorrents : BaseWebIndexer
|
public class IPTorrents : BaseWebIndexer
|
||||||
{
|
{
|
||||||
private string LoginUrl => SiteLink + "login.php";
|
|
||||||
private string TakeLoginUrl => SiteLink + "take_login.php";
|
|
||||||
private string BrowseUrl => SiteLink + "t";
|
private string BrowseUrl => SiteLink + "t";
|
||||||
|
|
||||||
public override string[] AlternativeSiteLinks { get; protected set; } = {
|
public override string[] AlternativeSiteLinks { get; protected set; } = {
|
||||||
|
@ -45,9 +42,9 @@ namespace Jackett.Common.Indexers
|
||||||
"https://ipt.world/",
|
"https://ipt.world/",
|
||||||
};
|
};
|
||||||
|
|
||||||
private new ConfigurationDataRecaptchaLogin configData
|
private new ConfigurationDataCookie configData
|
||||||
{
|
{
|
||||||
get => (ConfigurationDataRecaptchaLogin)base.configData;
|
get => (ConfigurationDataCookie)base.configData;
|
||||||
set => base.configData = value;
|
set => base.configData = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +57,7 @@ namespace Jackett.Common.Indexers
|
||||||
client: wc,
|
client: wc,
|
||||||
logger: l,
|
logger: l,
|
||||||
p: ps,
|
p: ps,
|
||||||
configData: new ConfigurationDataRecaptchaLogin())
|
configData: new ConfigurationDataCookie())
|
||||||
{
|
{
|
||||||
Encoding = Encoding.UTF8;
|
Encoding = Encoding.UTF8;
|
||||||
Language = "en-us";
|
Language = "en-us";
|
||||||
|
@ -142,45 +139,11 @@ namespace Jackett.Common.Indexers
|
||||||
AddCategoryMapping(84, TorznabCatType.XXXImageset, "XXX/Pics/Wallpapers");
|
AddCategoryMapping(84, TorznabCatType.XXXImageset, "XXX/Pics/Wallpapers");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<ConfigurationData> GetConfigurationForSetup()
|
|
||||||
{
|
|
||||||
var loginPage = await RequestStringWithCookies(LoginUrl, string.Empty);
|
|
||||||
CQ cq = loginPage.Content;
|
|
||||||
var captcha = cq.Find(".g-recaptcha");
|
|
||||||
if (captcha.Any())
|
|
||||||
{
|
|
||||||
var result = configData;
|
|
||||||
result.CookieHeader.Value = loginPage.Cookies;
|
|
||||||
result.Captcha.SiteKey = captcha.Attr("data-sitekey");
|
|
||||||
result.Captcha.Version = "2";
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var result = new ConfigurationDataBasicLogin
|
|
||||||
{
|
|
||||||
SiteLink = { Value = configData.SiteLink.Value },
|
|
||||||
Instructions = { Value = configData.Instructions.Value },
|
|
||||||
Username = { Value = configData.Username.Value },
|
|
||||||
Password = { Value = configData.Password.Value },
|
|
||||||
CookieHeader = { Value = loginPage.Cookies }
|
|
||||||
};
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||||
{
|
{
|
||||||
LoadValuesFromJson(configJson);
|
LoadValuesFromJson(configJson);
|
||||||
var pairs = new Dictionary<string, string> {
|
|
||||||
{ "username", configData.Username.Value },
|
|
||||||
{ "password", configData.Password.Value },
|
|
||||||
{ "g-recaptcha-response", configData.Captcha.Value }
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(configData.Captcha.Cookie))
|
CookieHeader = configData.Cookie.Value;
|
||||||
{
|
|
||||||
CookieHeader = configData.Captcha.Cookie;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var results = await PerformQuery(new TorznabQuery());
|
var results = await PerformQuery(new TorznabQuery());
|
||||||
|
@ -198,29 +161,6 @@ namespace Jackett.Common.Indexers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var request = new Utils.Clients.WebRequest()
|
|
||||||
{
|
|
||||||
Url = TakeLoginUrl,
|
|
||||||
Type = RequestType.POST,
|
|
||||||
Referer = SiteLink,
|
|
||||||
Encoding = Encoding,
|
|
||||||
PostData = pairs
|
|
||||||
};
|
|
||||||
var response = await webclient.GetString(request);
|
|
||||||
var firstCallCookies = response.Cookies;
|
|
||||||
// Redirect to ? then to /t
|
|
||||||
await FollowIfRedirect(response, request.Url, null, firstCallCookies);
|
|
||||||
|
|
||||||
await ConfigureIfOK(firstCallCookies, response.Content.Contains("/lout.php"), () =>
|
|
||||||
{
|
|
||||||
CQ dom = response.Content;
|
|
||||||
var messageEl = dom["body > div"].First();
|
|
||||||
var errorMessage = messageEl.Any() ? messageEl.Text().Trim() : response.Content;
|
|
||||||
throw new ExceptionWithConfigData(errorMessage, configData);
|
|
||||||
});
|
|
||||||
return IndexerConfigurationStatus.RequiresTesting;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||||
{
|
{
|
||||||
var releases = new List<ReleaseInfo>();
|
var releases = new List<ReleaseInfo>();
|
||||||
|
|
Loading…
Reference in a new issue