2023-04-20 07:13:52 +02:00
|
|
|
const axios = require('axios')
|
|
|
|
const Logger = require('../Logger')
|
|
|
|
|
|
|
|
class AudiobookCovers {
|
|
|
|
constructor() { }
|
|
|
|
|
|
|
|
async search(search) {
|
|
|
|
const url = `https://api.audiobookcovers.com/cover/bytext/`
|
|
|
|
const params = new URLSearchParams([['q', search]])
|
|
|
|
const items = await axios.get(url, { params }).then((res) => {
|
|
|
|
if (!res || !res.data) return []
|
|
|
|
return res.data
|
|
|
|
}).catch(error => {
|
|
|
|
Logger.error('[AudiobookCovers] Cover search error', error)
|
|
|
|
return []
|
|
|
|
})
|
2024-01-30 18:15:50 +01:00
|
|
|
return items.map(item => ({ cover: item.versions.png.original }))
|
2023-04-20 07:13:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = AudiobookCovers
|