mirror of
https://github.com/Readarr/Readarr
synced 2026-05-08 12:42:51 +02:00
New: End Jackett 'all' endpoint support
(cherry picked from commit 54c914d48fefa730728518d50fc9e49032d0947b)
This commit is contained in:
parent
61454955be
commit
3ea0c8e5fa
6 changed files with 195 additions and 2 deletions
|
|
@ -19,6 +19,7 @@ function getInternalLink(source) {
|
||||||
case 'IndexerRssCheck':
|
case 'IndexerRssCheck':
|
||||||
case 'IndexerSearchCheck':
|
case 'IndexerSearchCheck':
|
||||||
case 'IndexerStatusCheck':
|
case 'IndexerStatusCheck':
|
||||||
|
case 'IndexerJackettAllCheck':
|
||||||
case 'IndexerLongTermStatusCheck':
|
case 'IndexerLongTermStatusCheck':
|
||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Moq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.HealthCheck.Checks;
|
||||||
|
using NzbDrone.Core.Indexers;
|
||||||
|
using NzbDrone.Core.Indexers.Torznab;
|
||||||
|
using NzbDrone.Core.Localization;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class IndexerJackettAllCheckFixture : CoreTest<IndexerJackettAllCheck>
|
||||||
|
{
|
||||||
|
private List<IndexerDefinition> _indexers = new List<IndexerDefinition>();
|
||||||
|
private IndexerDefinition _definition;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void SetUp()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<IIndexerFactory>()
|
||||||
|
.Setup(v => v.All())
|
||||||
|
.Returns(_indexers);
|
||||||
|
|
||||||
|
Mocker.GetMock<ILocalizationService>()
|
||||||
|
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
|
||||||
|
.Returns("Some Warning Message");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GivenIndexer(string baseUrl, string apiPath)
|
||||||
|
{
|
||||||
|
var torznabSettings = new TorznabSettings
|
||||||
|
{
|
||||||
|
BaseUrl = baseUrl,
|
||||||
|
ApiPath = apiPath
|
||||||
|
};
|
||||||
|
|
||||||
|
_definition = new IndexerDefinition
|
||||||
|
{
|
||||||
|
Name = "Indexer",
|
||||||
|
ConfigContract = "TorznabSettings",
|
||||||
|
Settings = torznabSettings
|
||||||
|
};
|
||||||
|
|
||||||
|
_indexers.Add(_definition);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_not_return_error_when_no_indexers()
|
||||||
|
{
|
||||||
|
Subject.Check().ShouldBeOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("http://localhost:9117/", "api")]
|
||||||
|
public void should_not_return_error_when_no_jackett_all_indexers(string baseUrl, string apiPath)
|
||||||
|
{
|
||||||
|
GivenIndexer(baseUrl, apiPath);
|
||||||
|
|
||||||
|
Subject.Check().ShouldBeOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("http://localhost:9117/torznab/all/api", "api")]
|
||||||
|
[TestCase("http://localhost:9117/api/v2.0/indexers/all/results/torznab", "api")]
|
||||||
|
[TestCase("http://localhost:9117/", "/torznab/all/api")]
|
||||||
|
[TestCase("http://localhost:9117/", "/api/v2.0/indexers/all/results/torznab")]
|
||||||
|
public void should_return_warning_if_any_jackett_all_indexer_exists(string baseUrl, string apiPath)
|
||||||
|
{
|
||||||
|
GivenIndexer(baseUrl, apiPath);
|
||||||
|
|
||||||
|
Subject.Check().ShouldBeWarning();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
using FluentValidation.Results;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common.Http;
|
using NzbDrone.Common.Http;
|
||||||
|
|
@ -10,6 +13,7 @@
|
||||||
using NzbDrone.Core.Indexers.Torznab;
|
using NzbDrone.Core.Indexers.Torznab;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using NzbDrone.Core.Validation;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.IndexerTests.TorznabTests
|
namespace NzbDrone.Core.Test.IndexerTests.TorznabTests
|
||||||
{
|
{
|
||||||
|
|
@ -31,7 +35,11 @@ public void Setup()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_caps = new NewznabCapabilities();
|
_caps = new NewznabCapabilities
|
||||||
|
{
|
||||||
|
Categories = Builder<NewznabCategory>.CreateListOfSize(1).All().With(t => t.Id = 1).Build().ToList()
|
||||||
|
};
|
||||||
|
|
||||||
Mocker.GetMock<INewznabCapabilitiesProvider>()
|
Mocker.GetMock<INewznabCapabilitiesProvider>()
|
||||||
.Setup(v => v.GetCapabilities(It.IsAny<NewznabSettings>()))
|
.Setup(v => v.GetCapabilities(It.IsAny<NewznabSettings>()))
|
||||||
.Returns(_caps);
|
.Returns(_caps);
|
||||||
|
|
@ -104,5 +112,50 @@ public void should_use_pagesize_reported_by_caps()
|
||||||
|
|
||||||
Subject.PageSize.Should().Be(25);
|
Subject.PageSize.Should().Be(25);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase("http://localhost:9117/", "/api")]
|
||||||
|
public void url_and_api_not_jackett_all(string baseUrl, string apiPath)
|
||||||
|
{
|
||||||
|
var setting = new TorznabSettings()
|
||||||
|
{
|
||||||
|
BaseUrl = baseUrl,
|
||||||
|
ApiPath = apiPath
|
||||||
|
};
|
||||||
|
|
||||||
|
setting.Validate().IsValid.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("http://localhost:9117/torznab/all/api")]
|
||||||
|
[TestCase("http://localhost:9117/api/v2.0/indexers/all/results/torznab")]
|
||||||
|
public void jackett_all_url_should_not_validate(string baseUrl)
|
||||||
|
{
|
||||||
|
var recentFeed = ReadAllText(@"Files/Indexers/Torznab/torznab_tpb.xml");
|
||||||
|
(Subject.Definition.Settings as TorznabSettings).BaseUrl = baseUrl;
|
||||||
|
|
||||||
|
Mocker.GetMock<IHttpClient>()
|
||||||
|
.Setup(o => o.Execute(It.Is<HttpRequest>(v => v.Method == HttpMethod.Get)))
|
||||||
|
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), recentFeed));
|
||||||
|
|
||||||
|
var result = new NzbDroneValidationResult(Subject.Test());
|
||||||
|
result.IsValid.Should().BeTrue();
|
||||||
|
result.HasWarnings.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("/torznab/all/api")]
|
||||||
|
[TestCase("/api/v2.0/indexers/all/results/torznab")]
|
||||||
|
public void jackett_all_api_should_not_validate(string apiPath)
|
||||||
|
{
|
||||||
|
var recentFeed = ReadAllText(@"Files/Indexers/Torznab/torznab_tpb.xml");
|
||||||
|
|
||||||
|
Mocker.GetMock<IHttpClient>()
|
||||||
|
.Setup(o => o.Execute(It.Is<HttpRequest>(v => v.Method == HttpMethod.Get)))
|
||||||
|
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), recentFeed));
|
||||||
|
|
||||||
|
(Subject.Definition.Settings as TorznabSettings).ApiPath = apiPath;
|
||||||
|
|
||||||
|
var result = new NzbDroneValidationResult(Subject.Test());
|
||||||
|
result.IsValid.Should().BeTrue();
|
||||||
|
result.HasWarnings.Should().BeTrue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.Indexers;
|
||||||
|
using NzbDrone.Core.Indexers.Torznab;
|
||||||
|
using NzbDrone.Core.Localization;
|
||||||
|
using NzbDrone.Core.ThingiProvider.Events;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.HealthCheck.Checks
|
||||||
|
{
|
||||||
|
[CheckOn(typeof(ProviderUpdatedEvent<IIndexer>))]
|
||||||
|
[CheckOn(typeof(ProviderDeletedEvent<IIndexer>))]
|
||||||
|
[CheckOn(typeof(ProviderStatusChangedEvent<IIndexer>))]
|
||||||
|
public class IndexerJackettAllCheck : HealthCheckBase
|
||||||
|
{
|
||||||
|
private readonly IIndexerFactory _providerFactory;
|
||||||
|
|
||||||
|
public IndexerJackettAllCheck(IIndexerFactory providerFactory, ILocalizationService localizationService)
|
||||||
|
: base(localizationService)
|
||||||
|
{
|
||||||
|
_providerFactory = providerFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override HealthCheck Check()
|
||||||
|
{
|
||||||
|
var jackettAllProviders = _providerFactory.All().Where(
|
||||||
|
i => i.ConfigContract.Equals("TorznabSettings") &&
|
||||||
|
((i.Settings as TorznabSettings).BaseUrl.Contains("/torznab/all/api", StringComparison.InvariantCultureIgnoreCase) ||
|
||||||
|
(i.Settings as TorznabSettings).BaseUrl.Contains("/api/v2.0/indexers/all/results/torznab", StringComparison.InvariantCultureIgnoreCase) ||
|
||||||
|
(i.Settings as TorznabSettings).ApiPath.Contains("/torznab/all/api", StringComparison.InvariantCultureIgnoreCase) ||
|
||||||
|
(i.Settings as TorznabSettings).ApiPath.Contains("/api/v2.0/indexers/all/results/torznab", StringComparison.InvariantCultureIgnoreCase)));
|
||||||
|
|
||||||
|
if (jackettAllProviders.Empty())
|
||||||
|
{
|
||||||
|
return new HealthCheck(GetType());
|
||||||
|
}
|
||||||
|
|
||||||
|
return new HealthCheck(GetType(),
|
||||||
|
HealthCheckResult.Warning,
|
||||||
|
string.Format(_localizationService.GetLocalizedString("IndexerJackettAll"),
|
||||||
|
string.Join(", ", jackettAllProviders.Select(i => i.Name))),
|
||||||
|
"#jackett-all-endpoint-used");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -77,6 +77,7 @@ protected override void Test(List<ValidationFailure> failures)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
failures.AddIfNotNull(JackettAll());
|
||||||
failures.AddIfNotNull(TestCapabilities());
|
failures.AddIfNotNull(TestCapabilities());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,6 +108,23 @@ protected virtual ValidationFailure TestCapabilities()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual ValidationFailure JackettAll()
|
||||||
|
{
|
||||||
|
if (Settings.ApiPath.Contains("/torznab/all", StringComparison.InvariantCultureIgnoreCase) ||
|
||||||
|
Settings.ApiPath.Contains("/api/v2.0/indexers/all/results/torznab", StringComparison.InvariantCultureIgnoreCase) ||
|
||||||
|
Settings.BaseUrl.Contains("/torznab/all", StringComparison.InvariantCultureIgnoreCase) ||
|
||||||
|
Settings.BaseUrl.Contains("/api/v2.0/indexers/all/results/torznab", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
return new NzbDroneValidationFailure("ApiPath", "Jackett's all endpoint is not supported, please add indexers individually")
|
||||||
|
{
|
||||||
|
IsWarning = true,
|
||||||
|
DetailedDescription = "Jackett's all endpoint is not supported, please add indexers individually"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public override object RequestAction(string action, IDictionary<string, string> query)
|
public override object RequestAction(string action, IDictionary<string, string> query)
|
||||||
{
|
{
|
||||||
if (action == "newznabCategories")
|
if (action == "newznabCategories")
|
||||||
|
|
|
||||||
|
|
@ -194,6 +194,7 @@
|
||||||
"DownloadClientCheckNoneAvailableMessage": "No download client is available",
|
"DownloadClientCheckNoneAvailableMessage": "No download client is available",
|
||||||
"DownloadClients": "Download Clients",
|
"DownloadClients": "Download Clients",
|
||||||
"DownloadClientSettings": "Download Client Settings",
|
"DownloadClientSettings": "Download Client Settings",
|
||||||
|
"DownloadClientsSettingsSummary": "Download clients, download handling and remote path mappings",
|
||||||
"DownloadClientStatusCheckAllClientMessage": "All download clients are unavailable due to failures",
|
"DownloadClientStatusCheckAllClientMessage": "All download clients are unavailable due to failures",
|
||||||
"DownloadFailedCheckDownloadClientForMoreDetails": "Download failed: check download client for more details",
|
"DownloadFailedCheckDownloadClientForMoreDetails": "Download failed: check download client for more details",
|
||||||
"DownloadFailedInterp": "Download failed: {0}",
|
"DownloadFailedInterp": "Download failed: {0}",
|
||||||
|
|
@ -311,13 +312,14 @@
|
||||||
"IndexerIdHelpTextWarning": "Using a specific indexer with preferred words can lead to duplicate releases being grabbed",
|
"IndexerIdHelpTextWarning": "Using a specific indexer with preferred words can lead to duplicate releases being grabbed",
|
||||||
"IndexerIdvalue0IncludeInPreferredWordsRenamingFormat": "Include in {Preferred Words} renaming format",
|
"IndexerIdvalue0IncludeInPreferredWordsRenamingFormat": "Include in {Preferred Words} renaming format",
|
||||||
"IndexerIdvalue0OnlySupportedWhenIndexerIsSetToAll": "Only supported when Indexer is set to (All)",
|
"IndexerIdvalue0OnlySupportedWhenIndexerIsSetToAll": "Only supported when Indexer is set to (All)",
|
||||||
|
"IndexerJackettAll": "Indexers using the unsupported Jackett 'all' endpoint: {0}",
|
||||||
"IndexerLongTermStatusCheckAllClientMessage": "All indexers are unavailable due to failures for more than 6 hours",
|
"IndexerLongTermStatusCheckAllClientMessage": "All indexers are unavailable due to failures for more than 6 hours",
|
||||||
"IndexerPriority": "Indexer Priority",
|
"IndexerPriority": "Indexer Priority",
|
||||||
"IndexerRssHealthCheckNoIndexers": "No indexers available with RSS sync enabled, Readarr will not grab new releases automatically",
|
"IndexerRssHealthCheckNoIndexers": "No indexers available with RSS sync enabled, Readarr will not grab new releases automatically",
|
||||||
"Indexers": "Indexers",
|
"Indexers": "Indexers",
|
||||||
"IndexerSearchCheckNoAutomaticMessage": "No indexers available with Automatic Search enabled, Readarr will not provide any automatic search results",
|
"IndexerSearchCheckNoAutomaticMessage": "No indexers available with Automatic Search enabled, Readarr will not provide any automatic search results",
|
||||||
"IndexerSettings": "Indexer Settings",
|
"IndexerSettings": "Indexer Settings",
|
||||||
"IndexersSettingsSummary": "Download clients, download handling and remote path mappings",
|
"IndexersSettingsSummary": "Indexers and release restrictions",
|
||||||
"IndexerStatusCheckAllClientMessage": "All indexers are unavailable due to failures",
|
"IndexerStatusCheckAllClientMessage": "All indexers are unavailable due to failures",
|
||||||
"Interval": "Interval",
|
"Interval": "Interval",
|
||||||
"ISBN": "ISBN",
|
"ISBN": "ISBN",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue