mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update mncvision.id
This commit is contained in:
parent
d942fd8aeb
commit
3330298ddf
2 changed files with 33 additions and 2 deletions
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue