forked from iptv-org/epg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtvtv.us.config.js
38 lines (33 loc) · 968 Bytes
/
tvtv.us.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
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
module.exports = {
site: 'tvtv.us',
delay: 1500, // 1500 ms (otherwise the server returns error 429: https://github.com/iptv-org/epg/issues/2176)
days: 2,
url: function ({ date, channel }) {
return `https://www.tvtv.us/api/v1/lineup/USA-NY71652-X/grid/${date.toJSON()}/${date
.add(1, 'd')
.toJSON()}/${channel.site_id}`
},
parser: function ({ content }) {
let programs = []
const items = parseItems(content)
items.forEach(item => {
const start = dayjs.utc(item.startTime)
const stop = start.add(item.runTime, 'm')
programs.push({
title: item.title,
description: item.subtitle,
start,
stop
})
})
return programs
}
}
function parseItems(content) {
const json = JSON.parse(content)
if (!json.length) return []
return json[0]
}