Update utils.js
This commit is contained in:
parent
06c1644449
commit
04b935fb19
31
src/utils.js
31
src/utils.js
|
@ -150,7 +150,9 @@ utils.escapeString = function (string, defaultValue = '') {
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.convertToXMLTV = function ({ channels, programs }) {
|
utils.convertToXMLTV = function ({ channels, programs }) {
|
||||||
let output = `<?xml version="1.0" encoding="UTF-8" ?><tv date="${dayjs.utc().format('YYYYMMDD')}">\r\n`
|
let output = `<?xml version="1.0" encoding="UTF-8" ?><tv date="${dayjs
|
||||||
|
.utc()
|
||||||
|
.format('YYYYMMDD')}">\r\n`
|
||||||
for (let channel of channels) {
|
for (let channel of channels) {
|
||||||
const id = utils.escapeString(channel['xmltv_id'])
|
const id = utils.escapeString(channel['xmltv_id'])
|
||||||
const displayName = utils.escapeString(channel.name)
|
const displayName = utils.escapeString(channel.name)
|
||||||
|
@ -179,7 +181,18 @@ utils.convertToXMLTV = function ({ channels, programs }) {
|
||||||
const xmltv_ns = createXMLTVNS(program.season, program.episode)
|
const xmltv_ns = createXMLTVNS(program.season, program.episode)
|
||||||
const onscreen = createOnScreen(program.season, program.episode)
|
const onscreen = createOnScreen(program.season, program.episode)
|
||||||
const date = program.date || ''
|
const date = program.date || ''
|
||||||
const credits = createCredits({'director':program.director,'actor':program.actor, 'writer':program.writer,'adapter':program.adapter,'producer':program.producer, 'composer':program.composer, 'editor':program.editor, 'presenter':program.presenter, 'commentator':program.commentator, 'guest':program.guest})
|
const credits = createCredits({
|
||||||
|
director: program.director,
|
||||||
|
actor: program.actor,
|
||||||
|
writer: program.writer,
|
||||||
|
adapter: program.adapter,
|
||||||
|
producer: program.producer,
|
||||||
|
composer: program.composer,
|
||||||
|
editor: program.editor,
|
||||||
|
presenter: program.presenter,
|
||||||
|
commentator: program.commentator,
|
||||||
|
guest: program.guest
|
||||||
|
})
|
||||||
const icon = utils.escapeString(program.icon)
|
const icon = utils.escapeString(program.icon)
|
||||||
const sub_title = program.sub_title || ''
|
const sub_title = program.sub_title || ''
|
||||||
const url = program.url ? createURL(program.url, channel) : ''
|
const url = program.url ? createURL(program.url, channel) : ''
|
||||||
|
@ -261,7 +274,7 @@ utils.convertToXMLTV = function ({ channels, programs }) {
|
||||||
if (url.value.includes('http')) {
|
if (url.value.includes('http')) {
|
||||||
output += `<url${attr}>${url.value}</url>`
|
output += `<url${attr}>${url.value}</url>`
|
||||||
} else if (channel) {
|
} else if (channel) {
|
||||||
let chan = channels.find((c) => c.xmltv_id.localeCompare(channel) === 0)
|
let chan = channels.find(c => c.xmltv_id.localeCompare(channel) === 0)
|
||||||
if (chan && chan.site) {
|
if (chan && chan.site) {
|
||||||
output += `<url${attr}>https://${chan.site}${url.value}</url>`
|
output += `<url${attr}>https://${chan.site}${url.value}</url>`
|
||||||
}
|
}
|
||||||
|
@ -279,9 +292,9 @@ utils.convertToXMLTV = function ({ channels, programs }) {
|
||||||
img = { value: img }
|
img = { value: img }
|
||||||
}
|
}
|
||||||
|
|
||||||
const imageTypes = ['poster', 'backdrop', 'still', 'person', 'character'];
|
const imageTypes = ['poster', 'backdrop', 'still', 'person', 'character']
|
||||||
const imageSizes = ['1', '2', '3'];
|
const imageSizes = ['1', '2', '3']
|
||||||
const imageOrients = ['P', 'L'];
|
const imageOrients = ['P', 'L']
|
||||||
|
|
||||||
let attr = ''
|
let attr = ''
|
||||||
|
|
||||||
|
@ -304,7 +317,7 @@ utils.convertToXMLTV = function ({ channels, programs }) {
|
||||||
if (img.value.includes('http')) {
|
if (img.value.includes('http')) {
|
||||||
output += `<image${attr}>${img.value}</image>`
|
output += `<image${attr}>${img.value}</image>`
|
||||||
} else if (channel) {
|
} else if (channel) {
|
||||||
let chan = channels.find((c) => c.xmltv_id.localeCompare(channel) === 0)
|
let chan = channels.find(c => c.xmltv_id.localeCompare(channel) === 0)
|
||||||
if (chan && chan.site) {
|
if (chan && chan.site) {
|
||||||
output += `<image${attr}>https://${chan.site}${img.value}</image>`
|
output += `<image${attr}>https://${chan.site}${img.value}</image>`
|
||||||
}
|
}
|
||||||
|
@ -316,7 +329,7 @@ utils.convertToXMLTV = function ({ channels, programs }) {
|
||||||
|
|
||||||
function createCredits(obj) {
|
function createCredits(obj) {
|
||||||
let cast = Object.entries(obj)
|
let cast = Object.entries(obj)
|
||||||
.filter((x) => x[1])
|
.filter(x => x[1])
|
||||||
.map(([name, value]) => ({ name, value }))
|
.map(([name, value]) => ({ name, value }))
|
||||||
|
|
||||||
let output = ''
|
let output = ''
|
||||||
|
@ -343,8 +356,6 @@ utils.convertToXMLTV = function ({ channels, programs }) {
|
||||||
output += createImage(person.image)
|
output += createImage(person.image)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
output += `</${type.name}>`
|
output += `</${type.name}>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue