Update utils.js

This commit is contained in:
Aleksandr Statciuk 2021-10-31 01:00:01 +03:00
parent 65d63fce0e
commit c317cb5540
1 changed files with 5 additions and 3 deletions

View File

@ -121,7 +121,7 @@ utils.convertToXMLTV = function ({ channels, programs }) {
const channel = utils.escapeString(program.channel)
const title = utils.escapeString(program.title)
const description = utils.escapeString(program.description)
const category = utils.escapeString(program.category)
const categories = Array.isArray(program.category) ? program.category : [program.category]
const start = program.start ? dayjs.utc(program.start).format('YYYYMMDDHHmmss ZZ') : ''
const stop = program.stop ? dayjs.utc(program.stop).format('YYYYMMDDHHmmss ZZ') : ''
const lang = program.lang || 'en'
@ -140,8 +140,10 @@ utils.convertToXMLTV = function ({ channels, programs }) {
output += `<desc lang="${lang}">${description}</desc>`
}
if (category) {
output += `<category lang="${lang}">${category}</category>`
if (categories.length) {
categories.forEach(category => {
output += `<category lang="${lang}">${utils.escapeString(category)}</category>`
})
}
if (icon) {