mirror of
https://github.com/Readarr/Readarr
synced 2026-05-09 05:21:41 +02:00
New: Use ISBN / ASIN in preference to goodreads id
This commit is contained in:
parent
6a61702a91
commit
652fdae7d9
1 changed files with 15 additions and 14 deletions
|
|
@ -189,25 +189,13 @@ public List<CandidateEdition> GetRemoteCandidates(LocalEdition localEdition)
|
||||||
List<Book> remoteBooks = null;
|
List<Book> remoteBooks = null;
|
||||||
var candidates = new List<CandidateEdition>();
|
var candidates = new List<CandidateEdition>();
|
||||||
|
|
||||||
var goodreads = localEdition.LocalBooks.Select(x => x.FileTrackInfo.GoodreadsId).Distinct().ToList();
|
|
||||||
var isbns = localEdition.LocalBooks.Select(x => x.FileTrackInfo.Isbn).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 asins = localEdition.LocalBooks.Select(x => x.FileTrackInfo.Asin).Distinct().ToList();
|
||||||
|
var goodreads = localEdition.LocalBooks.Select(x => x.FileTrackInfo.GoodreadsId).Distinct().ToList();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (goodreads.Count == 1 && goodreads[0].IsNotNullOrWhiteSpace())
|
if (isbns.Count == 1 && isbns[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())
|
|
||||||
{
|
{
|
||||||
_logger.Trace($"Searching by isbn {isbns[0]}");
|
_logger.Trace($"Searching by isbn {isbns[0]}");
|
||||||
|
|
||||||
|
|
@ -225,6 +213,19 @@ public List<CandidateEdition> GetRemoteCandidates(LocalEdition localEdition)
|
||||||
remoteBooks = _bookSearchService.SearchByAsin(asins[0]);
|
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 no asin/isbn or no result, fall back to text search
|
||||||
if (remoteBooks == null || !remoteBooks.Any())
|
if (remoteBooks == null || !remoteBooks.Any())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue