epg/sites/telkussa.fi.config.js
2021-04-25 00:37:02 +03:00

35 lines
984 B
JavaScript

const dayjs = require('dayjs')
module.exports = {
lang: 'fi',
site: 'telkussa.fi',
channels: 'telkussa.fi.channels.xml',
output: '.gh-pages/guides/telkussa.fi.guide.xml',
url: function ({ date, channel }) {
return `https://telkussa.fi/API/Channel/${channel.site_id}/${date.format('YYYYMMDD')}`
},
logo: function ({ channel }) {
return `https://telkussa.fi/images/chan${channel.site_id}@3x.png`
},
parser: function ({ content, date, channel }) {
const programs = []
const items = JSON.parse(content)
if (!items.length) return programs
items.forEach(item => {
if (item.name && item.start && item.stop) {
const start = dayjs.unix(parseInt(item.start) * 60)
const stop = dayjs.unix(parseInt(item.stop) * 60)
programs.push({
title: item.name,
description: item.description,
start: start.toString(),
stop: stop.toString()
})
}
})
return programs
}
}