From 76a2f515333fca50a3aca2d3751972b3430da528 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Mon, 5 Jun 2023 02:22:49 +0300 Subject: [PATCH] Fixed: (HDTorrents) Add login error message --- src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs b/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs index ba3f1859d..398f5af58 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs @@ -8,8 +8,10 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using AngleSharp.Html.Parser; using NLog; +using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Indexers.Exceptions; using NzbDrone.Core.Indexers.Settings; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Messaging.Events; @@ -70,6 +72,16 @@ namespace NzbDrone.Core.Indexers.Definitions var response = await ExecuteAuth(authLoginRequest); + if (response.Content != null && !response.Content.ContainsIgnoreCase("If your browser doesn't have javascript enabled")) + { + var parser = new HtmlParser(); + var dom = parser.ParseDocument(response.Content); + + var errorMessage = dom.QuerySelector("div > font[color=\"#FF0000\"]")?.TextContent.Trim(); + + throw new IndexerAuthException(errorMessage ?? "Couldn't login"); + } + UpdateCookies(response.GetCookies(), DateTime.Now.AddDays(30)); _logger.Debug("Authentication succeeded");