mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
New: Indexer Messaging and Error Improvements
(cherry picked from commit 3b505d8734dcbe3fa53acba7f94f1361151e6a44)
This commit is contained in:
parent
0288c4b704
commit
c22c9400c2
@ -50,6 +50,8 @@ public string Content
|
|||||||
|
|
||||||
public bool HasHttpError => (int)StatusCode >= 400;
|
public bool HasHttpError => (int)StatusCode >= 400;
|
||||||
|
|
||||||
|
public bool HasHttpServerError => (int)StatusCode >= 500;
|
||||||
|
|
||||||
public bool HasHttpRedirect => StatusCode == HttpStatusCode.Moved ||
|
public bool HasHttpRedirect => StatusCode == HttpStatusCode.Moved ||
|
||||||
StatusCode == HttpStatusCode.MovedPermanently ||
|
StatusCode == HttpStatusCode.MovedPermanently ||
|
||||||
StatusCode == HttpStatusCode.Found ||
|
StatusCode == HttpStatusCode.Found ||
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using FluentValidation.Results;
|
using FluentValidation.Results;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
@ -94,6 +96,7 @@ protected virtual IList<ReleaseInfo> FetchReleases(Func<IIndexerRequestGenerator
|
|||||||
{
|
{
|
||||||
var releases = new List<ReleaseInfo>();
|
var releases = new List<ReleaseInfo>();
|
||||||
var url = string.Empty;
|
var url = string.Empty;
|
||||||
|
var minimumBackoff = TimeSpan.FromHours(1);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -190,8 +193,7 @@ protected virtual IList<ReleaseInfo> FetchReleases(Func<IIndexerRequestGenerator
|
|||||||
}
|
}
|
||||||
catch (WebException webException)
|
catch (WebException webException)
|
||||||
{
|
{
|
||||||
if (webException.Status == WebExceptionStatus.NameResolutionFailure ||
|
if (webException.Status is WebExceptionStatus.NameResolutionFailure or WebExceptionStatus.ConnectFailure)
|
||||||
webException.Status == WebExceptionStatus.ConnectFailure)
|
|
||||||
{
|
{
|
||||||
_indexerStatusService.RecordConnectionFailure(Definition.Id);
|
_indexerStatusService.RecordConnectionFailure(Definition.Id);
|
||||||
}
|
}
|
||||||
@ -201,7 +203,7 @@ protected virtual IList<ReleaseInfo> FetchReleases(Func<IIndexerRequestGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (webException.Message.Contains("502") || webException.Message.Contains("503") ||
|
if (webException.Message.Contains("502") || webException.Message.Contains("503") ||
|
||||||
webException.Message.Contains("timed out"))
|
webException.Message.Contains("504") || webException.Message.Contains("timed out"))
|
||||||
{
|
{
|
||||||
_logger.Warn("{0} server is currently unavailable. {1} {2}", this, url, webException.Message);
|
_logger.Warn("{0} server is currently unavailable. {1} {2}", this, url, webException.Message);
|
||||||
}
|
}
|
||||||
@ -212,34 +214,29 @@ protected virtual IList<ReleaseInfo> FetchReleases(Func<IIndexerRequestGenerator
|
|||||||
}
|
}
|
||||||
catch (TooManyRequestsException ex)
|
catch (TooManyRequestsException ex)
|
||||||
{
|
{
|
||||||
if (ex.RetryAfter != TimeSpan.Zero)
|
var retryTime = ex.RetryAfter != TimeSpan.Zero ? ex.RetryAfter : minimumBackoff;
|
||||||
{
|
_indexerStatusService.RecordFailure(Definition.Id, retryTime);
|
||||||
_indexerStatusService.RecordFailure(Definition.Id, ex.RetryAfter);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_indexerStatusService.RecordFailure(Definition.Id, TimeSpan.FromHours(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.Warn("API Request Limit reached for {0}", this);
|
_logger.Warn("API Request Limit reached for {0}. Disabled for {1}", this, retryTime);
|
||||||
}
|
}
|
||||||
catch (HttpException ex)
|
catch (HttpException ex)
|
||||||
{
|
{
|
||||||
_indexerStatusService.RecordFailure(Definition.Id);
|
_indexerStatusService.RecordFailure(Definition.Id);
|
||||||
_logger.Warn("{0} {1}", this, ex.Message);
|
if (ex.Response.HasHttpServerError)
|
||||||
}
|
|
||||||
catch (RequestLimitReachedException ex)
|
|
||||||
{
|
{
|
||||||
if (ex.RetryAfter != TimeSpan.Zero)
|
_logger.Warn("Unable to connect to {0} at [{1}]. Indexer's server is unavailable. Try again later. {2}", this, url, ex.Message);
|
||||||
{
|
|
||||||
_indexerStatusService.RecordFailure(Definition.Id, ex.RetryAfter);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_indexerStatusService.RecordFailure(Definition.Id, TimeSpan.FromHours(1));
|
_logger.Warn("{0} {1}", this, ex.Message);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (RequestLimitReachedException ex)
|
||||||
|
{
|
||||||
|
var retryTime = ex.RetryAfter != TimeSpan.Zero ? ex.RetryAfter : minimumBackoff;
|
||||||
|
_indexerStatusService.RecordFailure(Definition.Id, retryTime);
|
||||||
|
|
||||||
_logger.Warn("API Request Limit reached for {0}", this);
|
_logger.Warn("API Request Limit reached for {0}. Disabled for {1}", this, retryTime);
|
||||||
}
|
}
|
||||||
catch (ApiKeyException)
|
catch (ApiKeyException)
|
||||||
{
|
{
|
||||||
@ -259,6 +256,11 @@ protected virtual IList<ReleaseInfo> FetchReleases(Func<IIndexerRequestGenerator
|
|||||||
_logger.Error(ex, "CAPTCHA token required for {0}, check indexer settings.", this);
|
_logger.Error(ex, "CAPTCHA token required for {0}, check indexer settings.", this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (TaskCanceledException ex)
|
||||||
|
{
|
||||||
|
_indexerStatusService.RecordFailure(Definition.Id);
|
||||||
|
_logger.Warn(ex, "Unable to connect to indexer, possibly due to a timeout. {0}", url);
|
||||||
|
}
|
||||||
catch (IndexerException ex)
|
catch (IndexerException ex)
|
||||||
{
|
{
|
||||||
_indexerStatusService.RecordFailure(Definition.Id);
|
_indexerStatusService.RecordFailure(Definition.Id);
|
||||||
@ -360,6 +362,8 @@ protected virtual ValidationFailure TestConnection()
|
|||||||
catch (RequestLimitReachedException ex)
|
catch (RequestLimitReachedException ex)
|
||||||
{
|
{
|
||||||
_logger.Warn("Request limit reached: " + ex.Message);
|
_logger.Warn("Request limit reached: " + ex.Message);
|
||||||
|
|
||||||
|
return new ValidationFailure(string.Empty, "Request limit reached: " + ex.Message);
|
||||||
}
|
}
|
||||||
catch (CloudFlareCaptchaException ex)
|
catch (CloudFlareCaptchaException ex)
|
||||||
{
|
{
|
||||||
@ -392,11 +396,45 @@ protected virtual ValidationFailure TestConnection()
|
|||||||
_logger.Warn(ex, "Indexer does not support the query");
|
_logger.Warn(ex, "Indexer does not support the query");
|
||||||
return new ValidationFailure(string.Empty, "Indexer does not support the current query. Check if the categories and or searching for movies are supported. Check the log for more details.");
|
return new ValidationFailure(string.Empty, "Indexer does not support the current query. Check if the categories and or searching for movies are supported. Check the log for more details.");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
_logger.Warn(ex, "Unable to connect to indexer");
|
||||||
|
if (ex.Response.HasHttpServerError)
|
||||||
|
{
|
||||||
|
return new ValidationFailure(string.Empty, "Unable to connect to indexer, indexer's server is unavailable. Try again later. " + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ex.Response.StatusCode is HttpStatusCode.Forbidden or HttpStatusCode.Unauthorized)
|
||||||
|
{
|
||||||
|
return new ValidationFailure(string.Empty, "Unable to connect to indexer, invalid credentials. " + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ValidationFailure(string.Empty, "Unable to connect to indexer, check the log above the ValidationFailure for more details. " + ex.Message);
|
||||||
|
}
|
||||||
|
catch (HttpRequestException ex)
|
||||||
{
|
{
|
||||||
_logger.Warn(ex, "Unable to connect to indexer");
|
_logger.Warn(ex, "Unable to connect to indexer");
|
||||||
|
|
||||||
return new ValidationFailure(string.Empty, "Unable to connect to indexer. " + ex.Message);
|
return new ValidationFailure(string.Empty, "Unable to connect to indexer, please check your DNS settings and ensure IPv6 is working or disabled. " + ex.Message);
|
||||||
|
}
|
||||||
|
catch (TaskCanceledException ex)
|
||||||
|
{
|
||||||
|
_logger.Warn(ex, "Unable to connect to indexer");
|
||||||
|
|
||||||
|
return new ValidationFailure(string.Empty, "Unable to connect to indexer, possibly due to a timeout. Try again or check your network settings. " + ex.Message);
|
||||||
|
}
|
||||||
|
catch (WebException webException)
|
||||||
|
{
|
||||||
|
_logger.Warn("Unable to connect to indexer.");
|
||||||
|
|
||||||
|
if (webException.Status is WebExceptionStatus.NameResolutionFailure or WebExceptionStatus.ConnectFailure)
|
||||||
|
{
|
||||||
|
return new ValidationFailure(string.Empty, "Unable to connect to indexer connection failure. Check your connection to the indexer's server and DNS." + webException.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (webException.Message.Contains("502") || webException.Message.Contains("503") ||
|
||||||
|
webException.Message.Contains("504") || webException.Message.Contains("timed out"))
|
||||||
|
{
|
||||||
|
return new ValidationFailure(string.Empty, "Unable to connect to indexer, indexer's server is unavailable. Try again later. " + webException.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -123,7 +123,8 @@ protected virtual ReleaseInfo CreateNewReleaseInfo()
|
|||||||
|
|
||||||
protected virtual bool PreProcess(IndexerResponse indexerResponse)
|
protected virtual bool PreProcess(IndexerResponse indexerResponse)
|
||||||
{
|
{
|
||||||
if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK)
|
// Server Down HTTP Errors are handled in HTTPIndexerBase so ignore them here
|
||||||
|
if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK && !indexerResponse.HttpResponse.HasHttpServerError)
|
||||||
{
|
{
|
||||||
throw new IndexerException(indexerResponse, "Indexer API call resulted in an unexpected StatusCode [{0}]", indexerResponse.HttpResponse.StatusCode);
|
throw new IndexerException(indexerResponse, "Indexer API call resulted in an unexpected StatusCode [{0}]", indexerResponse.HttpResponse.StatusCode);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user