diff --git a/src/NzbDrone.Core.Test/MusicTests/AlbumRepositoryTests/AlbumRepositoryFixture.cs b/src/NzbDrone.Core.Test/MusicTests/AlbumRepositoryTests/AlbumRepositoryFixture.cs index bd6c734fc..9d72a0a7f 100644 --- a/src/NzbDrone.Core.Test/MusicTests/AlbumRepositoryTests/AlbumRepositoryFixture.cs +++ b/src/NzbDrone.Core.Test/MusicTests/AlbumRepositoryTests/AlbumRepositoryFixture.cs @@ -166,6 +166,7 @@ namespace NzbDrone.Core.Test.MusicTests.BookRepositoryTests private EquivalencyAssertionOptions BookComparerOptions(EquivalencyAssertionOptions opts) => opts.ComparingByMembers() .Excluding(ctx => ctx.SelectedMemberInfo.MemberType.IsGenericType && ctx.SelectedMemberInfo.MemberType.GetGenericTypeDefinition() == typeof(LazyLoaded<>)) - .Excluding(x => x.AuthorId); + .Excluding(x => x.AuthorId) + .Excluding(x => x.ForeignEditionId); } } diff --git a/src/NzbDrone.Core/Books/Model/Book.cs b/src/NzbDrone.Core/Books/Model/Book.cs index 8fd13fb29..0cd369f71 100644 --- a/src/NzbDrone.Core/Books/Model/Book.cs +++ b/src/NzbDrone.Core/Books/Model/Book.cs @@ -26,6 +26,7 @@ namespace NzbDrone.Core.Books // These are metadata entries public int AuthorMetadataId { get; set; } public string ForeignBookId { get; set; } + public string ForeignEditionId { get; set; } public string TitleSlug { get; set; } public string Title { get; set; } public DateTime? ReleaseDate { get; set; } @@ -71,6 +72,7 @@ namespace NzbDrone.Core.Books public override void UseMetadataFrom(Book other) { ForeignBookId = other.ForeignBookId; + ForeignEditionId = other.ForeignEditionId; TitleSlug = other.TitleSlug; Title = other.Title; ReleaseDate = other.ReleaseDate; @@ -95,6 +97,7 @@ namespace NzbDrone.Core.Books public override void ApplyChanges(Book other) { ForeignBookId = other.ForeignBookId; + ForeignEditionId = other.ForeignEditionId; AddOptions = other.AddOptions; Monitored = other.Monitored; AnyEditionOk = other.AnyEditionOk; diff --git a/src/NzbDrone.Core/Datastore/TableMapping.cs b/src/NzbDrone.Core/Datastore/TableMapping.cs index 2cff688b9..3fd326bb3 100644 --- a/src/NzbDrone.Core/Datastore/TableMapping.cs +++ b/src/NzbDrone.Core/Datastore/TableMapping.cs @@ -135,6 +135,7 @@ namespace NzbDrone.Core.Datastore Mapper.Entity("Books").RegisterModel() .Ignore(x => x.AuthorId) + .Ignore(x => x.ForeignEditionId) .HasOne(r => r.AuthorMetadata, r => r.AuthorMetadataId) .LazyLoad(x => x.BookFiles, (db, book) => db.Query(new SqlBuilder(db.DatabaseType) diff --git a/src/NzbDrone.Core/ImportLists/Readarr/ReadarrAPIResource.cs b/src/NzbDrone.Core/ImportLists/Readarr/ReadarrAPIResource.cs index bc9fdafa1..5a46b3425 100644 --- a/src/NzbDrone.Core/ImportLists/Readarr/ReadarrAPIResource.cs +++ b/src/NzbDrone.Core/ImportLists/Readarr/ReadarrAPIResource.cs @@ -28,6 +28,7 @@ namespace NzbDrone.Core.ImportLists.Readarr { public string Title { get; set; } public string ForeignBookId { get; set; } + public string ForeignEditionId { get; set; } public string Overview { get; set; } public List Images { get; set; } public bool Monitored { get; set; } diff --git a/src/NzbDrone.Core/ImportLists/Readarr/ReadarrImport.cs b/src/NzbDrone.Core/ImportLists/Readarr/ReadarrImport.cs index 88da51fcd..7e9a83545 100644 --- a/src/NzbDrone.Core/ImportLists/Readarr/ReadarrImport.cs +++ b/src/NzbDrone.Core/ImportLists/Readarr/ReadarrImport.cs @@ -68,10 +68,7 @@ namespace NzbDrone.Core.ImportLists.Readarr { BookGoodreadsId = remoteBook.ForeignBookId, Book = remoteBook.Title, - - // ToDo: Fix me. Edition is no longer in the book resource; rethink edition logic - // Bandaid fix for now...This will cause the imported book to possibly not be same edition as the source - // EditionGoodreadsId = remoteBook.Editions.Single(x => x.Monitored).ForeignEditionId, + EditionGoodreadsId = remoteBook.ForeignEditionId, Author = remoteAuthor.AuthorName, AuthorGoodreadsId = remoteAuthor.ForeignAuthorId }); diff --git a/src/Readarr.Api.V1/Books/BookResource.cs b/src/Readarr.Api.V1/Books/BookResource.cs index c8fa6e9f7..db49b06bb 100644 --- a/src/Readarr.Api.V1/Books/BookResource.cs +++ b/src/Readarr.Api.V1/Books/BookResource.cs @@ -19,6 +19,7 @@ namespace Readarr.Api.V1.Books public string Overview { get; set; } public int AuthorId { get; set; } public string ForeignBookId { get; set; } + public string ForeignEditionId { get; set; } public string TitleSlug { get; set; } public bool Monitored { get; set; } public bool AnyEditionOk { get; set; } @@ -62,6 +63,7 @@ namespace Readarr.Api.V1.Books Id = model.Id, AuthorId = model.AuthorId, ForeignBookId = model.ForeignBookId, + ForeignEditionId = model.Editions?.Value?.SingleOrDefault(x => x.Monitored)?.ForeignEditionId, TitleSlug = model.TitleSlug, Monitored = model.Monitored, AnyEditionOk = model.AnyEditionOk, @@ -92,6 +94,7 @@ namespace Readarr.Api.V1.Books { Id = resource.Id, ForeignBookId = resource.ForeignBookId, + ForeignEditionId = resource.ForeignEditionId, TitleSlug = resource.TitleSlug, Title = resource.Title, Monitored = resource.Monitored,