forked from iptv-org/epg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tvarenasport.com.config.js
50 lines (44 loc) · 1.22 KB
/
tvarenasport.com.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
const axios = require('axios')
const dayjs = require('dayjs')
module.exports = {
site: 'tvarenasport.com',
days: 2,
url: function ({ date }) {
return `https://www.tvarenasport.com/api/schedule?date=${date.format('DD-MM-YYYY')}`
},
parser: function ({ content, channel }) {
let programs = []
const items = parseItems(content, channel)
items.forEach(item => {
programs.push({
title: item.title.trim(),
category: item.league,
description: item.sport.trim(),
start: dayjs(item.start),
stop: dayjs(item.end)
})
})
return programs
},
async channels() {
const data = await axios
.get('https://www.tvarenasport.com/api/schedule')
.then(r => r.data)
.catch(console.log)
const channels = []
for (let id in data.channels) {
const item = data.channels[id]
channels.push({
lang: 'sr',
site_id: id,
name: item.name
})
}
return channels
}
}
function parseItems(content, channel) {
const data = JSON.parse(content)
if (!data || !Array.isArray(data.items)) return []
return data.items.filter(i => i.group === channel.site_id)
}