Merge pull request #192 from keaganhilliard/master

Better handle books with multiple series
This commit is contained in:
advplyr 2021-11-23 15:01:20 -06:00 committed by GitHub
commit 9cccb0de4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,9 +6,9 @@ class Audible {
constructor() { }
cleanResult(item) {
var { title, subtitle, asin, authors, narrators, publisher_name, publisher_summary, release_date, series, product_images } = item;
var { title, subtitle, asin, authors, narrators, publisher_name, publisher_summary, release_date, series, product_images, publication_name } = item;
var firstSeries = series && series.length > 0 ? series[0] : null;
var primarySeries = this.getPrimarySeries(series, publication_name);
return {
title,
@ -20,8 +20,8 @@ class Audible {
description: stripHtml(publisher_summary).result,
cover: this.getBestImageLink(product_images),
asin,
series: firstSeries ? firstSeries.title : null,
volumeNumber: firstSeries ? firstSeries.sequence : null
series: primarySeries ? primarySeries.title : null,
volumeNumber: primarySeries ? primarySeries.sequence : null
}
}
@ -30,6 +30,10 @@ class Audible {
return images[keys[keys.length - 1]];
}
getPrimarySeries(series, publication_name) {
return (series && series.length > 0) ? series.find((s) => s.title == publication_name) || series[0] : null
}
async search(title, author) {
var queryString = `response_groups=rating,series,contributors,product_desc,media,product_extended_attrs` +
`&image_sizes=500,1024,2000&num_results=25&products_sort_by=Relevance&title=${title}`;