Update Norwegian translation
Match box set or boxset
Improve ASIN and Author detection when parsing booklist
MODIFY
XRayBuilder.Core/src/DataSources/Amazon/AmazonClient.cs
XRayBuilder.Core/src/DataSources/Amazon/AmazonClient.cs
@@ -396,8 +396,14 @@ public async Task<BookInfo> SearchBook(string title, string author, string TLD,
var foundAsin = ParseAsinFromUrl(nodeASIN.OuterHtml);
var titleNode = node.SelectSingleNode(".//div/div/div/div[@class='a-fixed-left-grid-col a-col-right']/div/a")
?? node.SelectSingleNode(".//h2");
+
if (titleNode != null)
- result = new BookInfo(WebUtility.HtmlDecode(titleNode.InnerText.Trim()), author, foundAsin);
+ {
+ result = new BookInfo(WebUtility.HtmlDecode(titleNode.InnerText.Trim()), author, foundAsin)
+ {
+ Tld = TLD
+ };
+ }
}
return result;
}

MODIFY
XRayBuilder.Core/src/DataSources/Amazon/AmazonInfoParser.cs
XRayBuilder.Core/src/DataSources/Amazon/AmazonInfoParser.cs
@@ -17,6 +17,7 @@ public class AmazonInfoParser : IAmazonInfoParser
private readonly IHttpClient _httpClient;
private readonly Regex _numbersRegex = new(@"(\d+)", RegexOptions.Compiled);
+ private readonly Regex _regex404 = new(@"(cs_404_logo|cs_404_link)", RegexOptions.Compiled);
public AmazonInfoParser(ILogger logger, IHttpClient httpClient)
{
@@ -62,6 +63,9 @@ public InfoResponse ParseAmazonDocument(HtmlDocument bookDoc)
{
var response = new InfoResponse();
+ if (_regex404.IsMatch(bookDoc.DocumentNode.InnerHtml))
+ return response;
+
CheckCaptcha(bookDoc);
#region Image URL

MODIFY
XRayBuilder.Core/src/Extras/EndActions/EndActionsDataGenerator.cs
XRayBuilder.Core/src/Extras/EndActions/EndActionsDataGenerator.cs
@@ -55,9 +55,6 @@ public async Task<Response> GenerateOld(BookInfo curBook, Settings settings, IPr
//Generate Book search URL from book's ASIN
var ebookLocation = $@"https://www.amazon.{settings.AmazonTld}/dp/{curBook.Asin}";
- // Search Amazon for book
- //_logger.Log(String.Format("Book's Amazon page URL: {0}", ebookLocation));
-
HtmlDocument bookHtmlDoc;
try
{
@@ -120,15 +117,16 @@ string ReadDesc(string file)
{
var listSelectors = new[]
{
+ "//ol[@class='a-carousel' and @role='list']/li[@class='a-carousel-card']",
"//ol[@class='a-carousel' and @role='list']/li[@class='a-carousel-card a-float-left']",
"//ol[@class='a-carousel' and @role='list']/li[@class='a-carousel-card aok-float-left']",
- "//*[contains(@id, 'desktop-dp-sims_purchase-similarities-esp')]//li",
- "//*[@id='desktop-dp-sims_purchase-similarities-sims-feature']//li",
- "//*[contains(@id, 'dp-sims_OnlineDpSimsPurchaseStrategy-sims')]//li",
- "//*[@id='view_to_purchase-sims-feature']//li",
- "//*[@id='desktop-dp-sims_vtp-60-sims-feature']//li",
- "//div[@id='desktop-dp-sims_session-similarities-sims-feature']//li",
- "//div[@id='desktop-dp-sims_session-similarities-brand-protection-sims-feature']//li"
+ "//*[contains(@id, 'desktop-dp-sims_purchase-similarities-esp')]/li",
+ "//*[contains(@id, 'dp-sims_OnlineDpSimsPurchaseStrategy-sims')]/li",
+ "//*[@id='desktop-dp-sims_purchase-similarities-sims-feature']/li",
+ "//*[@id='desktop-dp-sims_vtp-60-sims-feature']/li",
+ "//div[@id='desktop-dp-sims_session-similarities-brand-protection-sims-feature']/li",
+ "//div[@id='desktop-dp-sims_session-similarities-sims-feature']/li",
+ "//*[@id='view_to_purchase-sims-feature']/li"
};
var relatedBooks = listSelectors.SelectMany(selector =>
@@ -221,10 +219,22 @@ private IEnumerable<BookInfo> ParseBookList(HtmlNodeCollection books)
private async Task<BookInfo> SearchOrPrompt(BookInfo book, Func<string, string, string> asinPrompt, Settings settings, CancellationToken cancellationToken = default)
{
- // If the asin was available from another source, use it
if (!string.IsNullOrEmpty(book.Asin))
{
var response = await _amazonInfoParser.GetAndParseAmazonDocument($"https://www.amazon.{settings.AmazonTld}/dp/{book.Asin}", cancellationToken);
+ if (string.IsNullOrEmpty(response.Description))
+ {
+ var localAmazonBook = await _amazonClient.SearchBook(book.Title, book.Author, settings.AmazonTld,
+ cancellationToken);
+ if (localAmazonBook != null)
+ {
+ response = await _amazonInfoParser.GetAndParseAmazonDocument(localAmazonBook.AmazonUrl, cancellationToken);
+ response.ApplyToBookInfo(localAmazonBook);
+ localAmazonBook.Title = book.Title;
+ return localAmazonBook;
+ }
+ response = await _amazonInfoParser.GetAndParseAmazonDocument($"https://www.amazon.com/dp/{book.Asin}", cancellationToken);
+ }
response.ApplyToBookInfo(book);
return book;
@@ -281,8 +291,7 @@ async Task<BookInfo> FromApOrSearch(BookInfo book, CancellationToken ct)
if (series.Next == null && int.TryParse(series.Position, out var seriesPosition) && seriesPosition != series.Total)
{
- _logger.Log("Book was found to be part of a series, but an error occurred finding the next book.\r\n"
- + "Please report this book, the URL, and output log to improve parsing (if it's a real book).");
+ _logger.Log($@"Book was found to be part of a series, but an error occurred finding the next book.{Environment.NewLine}Please report this book, the URL, and output log to improve parsing (if it's a real book).");
}
}

- Update Norwegian translation
- Match box set or boxset
- Improve ASIN and Author detection when parsing booklist