forked from iptv-org/epg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tv.yettel.hu.config.js
69 lines (59 loc) · 1.62 KB
/
tv.yettel.hu.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
const axios = require('axios')
const dayjs = require('dayjs')
module.exports = {
site: 'tv.yettel.hu',
days: 2,
url: function ({ channel, date }) {
return `https://dev.mytvback.com/api/19/default/hu-HU/schedules?livechannelpids=${
channel.site_id
}&includeImages=cover%3A100%3A144&filterAvailability=false&startTime=${date.unix()}&endTime=${date
.add(1, 'd')
.unix()}`
},
parser: function ({ content }) {
let programs = []
const items = parseItems(content)
items.forEach(item => {
programs.push({
title: item.Title,
description: item.ShortDescription,
icon: parseIcon(item),
start: parseStart(item),
stop: parseStop(item)
})
})
return programs
},
async channels() {
const data = await axios
.get('https://dev.mytvback.com/api/19/default/hu-HU/content/CHA_LIVE_MYTV2_HU/children')
.then(r => r.data)
.catch(console.log)
const channels = []
for (let item of data.Content.List) {
channels.push({
lang: 'hu',
site_id: item.Pid,
name: item.CallLetter
})
}
return channels
}
}
function parseIcon(item) {
if (Array.isArray(item.Images.Cover) && item.Images.Cover.length) {
return item.Images.Cover[0].Url
}
return null
}
function parseStart(item) {
return dayjs.unix(item.Start)
}
function parseStop(item) {
return dayjs.unix(item.End)
}
function parseItems(content) {
const data = JSON.parse(content)
if (!data || !Array.isArray(data.Content)) return []
return data.Content
}