mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-15 13:51:35 +00:00
User xmldom instead of jsdom
This commit is contained in:
parent
fe1edd24bc
commit
dde0f7a018
3 changed files with 19 additions and 2275 deletions
2280
package-lock.json
generated
2280
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -34,13 +34,13 @@
|
|||
"express": "^4.17.1",
|
||||
"graceful-fs": "^4.2.10",
|
||||
"htmlparser2": "^8.0.1",
|
||||
"jsdom": "^22.1.0",
|
||||
"node-tone": "^1.0.1",
|
||||
"nodemailer": "^6.9.2",
|
||||
"sequelize": "^6.32.1",
|
||||
"socket.io": "^4.5.4",
|
||||
"sqlite3": "^5.1.6",
|
||||
"xml2js": "^0.5.0",
|
||||
"xmldom": "^0.6.0",
|
||||
"xpath": "^0.0.33"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
const axios = require('axios')
|
||||
const htmlSanitizer = require('../utils/htmlSanitizer') // Assuming htmlSanitizer is in the same folder as in Audible
|
||||
const Logger = require('../Logger')
|
||||
const xpath = require('xpath')
|
||||
const jsdom = require('jsdom')
|
||||
const { DOMParser } = require('xmldom')
|
||||
|
||||
class Kindle {
|
||||
cleanResult(result) {
|
||||
|
|
@ -44,10 +43,15 @@ class Kindle {
|
|||
Logger.debug(`[Kindle] Search url: ${url}`)
|
||||
|
||||
var items = await axios
|
||||
.get(url)
|
||||
.get(url, { headers: { 'User-Agent': '' } }) //Amazon blocks the axios user agent so we strip it
|
||||
.then((result) => {
|
||||
if (!result || !result.data) return []
|
||||
const dom = new jsdom.JSDOM(result.data)
|
||||
const dom = new DOMParser({
|
||||
errorHandler: {
|
||||
warning: () => {}, // Suppress warning messages
|
||||
error: () => {} // Suppress error messages
|
||||
}
|
||||
}).parseFromString(result.data)
|
||||
return xpath.select('//div[contains(@class, "s-result-list")]//div[@data-index and @data-asin]', dom)
|
||||
})
|
||||
.catch((error) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue