This commit is contained in:
advplyr 2021-11-23 15:01:30 -06:00
commit f2b970f812

View File

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