fix(rutracker): encoding fix

This commit is contained in:
Alexey Kasyanchuk
2018-08-16 07:58:37 +03:00
parent 42fce4e720
commit 266c103321
4 changed files with 5 additions and 4 deletions

View File

@ -22,7 +22,7 @@ module.exports = class Nyaa
} }
if(!html) if(!html)
return return
html = await html.text() 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)

View File

@ -22,7 +22,7 @@ module.exports = class Rutracker
} }
if(!html) if(!html)
return return
html = await html.text() html = await html.textConverted()
const $ = cheerio.load(html) const $ = cheerio.load(html)
const topicTitle = $('#topic-title').text() const topicTitle = $('#topic-title').text()
if(!topicTitle) if(!topicTitle)

View File

@ -5,13 +5,13 @@ describe("nyaa", () => {
let nyaa = new Nyaa(); let nyaa = new Nyaa();
it("findHash", async function() { it("findHash", async function() {
this.timeout(10000) this.timeout(5000)
const data = await nyaa.findHash('b57cc972ecc31dd31e9349017e5d26c164e08906') const data = await nyaa.findHash('b57cc972ecc31dd31e9349017e5d26c164e08906')
assert.equal(data.name, '[HorribleSubs] One Piece - 794 [1080p].mkv') assert.equal(data.name, '[HorribleSubs] One Piece - 794 [1080p].mkv')
}) })
it("notFound", async function() { it("notFound", async function() {
this.timeout(10000) this.timeout(5000)
assert(!await nyaa.findHash('FFEDA8DF683F34A08BE89026114E6C05F881DCC0')) assert(!await nyaa.findHash('FFEDA8DF683F34A08BE89026114E6C05F881DCC0'))
}) })
}); });

View File

@ -20,5 +20,6 @@ describe("rutracker", () => {
assert.equal(data.name, '(Doom metal / Melodic metal / Instrumental) Folie A Deux - Demo - 2012, MP3, 128-320 kbps') assert.equal(data.name, '(Doom metal / Melodic metal / Instrumental) Folie A Deux - Demo - 2012, MP3, 128-320 kbps')
assert.equal(data.poster, 'http://i44.fastpic.ru/big/2012/1018/a2/4e8740f608387b32b74c5deea72d05a2.jpg') assert.equal(data.poster, 'http://i44.fastpic.ru/big/2012/1018/a2/4e8740f608387b32b74c5deea72d05a2.jpg')
assert.equal(data.rutrackerThreadId, 4220109) assert.equal(data.rutrackerThreadId, 4220109)
assert(data.description.includes('выхода'))
}) })
}); });