Update utils.js
This commit is contained in:
parent
81c8bcb7ea
commit
de3dc7f2ad
24
src/utils.js
24
src/utils.js
|
@ -94,18 +94,18 @@ utils.escapeString = function (string, defaultValue = '') {
|
||||||
.trim()
|
.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.convertToXMLTV = function ({ config, channels, programs }) {
|
utils.convertToXMLTV = function ({ channels, programs }) {
|
||||||
const url = config.site ? 'https://' + config.site : null
|
|
||||||
let output = `<?xml version="1.0" encoding="UTF-8" ?><tv>\r\n`
|
let output = `<?xml version="1.0" encoding="UTF-8" ?><tv>\r\n`
|
||||||
for (let channel of channels) {
|
for (let channel of channels) {
|
||||||
const id = this.escapeString(channel['xmltv_id'])
|
const id = utils.escapeString(channel['xmltv_id'])
|
||||||
const displayName = this.escapeString(channel.name)
|
const displayName = utils.escapeString(channel.name)
|
||||||
output += `<channel id="${id}"><display-name>${displayName}</display-name>`
|
output += `<channel id="${id}"><display-name>${displayName}</display-name>`
|
||||||
if (channel.logo) {
|
if (channel.logo) {
|
||||||
const logo = this.escapeString(channel.logo)
|
const logo = utils.escapeString(channel.logo)
|
||||||
output += `<icon src="${logo}"/>`
|
output += `<icon src="${logo}"/>`
|
||||||
}
|
}
|
||||||
if (url) {
|
if (channel.site) {
|
||||||
|
const url = channel.site ? 'https://' + channel.site : null
|
||||||
output += `<url>${url}</url>`
|
output += `<url>${url}</url>`
|
||||||
}
|
}
|
||||||
output += `</channel>\r\n`
|
output += `</channel>\r\n`
|
||||||
|
@ -114,14 +114,14 @@ utils.convertToXMLTV = function ({ config, channels, programs }) {
|
||||||
for (let program of programs) {
|
for (let program of programs) {
|
||||||
if (!program) continue
|
if (!program) continue
|
||||||
|
|
||||||
const channel = this.escapeString(program.channel)
|
const channel = utils.escapeString(program.channel)
|
||||||
const title = this.escapeString(program.title)
|
const title = utils.escapeString(program.title)
|
||||||
const description = this.escapeString(program.description)
|
const description = utils.escapeString(program.description)
|
||||||
const category = this.escapeString(program.category)
|
const category = utils.escapeString(program.category)
|
||||||
const start = program.start ? dayjs.utc(program.start).format('YYYYMMDDHHmmss ZZ') : ''
|
const start = program.start ? dayjs.utc(program.start).format('YYYYMMDDHHmmss ZZ') : ''
|
||||||
const stop = program.stop ? dayjs.utc(program.stop).format('YYYYMMDDHHmmss ZZ') : ''
|
const stop = program.stop ? dayjs.utc(program.stop).format('YYYYMMDDHHmmss ZZ') : ''
|
||||||
const lang = program.lang || config.lang
|
const lang = program.lang || 'en'
|
||||||
const icon = this.escapeString(program.icon)
|
const icon = utils.escapeString(program.icon)
|
||||||
|
|
||||||
if (start && title) {
|
if (start && title) {
|
||||||
output += `<programme start="${start}"`
|
output += `<programme start="${start}"`
|
||||||
|
|
Loading…
Reference in New Issue