forked from iptv-org/epg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maxtvgo.mk.config.js
72 lines (62 loc) · 1.92 KB
/
maxtvgo.mk.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
65
66
67
68
69
70
71
72
const axios = require('axios')
const dayjs = require('dayjs')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat)
module.exports = {
site: 'maxtvgo.mk',
days: 2,
url: function ({ channel, date }) {
return `https://prd-static-mkt.spectar.tv/rev-1636968171/client_api.php/epg/list/instance_id/1/language/mk/channel_id/${
channel.site_id
}/start/${date.format('YYYYMMDDHHmmss')}/stop/${date
.add(1, 'd')
.format('YYYYMMDDHHmmss')}/include_current/true/format/json`
},
parser: function ({ content }) {
let programs = []
const items = parseItems(content)
items.forEach(item => {
programs.push({
title: item.title,
category: item.category,
description: parseDescription(item),
icon: parseIcon(item),
start: parseStart(item),
stop: parseStop(item)
})
})
return programs
},
async channels() {
const channels = await axios
.get(
'https://prd-static-mkt.spectar.tv/rev-1636968171/client_api.php/channel/all/application_id/deep_blue/device_configuration/2/instance_id/1/language/mk/http_proto/https/format/json'
)
.then(r => r.data)
.catch(console.log)
return channels.map(item => {
return {
lang: 'mk',
site_id: item.id,
name: item.name
}
})
}
}
function parseStart(item) {
return dayjs(item['@attributes'].start, 'YYYYMMDDHHmmss ZZ')
}
function parseStop(item) {
return dayjs(item['@attributes'].stop, 'YYYYMMDDHHmmss ZZ')
}
function parseDescription(item) {
return typeof item.desc === 'string' ? item.desc : null
}
function parseIcon(item) {
return item.icon['@attributes'].src
}
function parseItems(content) {
const data = JSON.parse(content)
if (!data || !Array.isArray(data.programme)) return []
return data.programme
}