mirror of
https://github.com/Jackett/Jackett
synced 2025-03-06 11:48:49 +00:00
hdspace: improve error message on login (#14157)
This commit is contained in:
parent
a9b73e9f8c
commit
aff88be54f
1 changed files with 16 additions and 10 deletions
|
@ -4,9 +4,9 @@ using System.Collections.Specialized;
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using AngleSharp.Html.Parser;
|
||||
using Jackett.Common.Extensions;
|
||||
using Jackett.Common.Models;
|
||||
using Jackett.Common.Models.IndexerConfig;
|
||||
using Jackett.Common.Services.Interfaces;
|
||||
|
@ -95,7 +95,9 @@ namespace Jackett.Common.Indexers
|
|||
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
LoadValuesFromJson(configJson);
|
||||
|
||||
var loginPage = await RequestWithCookiesAsync(LoginUrl, string.Empty);
|
||||
|
||||
var pairs = new Dictionary<string, string>
|
||||
{
|
||||
{ "uid", configData.Username.Value },
|
||||
|
@ -105,15 +107,19 @@ namespace Jackett.Common.Indexers
|
|||
// Send Post
|
||||
var response = await RequestLoginAndFollowRedirect(LoginUrl, pairs, loginPage.Cookies, true, referer: LoginUrl);
|
||||
|
||||
await ConfigureIfOK(response.Cookies, response.ContentString?.Contains("logout.php") == true, () =>
|
||||
await ConfigureIfOK(response.Cookies, response.ContentString?.Contains("logout.php") == true || response.ContentString?.Contains("Rank: Parked") == true, () =>
|
||||
{
|
||||
var errorStr = "You have {0} remaining login attempts";
|
||||
var remainingAttemptSpan = new Regex(string.Format(errorStr, "(.*?)"))
|
||||
.Match(loginPage.ContentString).Groups[1].ToString();
|
||||
var attempts = Regex.Replace(remainingAttemptSpan, "<.*?>", string.Empty);
|
||||
var errorMessage = string.Format(errorStr, attempts);
|
||||
throw new ExceptionWithConfigData(errorMessage, configData);
|
||||
var parser = new HtmlParser();
|
||||
var dom = parser.ParseDocument(response.ContentString);
|
||||
var errorMessage = dom
|
||||
.QuerySelectorAll("table.lista td.lista span[style*=\"#FF0000\"], table.lista td.header:contains(\"login attempts\")")
|
||||
.Select(r => r.TextContent.Trim())
|
||||
.Where(m => m.IsNotNullOrWhiteSpace())
|
||||
.Join(" ");
|
||||
|
||||
throw new ExceptionWithConfigData(errorMessage.IsNotNullOrWhiteSpace() ? errorMessage : "Unknown error message, please report.", configData);
|
||||
});
|
||||
|
||||
return IndexerConfigurationStatus.RequiresTesting;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue