forked from iptv-org/epg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sky.de.config.js
78 lines (72 loc) · 1.91 KB
/
sky.de.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
73
74
75
76
77
78
const dayjs = require('dayjs')
module.exports = {
site: 'sky.de',
days: 2,
url: 'https://www.sky.de/sgtvg/service/getBroadcastsForGrid',
request: {
method: 'POST',
headers: {
'accept-language': 'en-GB',
'accept-encoding': 'gzip, deflate, br',
accept: 'application/json'
},
data: function ({ channel, date }) {
return {
cil: [channel.site_id],
d: date.valueOf()
}
}
},
parser: function ({ content, channel }) {
const programs = []
const items = parseItems(content, channel)
items.forEach(item => {
programs.push({
title: item.et,
description: item.epit,
category: item.ec,
start: dayjs(item.bsdt),
stop: dayjs(item.bedt),
season: item.sn,
episode: item.en,
icon: item.pu ? `http://sky.de${item.pu}` : null
})
})
return programs
},
async channels() {
const axios = require('axios')
const data = await axios
.post(
'https://www.sky.de/sgtvg/service/getChannelList',
{ dom: 'de', s: 0, feed: 1 },
{
headers: {
'Content-Type': 'application/json',
Referer: 'https://www.sky.de/tvguide-7599',
'X-Requested-With': 'XMLHttpRequest'
}
}
)
.then(r => r.data)
.catch(console.log)
let channels = []
data.cl.forEach(item => {
channels.push({
lang: 'de',
name: item.cn,
site_id: item.ci
})
})
return channels
}
}
function parseContent(content, channel) {
const json = JSON.parse(content)
if (!Array.isArray(json.cl)) return null
return json.cl.find(i => i.ci == channel.site_id)
}
function parseItems(content, channel) {
const data = parseContent(content, channel)
return data && Array.isArray(data.el) ? data.el : []
}