Update parser.js
This commit is contained in:
parent
dea63651df
commit
4852c72a9d
|
@ -18,12 +18,12 @@ function parseChannels(xml) {
|
||||||
const channels = channelsTag.elements
|
const channels = channelsTag.elements
|
||||||
.filter(el => el.name === 'channel')
|
.filter(el => el.name === 'channel')
|
||||||
.map(el => {
|
.map(el => {
|
||||||
let { xmltv_id, site, logo } = el.attributes
|
const data = el.attributes
|
||||||
const name = el.elements.find(el => el.type === 'text').text
|
data.name = el.elements.find(el => el.type === 'text').text
|
||||||
if (!name) throw new Error(`Channel '${xmltv_id}' has no valid name`)
|
data.site = data.site || rootSite
|
||||||
site = site || rootSite
|
if (!data.name) throw new Error(`Channel '${data.xmltv_id}' has no valid name`)
|
||||||
|
|
||||||
return new Channel({ name, xmltv_id, logo, site })
|
return new Channel(data)
|
||||||
})
|
})
|
||||||
|
|
||||||
return { site: rootSite, channels }
|
return { site: rootSite, channels }
|
||||||
|
|
Loading…
Reference in New Issue