From 6a24bf7a782768dc6f0853e67d4ddf4ac73672d9 Mon Sep 17 00:00:00 2001 From: ta264 Date: Wed, 5 Aug 2020 21:13:23 +0100 Subject: [PATCH] Disable newznab book-search, enable for Torznab --- .../Newznab/NewznabRequestGenerator.cs | 22 ++-------------- .../Indexers/Newznab/NewznabRssParser.cs | 2 +- src/NzbDrone.Core/Indexers/Torznab/Torznab.cs | 2 +- .../Torznab/TorznabRequestGenerator.cs | 26 +++++++++++++++++++ 4 files changed, 30 insertions(+), 22 deletions(-) create mode 100644 src/NzbDrone.Core/Indexers/Torznab/TorznabRequestGenerator.cs diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs index d5764aad8..7dbb3f339 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs @@ -8,7 +8,7 @@ namespace NzbDrone.Core.Indexers.Newznab { public class NewznabRequestGenerator : IIndexerRequestGenerator { - private readonly INewznabCapabilitiesProvider _capabilitiesProvider; + protected readonly INewznabCapabilitiesProvider _capabilitiesProvider; public int MaxPages { get; set; } public int PageSize { get; set; } public NewznabSettings Settings { get; set; } @@ -32,18 +32,7 @@ namespace NzbDrone.Core.Indexers.Newznab } } - private bool SupportsBookSearch - { - get - { - var capabilities = _capabilitiesProvider.GetCapabilities(Settings); - - return capabilities.SupportedBookSearchParameters != null && - capabilities.SupportedBookSearchParameters.Contains("q") && - capabilities.SupportedBookSearchParameters.Contains("author") && - capabilities.SupportedBookSearchParameters.Contains("title"); - } - } + protected virtual bool SupportsBookSearch => false; public virtual IndexerPageableRequestChain GetRecentRequests() { @@ -78,13 +67,6 @@ namespace NzbDrone.Core.Indexers.Newznab { pageableRequests.AddTier(); -/* pageableRequests.Add(GetPagedRequests(MaxPages, - Settings.Categories, - "search", - NewsnabifyTitle($"&q={searchCriteria.BookIsbn}"))); - - pageableRequests.AddTier();*/ - pageableRequests.Add(GetPagedRequests(MaxPages, Settings.Categories, "search", diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabRssParser.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabRssParser.cs index 1af275e01..8c50b70cd 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabRssParser.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabRssParser.cs @@ -128,7 +128,7 @@ namespace NzbDrone.Core.Indexers.Newznab protected virtual string GetAlbum(XElement item) { - var albumString = TryGetNewznabAttribute(item, "book"); + var albumString = TryGetNewznabAttribute(item, "booktitle"); if (!albumString.IsNullOrWhiteSpace()) { diff --git a/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs b/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs index 9c76fa25c..e93d2129c 100644 --- a/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs +++ b/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs @@ -23,7 +23,7 @@ namespace NzbDrone.Core.Indexers.Torznab public override IIndexerRequestGenerator GetRequestGenerator() { - return new NewznabRequestGenerator(_capabilitiesProvider) + return new TorznabRequestGenerator(_capabilitiesProvider) { PageSize = PageSize, Settings = Settings diff --git a/src/NzbDrone.Core/Indexers/Torznab/TorznabRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Torznab/TorznabRequestGenerator.cs new file mode 100644 index 000000000..7a4c20dcb --- /dev/null +++ b/src/NzbDrone.Core/Indexers/Torznab/TorznabRequestGenerator.cs @@ -0,0 +1,26 @@ +using System.Linq; +using NzbDrone.Core.Indexers.Newznab; + +namespace NzbDrone.Core.Indexers.Torznab +{ + public class TorznabRequestGenerator : NewznabRequestGenerator + { + public TorznabRequestGenerator(INewznabCapabilitiesProvider capabilitiesProvider) + : base(capabilitiesProvider) + { + } + + protected override bool SupportsBookSearch + { + get + { + var capabilities = _capabilitiesProvider.GetCapabilities(Settings); + + return capabilities.SupportedBookSearchParameters != null && + capabilities.SupportedBookSearchParameters.Contains("q") && + capabilities.SupportedBookSearchParameters.Contains("author") && + capabilities.SupportedBookSearchParameters.Contains("title"); + } + } + } +}