From 70856c217cf7e4e4379d4ff46f5373b51f8b0086 Mon Sep 17 00:00:00 2001 From: ta264 Date: Thu, 12 Jan 2023 21:04:11 +0000 Subject: [PATCH] Fixed: Adding book by edition id --- .../BookInfo/BookInfoProxyFixture.cs | 2 +- .../MetadataSource/BookInfo/BookInfoProxy.cs | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/NzbDrone.Core.Test/MetadataSource/BookInfo/BookInfoProxyFixture.cs b/src/NzbDrone.Core.Test/MetadataSource/BookInfo/BookInfoProxyFixture.cs index e528940be..6e5d3e779 100644 --- a/src/NzbDrone.Core.Test/MetadataSource/BookInfo/BookInfoProxyFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSource/BookInfo/BookInfoProxyFixture.cs @@ -75,7 +75,7 @@ namespace NzbDrone.Core.Test.MetadataSource.Goodreads [Test] public void getting_details_of_invalid_book() { - Assert.Throws(() => Subject.GetBookInfo("99999999")); + Assert.Throws(() => Subject.GetBookInfo("1")); } private void ValidateAuthor(Author author) diff --git a/src/NzbDrone.Core/MetadataSource/BookInfo/BookInfoProxy.cs b/src/NzbDrone.Core/MetadataSource/BookInfo/BookInfoProxy.cs index 35159e5c7..dfb0ecbfb 100644 --- a/src/NzbDrone.Core/MetadataSource/BookInfo/BookInfoProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/BookInfo/BookInfoProxy.cs @@ -125,7 +125,7 @@ namespace NzbDrone.Core.MetadataSource.BookInfo catch (BookInfoException e) { _logger.Warn(e, "Unexpected error getting book info"); - throw new AuthorNotFoundException(foreignBookId); + throw new BookNotFoundException(foreignBookId); } } @@ -398,9 +398,9 @@ namespace NzbDrone.Core.MetadataSource.BookInfo } var location = httpResponse.Headers.GetSingleValue("Location"); - var split = location.Split('/'); - var type = split[0]; - var newId = split[1]; + var split = location.Split('/').Reverse().ToList(); + var newId = split[0]; + var type = split[1]; Book book; List authors; @@ -437,6 +437,10 @@ namespace NzbDrone.Core.MetadataSource.BookInfo trimmed.AuthorMetadata = book.AuthorMetadata.Value; trimmed.SeriesLinks = book.SeriesLinks; var edition = book.Editions.Value.SingleOrDefault(e => e.ForeignEditionId == id.ToString()); + if (edition != null) + { + edition.Monitored = true; + } trimmed.Editions = new List { edition }; book = trimmed; @@ -632,9 +636,9 @@ namespace NzbDrone.Core.MetadataSource.BookInfo if (httpResponse.HasHttpRedirect) { var location = httpResponse.Headers.GetSingleValue("Location"); - var split = location.Split('/'); - var type = split[0]; - var newId = split[1]; + var split = location.Split('/').Reverse().ToList(); + var newId = split[0]; + var type = split[1]; if (type == "author") {