diff --git a/src/NzbDrone.Core/Indexers/Gazelle/Gazelle.cs b/src/NzbDrone.Core/Indexers/Gazelle/Gazelle.cs index df85020b4..ee0531ecc 100644 --- a/src/NzbDrone.Core/Indexers/Gazelle/Gazelle.cs +++ b/src/NzbDrone.Core/Indexers/Gazelle/Gazelle.cs @@ -5,6 +5,9 @@ using NzbDrone.Core.Configuration; using NzbDrone.Core.Parser; using NzbDrone.Core.ThingiProvider; using System.Collections.Generic; +using System.Linq; +using FluentValidation.Results; +using NzbDrone.Common.Extensions; namespace NzbDrone.Core.Indexers.Gazelle { @@ -74,5 +77,12 @@ namespace NzbDrone.Core.Indexers.Gazelle return settings; } + + protected override void Test(List failures) + { + // Remove previous cookies when testing incase user or pwd change + _authCookieCache.Remove(Settings.BaseUrl.Trim().TrimEnd('/')); + base.Test(failures); + } } } diff --git a/src/NzbDrone.Core/Indexers/Gazelle/GazelleApi.cs b/src/NzbDrone.Core/Indexers/Gazelle/GazelleApi.cs index 77318f24f..a12532907 100644 --- a/src/NzbDrone.Core/Indexers/Gazelle/GazelleApi.cs +++ b/src/NzbDrone.Core/Indexers/Gazelle/GazelleApi.cs @@ -1,5 +1,4 @@ -using System; -using Newtonsoft.Json; +using System; using System.Collections.Generic; namespace NzbDrone.Core.Indexers.Gazelle diff --git a/src/NzbDrone.Core/Indexers/Gazelle/GazelleParser.cs b/src/NzbDrone.Core/Indexers/Gazelle/GazelleParser.cs index 74a41232a..62f0b3e2a 100644 --- a/src/NzbDrone.Core/Indexers/Gazelle/GazelleParser.cs +++ b/src/NzbDrone.Core/Indexers/Gazelle/GazelleParser.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Net; -using Newtonsoft.Json; using NzbDrone.Common.Http; using NzbDrone.Core.Indexers.Exceptions; using NzbDrone.Core.Parser.Model; diff --git a/src/NzbDrone.Core/Indexers/Gazelle/GazelleRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Gazelle/GazelleRequestGenerator.cs index d403d3479..bf74d30a2 100644 --- a/src/NzbDrone.Core/Indexers/Gazelle/GazelleRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Gazelle/GazelleRequestGenerator.cs @@ -116,19 +116,16 @@ namespace NzbDrone.Core.Indexers.Gazelle var response = HttpClient.Execute(authLoginRequest); cookies = response.GetCookies(); - AuthCookieCache.Set(authKey, cookies, new TimeSpan(7, 0, 0, 0, 0)); // re-auth every 7 days - requestBuilder.SetCookies(cookies); - } - else - { - requestBuilder.SetCookies(cookies); + + AuthCookieCache.Set(authKey, cookies); } var index = GetIndex(cookies); - if (index.Status.IsNullOrWhiteSpace() || index.Status != "success") + if (index == null || index.Status.IsNullOrWhiteSpace() || index.Status != "success") { Logger.Debug("Gazelle authentication failed."); + AuthCookieCache.Remove(authKey); throw new Exception("Failed to authenticate with Gazelle."); } diff --git a/src/NzbDrone.Core/Indexers/Gazelle/GazelleSettings.cs b/src/NzbDrone.Core/Indexers/Gazelle/GazelleSettings.cs index eccd73cdd..5a6e345a8 100644 --- a/src/NzbDrone.Core/Indexers/Gazelle/GazelleSettings.cs +++ b/src/NzbDrone.Core/Indexers/Gazelle/GazelleSettings.cs @@ -1,7 +1,6 @@ using FluentValidation; using NzbDrone.Core.Annotations; using NzbDrone.Core.Validation; -using System.Text.RegularExpressions; namespace NzbDrone.Core.Indexers.Gazelle {