1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Fixed: Indexers that do not support movie search should give better error messages. Radarr now also complains if an indexer does not support certain categories.

This commit is contained in:
Leonardo Galli 2018-05-08 22:19:36 +02:00
parent 58044e0104
commit d1c2569aa6
5 changed files with 77 additions and 6 deletions

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/ExternalModules/CurlSharp" vcs="Git" />
</component>
</project>

View File

@ -298,7 +298,8 @@ protected virtual ValidationFailure TestConnection()
if (releases.Empty())
{
return new ValidationFailure(string.Empty, "No results were returned from your indexer, please check your settings.");
return new ValidationFailure(string.Empty,
"No results were returned from your indexer, please check your settings.");
}
}
catch (ApiKeyException)
@ -319,7 +320,8 @@ protected virtual ValidationFailure TestConnection()
}
else
{
return new ValidationFailure("CaptchaToken", "Site protected by CloudFlare CAPTCHA. Valid CAPTCHA token required.");
return new ValidationFailure("CaptchaToken",
"Site protected by CloudFlare CAPTCHA. Valid CAPTCHA token required.");
}
}
catch (UnsupportedFeedException ex)
@ -334,6 +336,21 @@ protected virtual ValidationFailure TestConnection()
return new ValidationFailure(string.Empty, "Unable to connect to indexer. " + ex.Message);
}
catch (HttpException ex)
{
if (ex.Response.StatusCode == HttpStatusCode.BadRequest &&
ex.Response.Content.Contains("not support the requested 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.");
}
else
{
_logger.Warn(ex, "Unable to connect to indexer");
return new ValidationFailure(string.Empty, "Unable to connect to indexer, check the log for more details");
}
}
catch (Exception ex)
{
_logger.Warn(ex, "Unable to connect to indexer");

View File

@ -93,25 +93,44 @@ protected override void Test(List<ValidationFailure> failures)
failures.AddIfNotNull(TestCapabilities());
}
protected static List<int> CategoryIds(List<NewznabCategory> categories)
{
var l = categories.Select(c => c.Id).ToList();
foreach (var category in categories)
{
l.AddRange(CategoryIds(category.Subcategories));
}
return l;
}
protected virtual ValidationFailure TestCapabilities()
{
try
{
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
var notSupported = Settings.Categories.Except(CategoryIds(capabilities.Categories));
if (notSupported.Any())
{
return new ValidationFailure(string.Empty, $"This indexer does not support the following categories: {string.Join(", ", notSupported)}");
}
if (capabilities.SupportedSearchParameters != null && capabilities.SupportedSearchParameters.Contains("q"))
{
return null;
}
if (capabilities.SupportedTvSearchParameters != null &&
if (capabilities.SupportedMovieSearchParameters != null &&
new[] { "q", "imdbid" }.Any(v => capabilities.SupportedMovieSearchParameters.Contains(v)) &&
new[] { "imdbtitle", "imdbyear" }.All(v => capabilities.SupportedMovieSearchParameters.Contains(v)))
{
return null;
}
return new ValidationFailure(string.Empty, "Indexer does not support required search parameters");
return new ValidationFailure(string.Empty, "This indexer does not support searching for movies :(. Tell your indexer staff to enable this or force add the indexer by disabling search, adding the indexer and then enabling it again.");
}
catch (Exception ex)
{

View File

@ -40,10 +40,15 @@ public virtual IndexerPageableRequestChain GetRecentRequests()
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
// Some indexers might forget to enable movie search, but normal search still works fine. Thus we force a normal search.
if (capabilities.SupportedMovieSearchParameters != null)
{
pageableRequests.Add(GetPagedRequests(MaxPages, Settings.Categories.Concat(Settings.AnimeCategories), "movie", ""));
}
else if (capabilities.SupportedSearchParameters != null)
{
pageableRequests.Add(GetPagedRequests(MaxPages, Settings.Categories.Concat(Settings.AnimeCategories), "search", ""));
}
return pageableRequests;
}

View File

@ -83,24 +83,47 @@ protected override void Test(List<ValidationFailure> failures)
failures.AddIfNotNull(TestCapabilities());
}
protected static List<int> CategoryIds(List<NewznabCategory> categories)
{
var l = categories.Select(c => c.Id).ToList();
foreach (var category in categories)
{
if (category.Subcategories != null)
l.AddRange(CategoryIds(category.Subcategories));
}
return l;
}
protected virtual ValidationFailure TestCapabilities()
{
try
{
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
var notSupported = Settings.Categories.Except(CategoryIds(capabilities.Categories));
if (notSupported.Any())
{
_logger.Warn($"{Definition.Name} does not support the following categories: {string.Join(", ", notSupported)}");
if (notSupported.Count() == Settings.Categories.Count())
return new ValidationFailure(string.Empty, $"This indexer does not support any of the selected categories! (You may need to turn on advanced settings to see them)");
}
if (capabilities.SupportedSearchParameters != null && capabilities.SupportedSearchParameters.Contains("q"))
{
return null;
}
if (capabilities.SupportedMovieSearchParameters != null &&
new[] { "q", "imdbid" }.Any(v => capabilities.SupportedMovieSearchParameters.Contains(v)))
new[] { "q", "imdbid" }.Any(v => capabilities.SupportedMovieSearchParameters.Contains(v)) &&
new[] { "imdbtitle", "imdbyear" }.All(v => capabilities.SupportedMovieSearchParameters.Contains(v)))
{
return null;
}
return new ValidationFailure(string.Empty, "Indexer does not support required search parameters");
return new ValidationFailure(string.Empty, "This indexer does not support searching for movies :(. Tell your indexer staff to enable this or force add the indexer by disabling search, adding the indexer and then enabling it again.");
}
catch (Exception ex)
{