forked from iptv-org/epg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
telkussa.fi.config.js
45 lines (40 loc) · 1.08 KB
/
telkussa.fi.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const dayjs = require('dayjs')
module.exports = {
site: 'telkussa.fi',
days: 2,
url: function ({ date, channel }) {
return `https://telkussa.fi/API/Channel/${channel.site_id}/${date.format('YYYYMMDD')}`
},
parser: function ({ content }) {
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,
stop
})
}
})
return programs
},
async channels({ lang }) {
const axios = require('axios')
const data = await axios
.get(`https://telkussa.fi/API/Channels`)
.then(r => r.data)
.catch(console.log)
return data.map(item => {
return {
lang: 'fi',
site_id: item.id,
name: item.name
}
})
}
}