forked from iptv-org/epg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tv.lv.config.js
64 lines (55 loc) · 1.44 KB
/
tv.lv.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
53
54
55
56
57
58
59
60
61
62
63
64
const dayjs = require('dayjs')
module.exports = {
site: 'tv.lv',
days: 2,
url: function ({ date, channel }) {
return `https://www.tv.lv/programme/listing/none/${date.format(
'DD-MM-YYYY'
)}?filter=channel&subslug=${channel.site_id}`
},
parser: function ({ content }) {
const programs = []
const items = parseItems(content)
items.forEach(item => {
const start = parseStart(item)
const stop = parseStop(item)
programs.push({
title: item.title,
description: item.description_long,
category: item.categorystring,
icon: item.image,
start,
stop
})
})
return programs
},
async channels() {
const axios = require('axios')
const groups = await axios
.get('https://www.tv.lv/data/channels/lvall')
.then(r => r.data)
.catch(console.log)
let channels = []
groups.forEach(group => {
group.channels.forEach(item => {
channels.push({
lang: 'lv',
site_id: item.slug,
name: item.name
})
})
})
return channels
}
}
function parseStart(item) {
return item.start_unix ? dayjs.unix(item.start_unix) : null
}
function parseStop(item) {
return item.stop_unix ? dayjs.unix(item.stop_unix) : null
}
function parseItems(content) {
const data = JSON.parse(content)
return data.schedule.programme || []
}