forked from iptv-org/epg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frikanalen.no.config.js
52 lines (43 loc) · 1.06 KB
/
frikanalen.no.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
46
47
48
49
50
51
52
const dayjs = require('dayjs')
module.exports = {
site: 'frikanalen.no',
days: 2,
url({ date }) {
return `https://frikanalen.no/api/scheduleitems/?date=${date.format(
'YYYY-MM-DD'
)}&format=json&limit=100`
},
parser({ content }) {
let programs = []
const items = parseItems(content)
items.forEach(item => {
programs.push({
title: parseTitle(item),
category: parseCategory(item),
description: parseDescription(item),
start: parseStart(item),
stop: parseStop(item)
})
})
return programs
}
}
function parseTitle(item) {
return item.video.name
}
function parseCategory(item) {
return item.video.categories
}
function parseDescription(item) {
return item.video.header
}
function parseStart(item) {
return dayjs(item.starttime)
}
function parseStop(item) {
return dayjs(item.endtime)
}
function parseItems(content) {
const data = JSON.parse(content)
return data && Array.isArray(data.results) ? data.results : []
}