From 652fdae7d9b6fe2bbd79bec9e4b6e99fa4173ae7 Mon Sep 17 00:00:00 2001 From: ta264 Date: Tue, 30 Mar 2021 21:24:41 +0100 Subject: [PATCH] New: Use ISBN / ASIN in preference to goodreads id --- .../Identification/CandidateService.cs | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/NzbDrone.Core/MediaFiles/BookImport/Identification/CandidateService.cs b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/CandidateService.cs index dd3024124..e00228ab3 100644 --- a/src/NzbDrone.Core/MediaFiles/BookImport/Identification/CandidateService.cs +++ b/src/NzbDrone.Core/MediaFiles/BookImport/Identification/CandidateService.cs @@ -189,25 +189,13 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Identification List remoteBooks = null; var candidates = new List(); - var goodreads = localEdition.LocalBooks.Select(x => x.FileTrackInfo.GoodreadsId).Distinct().ToList(); var isbns = localEdition.LocalBooks.Select(x => x.FileTrackInfo.Isbn).Distinct().ToList(); var asins = localEdition.LocalBooks.Select(x => x.FileTrackInfo.Asin).Distinct().ToList(); + var goodreads = localEdition.LocalBooks.Select(x => x.FileTrackInfo.GoodreadsId).Distinct().ToList(); try { - if (goodreads.Count == 1 && goodreads[0].IsNotNullOrWhiteSpace()) - { - if (int.TryParse(goodreads[0], out var id)) - { - _logger.Trace($"Searching by goodreads id {id}"); - - remoteBooks = _bookSearchService.SearchByGoodreadsId(id); - } - } - - if ((remoteBooks == null || !remoteBooks.Any()) && - isbns.Count == 1 && - isbns[0].IsNotNullOrWhiteSpace()) + if (isbns.Count == 1 && isbns[0].IsNotNullOrWhiteSpace()) { _logger.Trace($"Searching by isbn {isbns[0]}"); @@ -225,6 +213,19 @@ namespace NzbDrone.Core.MediaFiles.BookImport.Identification remoteBooks = _bookSearchService.SearchByAsin(asins[0]); } + // if we don't have an independent ID, try a goodreads ID, but may have been matched to the wrong edition by calibre + if ((remoteBooks == null || !remoteBooks.Any()) && + goodreads.Count == 1 && + goodreads[0].IsNotNullOrWhiteSpace()) + { + if (int.TryParse(goodreads[0], out var id)) + { + _logger.Trace($"Searching by goodreads id {id}"); + + remoteBooks = _bookSearchService.SearchByGoodreadsId(id); + } + } + // if no asin/isbn or no result, fall back to text search if (remoteBooks == null || !remoteBooks.Any()) {