forked from iptv-org/epg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zap.co.ao.config.js
48 lines (43 loc) · 1.19 KB
/
zap.co.ao.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
const { DateTime } = require('luxon')
const axios = require('axios')
module.exports = {
site: 'zap.co.ao',
days: 2,
url: function ({ date, channel }) {
return `https://zapon.zapsi.net/ao/m/api/epg/events?date=${date.format('YYYYMMDD')}&channel=${
channel.site_id
}`
},
parser: function ({ content }) {
const programs = []
const items = parseItems(content)
if (!items.length) return programs
items.forEach(item => {
programs.push({
title: item.programName,
description: item.programDescription,
category: item.categoryName,
start: DateTime.fromSeconds(item.utcBeginDate).toUTC(),
stop: DateTime.fromSeconds(item.utcEndDate).toUTC()
})
})
return programs
},
async channels() {
const channels = await axios
.get('https://zapon.zapsi.net/ao/m/api/epg/channels')
.then(r => r.data.data)
.catch(console.log)
return channels.map(item => {
return {
lang: 'pt',
site_id: item.id,
name: item.name
}
})
}
}
function parseItems(content) {
const data = JSON.parse(content)
return data.data || []
}