-
-
Notifications
You must be signed in to change notification settings - Fork 239
/
wavve.com.config.js
62 lines (53 loc) · 1.62 KB
/
wavve.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
51
52
53
54
55
56
57
58
59
60
61
62
const axios = require('axios')
const { DateTime } = require('luxon')
module.exports = {
site: 'wavve.com',
days: 2,
url: function ({ channel, date }) {
return `https://apis.pooq.co.kr/live/epgs/channels/${
channel.site_id
}?startdatetime=${date.format('YYYY-MM-DD')}%2000%3A00&enddatetime=${date
.add(1, 'd')
.format('YYYY-MM-DD')}%2000%3A00&apikey=E5F3E0D30947AA5440556471321BB6D9&limit=500`
},
parser: function ({ content }) {
let programs = []
const items = parseItems(content)
items.forEach(item => {
programs.push({
title: item.title,
start: parseStart(item),
stop: parseStop(item)
})
})
return programs
},
async channels() {
const channels = []
const data = await axios
.get(
'https://apis.pooq.co.kr/live/epgs?enddatetime=2022-04-17%2019%3A00&genre=all&limit=500&startdatetime=2022-04-17%2016%3A00&apikey=E5F3E0D30947AA5440556471321BB6D9'
)
.then(r => r.data)
.catch(console.log)
data.list.forEach(i => {
channels.push({
name: i.channelname,
site_id: i.channelid,
lang: 'ko'
})
})
return channels
}
}
function parseStart(item) {
return DateTime.fromFormat(item.starttime, 'yyyy-MM-dd HH:mm', { zone: 'Asia/Seoul' }).toUTC()
}
function parseStop(item) {
return DateTime.fromFormat(item.endtime, 'yyyy-MM-dd HH:mm', { zone: 'Asia/Seoul' }).toUTC()
}
function parseItems(content) {
const data = JSON.parse(content)
if (!data || !Array.isArray(data.list)) return []
return data.list
}