Update parser.js

This commit is contained in:
Aleksandr Statciuk 2022-06-16 15:32:34 +03:00
parent dea63651df
commit 4852c72a9d
1 changed files with 5 additions and 5 deletions

View File

@ -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 }