diff --git a/src/NzbDrone.Core/Http/CloudFlare/CloudFlareCaptchaException.cs b/src/NzbDrone.Core/Http/CloudFlare/CloudFlareCaptchaException.cs index 1654535a8..3368bd9ce 100644 --- a/src/NzbDrone.Core/Http/CloudFlare/CloudFlareCaptchaException.cs +++ b/src/NzbDrone.Core/Http/CloudFlare/CloudFlareCaptchaException.cs @@ -15,5 +15,10 @@ public CloudFlareCaptchaException(HttpResponse response, CloudFlareCaptchaReques Response = response; CaptchaRequest = captchaRequest; } + + public bool IsExpired + { + get { return Response.Request.Cookies.ContainsKey("cf_clearance"); } + } } } diff --git a/src/NzbDrone.Core/Http/CloudFlare/CloudFlareHttpInterceptor.cs b/src/NzbDrone.Core/Http/CloudFlare/CloudFlareHttpInterceptor.cs index d4377d399..a35f7c0b8 100644 --- a/src/NzbDrone.Core/Http/CloudFlare/CloudFlareHttpInterceptor.cs +++ b/src/NzbDrone.Core/Http/CloudFlare/CloudFlareHttpInterceptor.cs @@ -27,7 +27,7 @@ public HttpResponse PostResponse(HttpResponse response) { if (response.StatusCode == HttpStatusCode.Forbidden && response.Content.Contains(_cloudFlareChallengeScript)) { - _logger.Error("CloudFlare CAPTCHA block on {0}", response.Request.Url); + _logger.Debug("CloudFlare CAPTCHA block on {0}", response.Request.Url); throw new CloudFlareCaptchaException(response, CreateCaptchaRequest(response)); } diff --git a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs index 94b0a1e00..c9cfff122 100644 --- a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs @@ -246,6 +246,18 @@ protected virtual IList FetchReleases(IndexerPageableRequestChain p _indexerStatusService.RecordFailure(Definition.Id); _logger.Warn("Invalid API Key for {0} {1}", this, url); } + catch (CloudFlareCaptchaException ex) + { + _indexerStatusService.RecordFailure(Definition.Id); + if (ex.IsExpired) + { + _logger.Error(ex, "Expired CAPTCHA token for {0}, please refresh in indexer settings.", this); + } + else + { + _logger.Error(ex, "CAPTCHA token required for {0}, check indexer settings.", this); + } + } catch (IndexerException ex) { _indexerStatusService.RecordFailure(Definition.Id); @@ -314,9 +326,16 @@ protected virtual ValidationFailure TestConnection() { _logger.Warn("Request limit reached"); } - catch (CloudFlareCaptchaException) + catch (CloudFlareCaptchaException ex) { - return new ValidationFailure("CaptchaToken", "Site protected by CloudFlare CAPTCHA. Valid CAPTCHA token required."); + if (ex.IsExpired) + { + return new ValidationFailure("CaptchaToken", "CloudFlare CAPTCHA token expired, please Refresh."); + } + else + { + return new ValidationFailure("CaptchaToken", "Site protected by CloudFlare CAPTCHA. Valid CAPTCHA token required."); + } } catch (UnsupportedFeedException ex) { diff --git a/src/UI/Form/CaptchaTemplate.hbs b/src/UI/Form/CaptchaTemplate.hbs index 29ef3edcf..12e472df0 100644 --- a/src/UI/Form/CaptchaTemplate.hbs +++ b/src/UI/Form/CaptchaTemplate.hbs @@ -3,12 +3,13 @@
- +
- + +