mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-05-04 01:17:19 +02:00
Update async function, update debug log
This commit is contained in:
parent
059d6d96a7
commit
2b3688b141
@ -169,7 +169,7 @@ class BookFinder {
|
|||||||
var books = []
|
var books = []
|
||||||
var maxTitleDistance = !isNaN(options.titleDistance) ? Number(options.titleDistance) : 4
|
var maxTitleDistance = !isNaN(options.titleDistance) ? Number(options.titleDistance) : 4
|
||||||
var maxAuthorDistance = !isNaN(options.authorDistance) ? Number(options.authorDistance) : 4
|
var maxAuthorDistance = !isNaN(options.authorDistance) ? Number(options.authorDistance) : 4
|
||||||
Logger.debug(`Cover Search: title: "${title}", author: "${author}", provider: ${provider}`)
|
Logger.debug(`Book Search: title: "${title}", author: "${author}", provider: ${provider}`)
|
||||||
|
|
||||||
if (provider === 'google') {
|
if (provider === 'google') {
|
||||||
return this.getGoogleBooksResults(title, author, maxTitleDistance, maxAuthorDistance)
|
return this.getGoogleBooksResults(title, author, maxTitleDistance, maxAuthorDistance)
|
||||||
|
@ -38,12 +38,12 @@ class Audible {
|
|||||||
return /[0-9A-Z]{10}/.test(title)
|
return /[0-9A-Z]{10}/.test(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
async asinSearch(asin) {
|
asinSearch(asin) {
|
||||||
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`;
|
`&image_sizes=500,1024,2000`;
|
||||||
var url = `https://api.audible.com/1.0/catalog/products/${asin}?${queryString}`
|
var url = `https://api.audible.com/1.0/catalog/products/${asin}?${queryString}`
|
||||||
Logger.debug(`[Audible] ASIN url: ${url}`)
|
Logger.debug(`[Audible] ASIN url: ${url}`)
|
||||||
return await axios.get(url).then((res) => {
|
return axios.get(url).then((res) => {
|
||||||
if (!res || !res.data || !res.data.product) return []
|
if (!res || !res.data || !res.data.product) return []
|
||||||
return [res.data.product]
|
return [res.data.product]
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
@ -56,7 +56,7 @@ class Audible {
|
|||||||
if (this.isProbablyAsin(title)) {
|
if (this.isProbablyAsin(title)) {
|
||||||
var items = await this.asinSearch(title)
|
var items = await this.asinSearch(title)
|
||||||
if (items.length > 0) return items.map(item => this.cleanResult(item))
|
if (items.length > 0) return items.map(item => this.cleanResult(item))
|
||||||
}
|
}
|
||||||
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}`;
|
||||||
if (author) queryString += `&author=${author}`
|
if (author) queryString += `&author=${author}`
|
||||||
|
Loading…
Reference in New Issue
Block a user