Update mncvision.id

This commit is contained in:
Aleksandr Statciuk 2021-11-13 11:58:50 +03:00
parent d942fd8aeb
commit 3330298ddf
2 changed files with 33 additions and 2 deletions

View file

@ -43,7 +43,12 @@ module.exports = {
const stop = start.add(duration, 'm')
const description = await loadDescription(item)
programs.push({ title, description, start: start.toJSON(), stop: stop.toJSON() })
programs.push({
title,
description,
start: start.toJSON(),
stop: stop.toJSON()
})
}
return programs
@ -80,8 +85,10 @@ async function loadDescription(item) {
.catch(console.log)
if (!data) return null
const $page = cheerio.load(data)
const description = $page('.synopsis').text().trim()
if (description === '-') return null
return $page('.synopsis').text().trim()
return description
}
function parseDuration(item) {

View file

@ -64,6 +64,30 @@ it('can parse response', done => {
})
})
it('can parse response with empty description', done => {
axios.get.mockImplementation(() =>
Promise.resolve({
data: `<!DOCTYPE html><html lang="en"><head></head><body><blockquote class="bloquet synopsis"> - </blockquote></body></html>`
})
)
parser({ date, channel, content })
.then(result => {
expect(result).toMatchObject([
{
start: '2021-11-11T17:00:00.000Z',
stop: '2021-11-11T18:00:00.000Z',
title: 'African Wild S1: Seals',
description: null
}
])
done()
})
.catch(error => {
done(error)
})
})
it('can handle empty guide', done => {
parser({
date,