From 357726ed09197046b86915d20e7306e6db4d88e5 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 21 Mar 2014 07:59:42 -0700 Subject: [PATCH] Fixed: Do not prevent adding of indexer when API request limit was reached --- .../Exceptions/RequestLimitReachedException.cs | 17 +++++++++++++++++ .../Indexers/Newznab/NewznabPreProcessor.cs | 5 +++++ .../Indexers/NewznabTestService.cs | 6 +++++- src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/NzbDrone.Core/Indexers/Exceptions/RequestLimitReachedException.cs diff --git a/src/NzbDrone.Core/Indexers/Exceptions/RequestLimitReachedException.cs b/src/NzbDrone.Core/Indexers/Exceptions/RequestLimitReachedException.cs new file mode 100644 index 000000000..2ad6ecd81 --- /dev/null +++ b/src/NzbDrone.Core/Indexers/Exceptions/RequestLimitReachedException.cs @@ -0,0 +1,17 @@ +using NzbDrone.Common.Exceptions; + +namespace NzbDrone.Core.Indexers.Exceptions +{ + public class RequestLimitReachedException : NzbDroneException + { + public RequestLimitReachedException(string message, params object[] args) + : base(message, args) + { + } + + public RequestLimitReachedException(string message) + : base(message) + { + } + } +} diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabPreProcessor.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabPreProcessor.cs index 3ff151b8a..c64a9cecb 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabPreProcessor.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabPreProcessor.cs @@ -24,6 +24,11 @@ public static void Process(string source, string url) throw new ApiKeyException("Indexer requires an API key"); } + if (errorMessage == "Request limit reached") + { + throw new RequestLimitReachedException("API limit reached"); + } + throw new NewznabException("Newznab error detected: {0}", errorMessage); } } diff --git a/src/NzbDrone.Core/Indexers/NewznabTestService.cs b/src/NzbDrone.Core/Indexers/NewznabTestService.cs index ca982c405..5e25a5bac 100644 --- a/src/NzbDrone.Core/Indexers/NewznabTestService.cs +++ b/src/NzbDrone.Core/Indexers/NewznabTestService.cs @@ -46,7 +46,11 @@ public void Test(IIndexer indexer) _logger.Warn("Indexer returned result for Newznab RSS URL, API Key appears to be invalid"); var apiKeyFailure = new ValidationFailure("ApiKey", "Invalid API Key"); - throw new ValidationException(new List { apiKeyFailure }.ToArray()); + throw new ValidationException(new List {apiKeyFailure}.ToArray()); + } + catch (RequestLimitReachedException) + { + _logger.Warn("Request limit reached"); } catch (Exception ex) { diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index ca9b25f0d..1592be0d7 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -299,6 +299,7 @@ +