parent
3748a9cf30
commit
faa40e5a77
|
@ -75,6 +75,7 @@ module.exports = {
|
||||||
stop, // program end time (optional)
|
stop, // program end time (optional)
|
||||||
description, // program description (optional)
|
description, // program description (optional)
|
||||||
category, // program category (optional)
|
category, // program category (optional)
|
||||||
|
icon, // program icon (optional)
|
||||||
lang // program language (default: 'en')
|
lang // program language (default: 'en')
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
|
|
|
@ -132,6 +132,7 @@ utils.convertToXMLTV = function ({ config, channels, programs }) {
|
||||||
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 || config.lang
|
||||||
|
const icon = program.icon
|
||||||
|
|
||||||
if (start && title) {
|
if (start && title) {
|
||||||
output += `<programme start="${start}"`
|
output += `<programme start="${start}"`
|
||||||
|
@ -150,6 +151,10 @@ utils.convertToXMLTV = function ({ config, channels, programs }) {
|
||||||
output += `<category lang="${lang}">${category}</category>`
|
output += `<category lang="${lang}">${category}</category>`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (icon) {
|
||||||
|
output += `<icon src="${icon}"/>`
|
||||||
|
}
|
||||||
|
|
||||||
output += '</programme>\r\n'
|
output += '</programme>\r\n'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,13 +55,14 @@ it('can convert object to xmltv string', () => {
|
||||||
start: '2021-03-19 06:00:00 +0000',
|
start: '2021-03-19 06:00:00 +0000',
|
||||||
stop: '2021-03-19 06:30:00 +0000',
|
stop: '2021-03-19 06:30:00 +0000',
|
||||||
category: 'Test',
|
category: 'Test',
|
||||||
|
icon: 'https://example.com/images/Program1.png',
|
||||||
channel: '1TV.com',
|
channel: '1TV.com',
|
||||||
lang: 'it'
|
lang: 'it'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
const output = utils.convertToXMLTV({ channels, programs })
|
const output = utils.convertToXMLTV({ channels, programs })
|
||||||
expect(output).toBe(
|
expect(output).toBe(
|
||||||
'<?xml version="1.0" encoding="UTF-8" ?><tv>\r\n<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png" /></channel>\r\n<channel id="2TV.com"><display-name>2 TV</display-name></channel>\r\n<programme start="20210319060000 +0000" stop="20210319063000 +0000" channel="1TV.com"><title lang="it">Program 1</title><desc lang="it">Description for Program 1</desc><category lang="it">Test</category></programme>\r\n</tv>'
|
'<?xml version="1.0" encoding="UTF-8" ?><tv>\r\n<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/></channel>\r\n<channel id="2TV.com"><display-name>2 TV</display-name></channel>\r\n<programme start="20210319060000 +0000" stop="20210319063000 +0000" channel="1TV.com"><title lang="it">Program 1</title><desc lang="it">Description for Program 1</desc><category lang="it">Test</category><icon src="https://example.com/images/Program1.png"/></programme>\r\n</tv>'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue