Fallback to title and author search if ASIN not found on Goodreads.
MODIFY
XRayBuilder.Core/src/DataSources/Secondary/SecondarySourceGoodreads.cs
XRayBuilder.Core/src/DataSources/Secondary/SecondarySourceGoodreads.cs
@@ -72,15 +72,20 @@ public override bool IsMatchingUrl(string url)
public override async Task<IEnumerable<BookInfo>> SearchBookAsync(IMetadata metadata, CancellationToken cancellationToken = default)
{
+ var title = Uri.EscapeDataString(metadata.Title);
+ var author = Uri.EscapeDataString(Functions.FixAuthor(metadata.Author));
+
// Try by ASIN first, then fall back on author/title
if (!string.IsNullOrEmpty(metadata.Asin))
{
- return ParseSearchResults(await _httpClient.GetPageAsync(SearchUrlAsin(Uri.EscapeDataString(metadata.Asin)), cancellationToken));
+ _logger.Log($"Searching by ASIN...");
+ var bookList = ParseSearchResults(await _httpClient.GetPageAsync(SearchUrlAsin(Uri.EscapeDataString(metadata.Asin)), cancellationToken));
+ var searchBookAsync = bookList as BookInfo[] ?? bookList.ToArray();
+ if (searchBookAsync.Any())
+ return searchBookAsync;
}
- var title = Uri.EscapeDataString(metadata.Title);
- var author = Uri.EscapeDataString(Functions.FixAuthor(metadata.Author));
-
+ _logger.Log($"Searching by Author and Title...");
return ParseSearchResults(await _httpClient.GetPageAsync(SearchUrl(author, title), cancellationToken));
}

Fallback to title and author search if ASIN not found on Goodreads.