fix(nyaa): fix errors on nyaa

This commit is contained in:
Alexey Kasyanchuk
2018-08-19 20:52:22 +03:00
parent 4dfd5cd15a
commit 91fcc5d68e
2 changed files with 15 additions and 2 deletions

View File

@ -22,14 +22,19 @@ module.exports = class Nyaa
html = await fetch('https://nyaa.si/' + (this.threadId ? `view/${this.threadId}` : (this.hash ? `?q=${this.hash}` : '')))
} catch(err) {
resolve()
return
}
if(!html)
if(!html) {
resolve()
return
}
html = await html.textConverted()
const $ = cheerio.load(html)
let topicTitle = $('.panel-title').first().text()
if(!topicTitle)
if(!topicTitle) {
resolve()
return
}
topicTitle = topicTitle.replace(/\t/g, '').replace(/\n/g, '')