mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 01:20:08 -04:00
commit
b320484c89
2 changed files with 26 additions and 9 deletions
|
@ -23,7 +23,16 @@ module.exports = {
|
|||
return `${API_ENDPOINT}/${path}.xml`
|
||||
},
|
||||
parser: function ({ content, channel, date, cached }) {
|
||||
return parseItems(content, channel, date)
|
||||
const items = parseItems(content, channel, date)
|
||||
|
||||
return items.map(item => {
|
||||
return {
|
||||
...item,
|
||||
title: getTitle(item),
|
||||
description: getDescription(item),
|
||||
categories: getCategories(item)
|
||||
}
|
||||
})
|
||||
},
|
||||
async channels({ path, lang = 'en' }) {
|
||||
let xml = await axios
|
||||
|
@ -42,6 +51,18 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
|
||||
function getTitle(item) {
|
||||
return item.title.length ? item.title[0].value : null
|
||||
}
|
||||
|
||||
function getDescription(item) {
|
||||
return item.desc.length ? item.desc[0].value : null
|
||||
}
|
||||
|
||||
function getCategories(item) {
|
||||
return item.category.map(c => c.value)
|
||||
}
|
||||
|
||||
function parseItems(content, channel, date) {
|
||||
try {
|
||||
const curr_day = date
|
||||
|
|
|
@ -30,14 +30,10 @@ it('can parse response', () => {
|
|||
expect(results[0]).toMatchObject({
|
||||
start: '2022-05-03T10:49:22.000Z',
|
||||
stop: '2022-05-03T11:21:22.000Z',
|
||||
title: [{ value: 'Barney and Friends' }],
|
||||
desc: [
|
||||
{
|
||||
value:
|
||||
'Baby Bop forgets to say "please" and "thank you". Riff shares his dream of becoming an inventor.'
|
||||
}
|
||||
],
|
||||
category: [{ value: 'Children & Family' }]
|
||||
title: 'Barney and Friends',
|
||||
description:
|
||||
'Baby Bop forgets to say "please" and "thank you". Riff shares his dream of becoming an inventor.',
|
||||
categories: ['Children & Family']
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue