fix(nyaa): fix errors on nyaa
This commit is contained in:
@ -22,14 +22,19 @@ module.exports = class Nyaa
|
|||||||
html = await fetch('https://nyaa.si/' + (this.threadId ? `view/${this.threadId}` : (this.hash ? `?q=${this.hash}` : '')))
|
html = await fetch('https://nyaa.si/' + (this.threadId ? `view/${this.threadId}` : (this.hash ? `?q=${this.hash}` : '')))
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
resolve()
|
resolve()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if(!html)
|
if(!html) {
|
||||||
resolve()
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
html = await html.textConverted()
|
html = await html.textConverted()
|
||||||
const $ = cheerio.load(html)
|
const $ = cheerio.load(html)
|
||||||
let topicTitle = $('.panel-title').first().text()
|
let topicTitle = $('.panel-title').first().text()
|
||||||
if(!topicTitle)
|
if(!topicTitle) {
|
||||||
resolve()
|
resolve()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
topicTitle = topicTitle.replace(/\t/g, '').replace(/\n/g, '')
|
topicTitle = topicTitle.replace(/\t/g, '').replace(/\n/g, '')
|
||||||
|
|
||||||
|
@ -35,6 +35,14 @@ describe("big table for check", () => {
|
|||||||
assert.equal((await sphinx.query(`select data from feed where id = 1`))[0].data, '{"a":1,"b":2,"c":3,"d":6,"e":5}')
|
assert.equal((await sphinx.query(`select data from feed where id = 1`))[0].data, '{"a":1,"b":2,"c":3,"d":6,"e":5}')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("insert object to database", async function() {
|
||||||
|
const obj = {a: 1, v: 2}
|
||||||
|
const p = {id: 3, data: obj}
|
||||||
|
await sphinx.insertValues('feed', p)
|
||||||
|
assert.equal((await sphinx.query(`select data from feed where id = 3`))[0].data, '{"a":1,"v":2}')
|
||||||
|
assert.equal(obj, p.data)
|
||||||
|
})
|
||||||
|
|
||||||
it("close", async function() {
|
it("close", async function() {
|
||||||
await sphinx.end()
|
await sphinx.end()
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user