mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-03 00:06:46 +01:00
Update:Book matches support lowercase letters in audible ASIN #2849
This commit is contained in:
parent
0f7c99d989
commit
f0caf1a933
@ -79,12 +79,19 @@ class Audible {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if a search title matches an ASIN. Supports lowercase letters
|
||||||
|
*
|
||||||
|
* @param {string} title
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
isProbablyAsin(title) {
|
isProbablyAsin(title) {
|
||||||
return /^[0-9A-Z]{10}$/.test(title)
|
return /^[0-9A-Za-z]{10}$/.test(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
asinSearch(asin, region) {
|
asinSearch(asin, region) {
|
||||||
asin = encodeURIComponent(asin)
|
if (!asin) return []
|
||||||
|
asin = encodeURIComponent(asin.toUpperCase())
|
||||||
var regionQuery = region ? `?region=${region}` : ''
|
var regionQuery = region ? `?region=${region}` : ''
|
||||||
var url = `https://api.audnex.us/books/${asin}${regionQuery}`
|
var url = `https://api.audnex.us/books/${asin}${regionQuery}`
|
||||||
Logger.debug(`[Audible] ASIN url: ${url}`)
|
Logger.debug(`[Audible] ASIN url: ${url}`)
|
||||||
@ -124,7 +131,7 @@ class Audible {
|
|||||||
const url = `https://api.audible${tld}/1.0/catalog/products?${queryString}`
|
const url = `https://api.audible${tld}/1.0/catalog/products?${queryString}`
|
||||||
Logger.debug(`[Audible] Search url: ${url}`)
|
Logger.debug(`[Audible] Search url: ${url}`)
|
||||||
items = await axios.get(url).then((res) => {
|
items = await axios.get(url).then((res) => {
|
||||||
if (!res || !res.data || !res.data.products) return null
|
if (!res?.data?.products) return null
|
||||||
return Promise.all(res.data.products.map(result => this.asinSearch(result.asin, region)))
|
return Promise.all(res.data.products.map(result => this.asinSearch(result.asin, region)))
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
Logger.error('[Audible] query search error', error)
|
Logger.error('[Audible] query search error', error)
|
||||||
|
Loading…
Reference in New Issue
Block a user