diff --git a/src/NzbDrone.Core.Test/IndexerSearchTests/SearchDefinitionFixture.cs b/src/NzbDrone.Core.Test/IndexerSearchTests/SearchDefinitionFixture.cs index 4d86947fe..404ff54b4 100644 --- a/src/NzbDrone.Core.Test/IndexerSearchTests/SearchDefinitionFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerSearchTests/SearchDefinitionFixture.cs @@ -13,7 +13,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests public void should_replace_some_special_characters_artist(string artist, string expected) { Subject.Author = new Author { Name = artist }; - Subject.ArtistQuery.Should().Be(expected); + Subject.AuthorQuery.Should().Be(expected); } [TestCase("…and Justice for All", "and+Justice+for+All")] @@ -25,14 +25,14 @@ namespace NzbDrone.Core.Test.IndexerSearchTests public void should_replace_some_special_characters(string album, string expected) { Subject.BookTitle = album; - Subject.AlbumQuery.Should().Be(expected); + Subject.BookQuery.Should().Be(expected); } [TestCase("+", "+")] public void should_not_replace_some_special_characters_if_result_empty_string(string album, string expected) { Subject.BookTitle = album; - Subject.AlbumQuery.Should().Be(expected); + Subject.BookQuery.Should().Be(expected); } } } diff --git a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs index b27df93ab..715109f07 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs @@ -51,7 +51,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests [Test] public void should_search_by_artist_and_album_if_supported() { - _capabilities.SupportedAudioSearchParameters = new[] { "q", "author", "book" }; + _capabilities.SupportedBookSearchParameters = new[] { "q", "author", "title" }; var results = Subject.GetSearchRequests(_singleAlbumSearchCriteria); results.GetTier(0).Should().HaveCount(1); @@ -59,7 +59,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests var page = results.GetAllTiers().First().First(); page.Url.Query.Should().Contain("author=Alien%20Ant%20Farm"); - page.Url.Query.Should().Contain("book=TruANT"); + page.Url.Query.Should().Contain("title=TruANT"); } } } diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/BookSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/BookSearchCriteria.cs index 8f433946c..d569d9ac7 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/BookSearchCriteria.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/BookSearchCriteria.cs @@ -6,9 +6,10 @@ namespace NzbDrone.Core.IndexerSearch.Definitions { public string BookTitle { get; set; } public int BookYear { get; set; } + public string BookIsbn { get; set; } public string Disambiguation { get; set; } - public string AlbumQuery => GetQueryTitle($"{BookTitle}{(Disambiguation.IsNullOrWhiteSpace() ? string.Empty : $"+{Disambiguation}")}"); + public string BookQuery => GetQueryTitle($"{BookTitle}{(Disambiguation.IsNullOrWhiteSpace() ? string.Empty : $"+{Disambiguation}")}"); public override string ToString() { diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs index 2ff64df2e..070854088 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs @@ -19,7 +19,7 @@ namespace NzbDrone.Core.IndexerSearch.Definitions public Author Author { get; set; } public List Books { get; set; } - public string ArtistQuery => GetQueryTitle(Author.Name); + public string AuthorQuery => GetQueryTitle(Author.Name); public static string GetQueryTitle(string title) { diff --git a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index 6b7ee6866..af88a906d 100644 --- a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -44,7 +44,7 @@ namespace NzbDrone.Core.IndexerSearch public List BookSearch(int bookId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) { var book = _bookService.GetBook(bookId); - return AlbumSearch(book, missingOnly, userInvokedSearch, interactiveSearch); + return BookSearch(book, missingOnly, userInvokedSearch, interactiveSearch); } public List AuthorSearch(int authorId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) @@ -56,22 +56,23 @@ namespace NzbDrone.Core.IndexerSearch public List ArtistSearch(Author author, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) { var searchSpec = Get(author, userInvokedSearch, interactiveSearch); - var albums = _bookService.GetBooksByAuthor(author.Id); + var books = _bookService.GetBooksByAuthor(author.Id); - albums = albums.Where(a => a.Monitored).ToList(); + books = books.Where(a => a.Monitored).ToList(); - searchSpec.Books = albums; + searchSpec.Books = books; return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); } - public List AlbumSearch(Book book, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) + public List BookSearch(Book book, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) { var author = _authorService.GetAuthor(book.AuthorId); var searchSpec = Get(author, new List { book }, userInvokedSearch, interactiveSearch); searchSpec.BookTitle = book.Title; + searchSpec.BookIsbn = book.Isbn13; if (book.ReleaseDate.HasValue) { searchSpec.BookYear = book.ReleaseDate.Value.Year; diff --git a/src/NzbDrone.Core/Indexers/Gazelle/GazelleRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Gazelle/GazelleRequestGenerator.cs index ef01d1bb6..8d0fc7755 100644 --- a/src/NzbDrone.Core/Indexers/Gazelle/GazelleRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Gazelle/GazelleRequestGenerator.cs @@ -29,14 +29,14 @@ namespace NzbDrone.Core.Indexers.Gazelle public IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria) { var pageableRequests = new IndexerPageableRequestChain(); - pageableRequests.Add(GetRequest(string.Format("&artistname={0}&groupname={1}", searchCriteria.ArtistQuery, searchCriteria.AlbumQuery))); + pageableRequests.Add(GetRequest(string.Format("&artistname={0}&groupname={1}", searchCriteria.AuthorQuery, searchCriteria.BookQuery))); return pageableRequests; } public IndexerPageableRequestChain GetSearchRequests(AuthorSearchCriteria searchCriteria) { var pageableRequests = new IndexerPageableRequestChain(); - pageableRequests.Add(GetRequest(string.Format("&artistname={0}", searchCriteria.ArtistQuery))); + pageableRequests.Add(GetRequest(string.Format("&artistname={0}", searchCriteria.AuthorQuery))); return pageableRequests; } diff --git a/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs b/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs index 98538139c..1d7de148f 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs @@ -111,8 +111,8 @@ namespace NzbDrone.Core.Indexers.Newznab return null; } - if (capabilities.SupportedAudioSearchParameters != null && - new[] { "author", "book" }.All(v => capabilities.SupportedAudioSearchParameters.Contains(v))) + if (capabilities.SupportedBookSearchParameters != null && + new[] { "author", "book" }.All(v => capabilities.SupportedBookSearchParameters.Contains(v))) { return null; } diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilities.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilities.cs index 408f6c103..98ef050b7 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilities.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilities.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace NzbDrone.Core.Indexers.Newznab { @@ -8,7 +8,7 @@ namespace NzbDrone.Core.Indexers.Newznab public int MaxPageSize { get; set; } public string[] SupportedSearchParameters { get; set; } public string[] SupportedTvSearchParameters { get; set; } - public string[] SupportedAudioSearchParameters { get; set; } + public string[] SupportedBookSearchParameters { get; set; } public bool SupportsAggregateIdSearch { get; set; } public List Categories { get; set; } @@ -18,7 +18,7 @@ namespace NzbDrone.Core.Indexers.Newznab MaxPageSize = 100; SupportedSearchParameters = new[] { "q" }; SupportedTvSearchParameters = new[] { "q", "rid", "season", "ep" }; // This should remain 'rid' for older newznab installs. - SupportedAudioSearchParameters = new[] { "q", "author", "book" }; + SupportedBookSearchParameters = new[] { "q", "author", "title" }; SupportsAggregateIdSearch = false; Categories = new List(); } diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilitiesProvider.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilitiesProvider.cs index a7ac44737..1491f3290 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilitiesProvider.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilitiesProvider.cs @@ -128,14 +128,14 @@ namespace NzbDrone.Core.Indexers.Newznab capabilities.SupportsAggregateIdSearch = true; } - var xmlAudioSearch = xmlSearching.Element("audio-search"); + var xmlAudioSearch = xmlSearching.Element("book-search"); if (xmlAudioSearch == null || xmlAudioSearch.Attribute("available").Value != "yes") { - capabilities.SupportedAudioSearchParameters = null; + capabilities.SupportedBookSearchParameters = null; } else if (xmlAudioSearch.Attribute("supportedParams") != null) { - capabilities.SupportedAudioSearchParameters = xmlAudioSearch.Attribute("supportedParams").Value.Split(','); + capabilities.SupportedBookSearchParameters = xmlAudioSearch.Attribute("supportedParams").Value.Split(','); } } diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs index a59bac945..56ebeea7f 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs @@ -38,10 +38,10 @@ namespace NzbDrone.Core.Indexers.Newznab { var capabilities = _capabilitiesProvider.GetCapabilities(Settings); - return capabilities.SupportedAudioSearchParameters != null && - capabilities.SupportedAudioSearchParameters.Contains("q") && - capabilities.SupportedAudioSearchParameters.Contains("author") && - capabilities.SupportedAudioSearchParameters.Contains("book"); + return capabilities.SupportedBookSearchParameters != null && + capabilities.SupportedBookSearchParameters.Contains("q") && + capabilities.SupportedBookSearchParameters.Contains("author") && + capabilities.SupportedBookSearchParameters.Contains("title"); } } @@ -51,9 +51,9 @@ namespace NzbDrone.Core.Indexers.Newznab var capabilities = _capabilitiesProvider.GetCapabilities(Settings); - if (capabilities.SupportedAudioSearchParameters != null) + if (capabilities.SupportedBookSearchParameters != null) { - pageableRequests.Add(GetPagedRequests(MaxPages, Settings.Categories, "music", "")); + pageableRequests.Add(GetPagedRequests(MaxPages, Settings.Categories, "book", "")); } else if (capabilities.SupportedSearchParameters != null) { @@ -69,9 +69,9 @@ namespace NzbDrone.Core.Indexers.Newznab if (SupportsAudioSearch) { - AddAudioPageableRequests(pageableRequests, + AddBookPageableRequests(pageableRequests, searchCriteria, - NewsnabifyTitle($"&author={searchCriteria.ArtistQuery}&book={searchCriteria.AlbumQuery}")); + NewsnabifyTitle($"&author={searchCriteria.AuthorQuery}&title={searchCriteria.BookQuery}")); } if (SupportsSearch) @@ -81,7 +81,14 @@ namespace NzbDrone.Core.Indexers.Newznab pageableRequests.Add(GetPagedRequests(MaxPages, Settings.Categories, "search", - NewsnabifyTitle($"&q={searchCriteria.ArtistQuery}+{searchCriteria.AlbumQuery}"))); + NewsnabifyTitle($"&q={searchCriteria.BookIsbn}"))); + + pageableRequests.AddTier(); + + pageableRequests.Add(GetPagedRequests(MaxPages, + Settings.Categories, + "search", + NewsnabifyTitle($"&q={searchCriteria.AuthorQuery}+{searchCriteria.BookQuery}"))); } return pageableRequests; @@ -93,9 +100,9 @@ namespace NzbDrone.Core.Indexers.Newznab if (SupportsAudioSearch) { - AddAudioPageableRequests(pageableRequests, + AddBookPageableRequests(pageableRequests, searchCriteria, - NewsnabifyTitle($"&author={searchCriteria.ArtistQuery}")); + NewsnabifyTitle($"&author={searchCriteria.AuthorQuery}")); } if (SupportsSearch) @@ -105,17 +112,17 @@ namespace NzbDrone.Core.Indexers.Newznab pageableRequests.Add(GetPagedRequests(MaxPages, Settings.Categories, "search", - NewsnabifyTitle($"&q={searchCriteria.ArtistQuery}"))); + NewsnabifyTitle($"&q={searchCriteria.AuthorQuery}"))); } return pageableRequests; } - private void AddAudioPageableRequests(IndexerPageableRequestChain chain, SearchCriteriaBase searchCriteria, string parameters) + private void AddBookPageableRequests(IndexerPageableRequestChain chain, SearchCriteriaBase searchCriteria, string parameters) { chain.AddTier(); - chain.Add(GetPagedRequests(MaxPages, Settings.Categories, "music", $"&q={parameters}")); + chain.Add(GetPagedRequests(MaxPages, Settings.Categories, "book", $"&q={parameters}")); } private IEnumerable GetPagedRequests(int maxPages, IEnumerable categories, string searchType, string parameters) diff --git a/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs index c62d6d5a7..1534dc78d 100644 --- a/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs @@ -30,8 +30,8 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs var pageableRequests = new IndexerPageableRequestChain(); pageableRequests.Add(GetPagedRequests(string.Format("{0}+{1}", - searchCriteria.ArtistQuery, - searchCriteria.AlbumQuery))); + searchCriteria.AuthorQuery, + searchCriteria.BookQuery))); return pageableRequests; } @@ -41,7 +41,7 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs var pageableRequests = new IndexerPageableRequestChain(); pageableRequests.Add(GetPagedRequests(string.Format("{0}", - searchCriteria.ArtistQuery))); + searchCriteria.AuthorQuery))); return pageableRequests; } diff --git a/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs index 72114cc81..0fbf05661 100644 --- a/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Rarbg/RarbgRequestGenerator.cs @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Indexers.Rarbg { var pageableRequests = new IndexerPageableRequestChain(); - pageableRequests.Add(GetPagedRequests("search", null, "{0}+{1}", searchCriteria.ArtistQuery, searchCriteria.AlbumQuery)); + pageableRequests.Add(GetPagedRequests("search", null, "{0}+{1}", searchCriteria.AuthorQuery, searchCriteria.BookQuery)); return pageableRequests; } @@ -39,7 +39,7 @@ namespace NzbDrone.Core.Indexers.Rarbg { var pageableRequests = new IndexerPageableRequestChain(); - pageableRequests.Add(GetPagedRequests("search", null, "{0}", searchCriteria.ArtistQuery)); + pageableRequests.Add(GetPagedRequests("search", null, "{0}", searchCriteria.AuthorQuery)); return pageableRequests; } diff --git a/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs b/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs index 0ad7b3fc7..9c76fa25c 100644 --- a/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs +++ b/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs @@ -91,8 +91,8 @@ namespace NzbDrone.Core.Indexers.Torznab return null; } - if (capabilities.SupportedAudioSearchParameters != null && - new[] { "author", "book" }.All(v => capabilities.SupportedAudioSearchParameters.Contains(v))) + if (capabilities.SupportedBookSearchParameters != null && + new[] { "author", "title" }.All(v => capabilities.SupportedBookSearchParameters.Contains(v))) { return null; }