From e45f88473cacf5d6b5b5b7787263c2876186b949 Mon Sep 17 00:00:00 2001 From: Qstick Date: Mon, 28 Jun 2021 23:04:10 -0400 Subject: [PATCH] Fixed: (Anthelion) Null BaseUrl and better error message on auth fail Fixes #295 --- .../Indexers/Definitions/Anthelion.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/Anthelion.cs b/src/NzbDrone.Core/Indexers/Definitions/Anthelion.cs index 835055ea9..cd1d40055 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Anthelion.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Anthelion.cs @@ -79,9 +79,13 @@ namespace NzbDrone.Core.Indexers.Definitions var response = await ExecuteAuth(authLoginRequest); - if (!response.Content.Contains("logout.php")) + if (CheckIfLoginNeeded(response)) { - throw new IndexerAuthException("Anthelion Auth Failed"); + var parser = new HtmlParser(); + var dom = parser.ParseDocument(response.Content); + var errorMessage = dom.QuerySelector("form#loginform").TextContent.Trim(); + + throw new IndexerAuthException(errorMessage); } cookies = response.GetCookies(); @@ -127,7 +131,6 @@ namespace NzbDrone.Core.Indexers.Definitions { public AnthelionSettings Settings { get; set; } public IndexerCapabilities Capabilities { get; set; } - public string BaseUrl { get; set; } public AnthelionRequestGenerator() { @@ -135,7 +138,7 @@ namespace NzbDrone.Core.Indexers.Definitions private IEnumerable GetPagedRequests(string term, int[] categories, string imdbId = null) { - var searchUrl = string.Format("{0}/torrents.php", BaseUrl.TrimEnd('/')); + var searchUrl = string.Format("{0}/torrents.php", Settings.BaseUrl.TrimEnd('/')); // TODO: IMDB search is available but it requires to parse the details page var qc = new NameValueCollection @@ -174,8 +177,6 @@ namespace NzbDrone.Core.Indexers.Definitions { var pageableRequests = new IndexerPageableRequestChain(); - pageableRequests.Add(GetPagedRequests(string.Format("{0}", searchCriteria.SanitizedSearchTerm), searchCriteria.Categories)); - return pageableRequests; } @@ -192,8 +193,6 @@ namespace NzbDrone.Core.Indexers.Definitions { var pageableRequests = new IndexerPageableRequestChain(); - pageableRequests.Add(GetPagedRequests(string.Format("{0}", searchCriteria.SanitizedSearchTerm), searchCriteria.Categories)); - return pageableRequests; }