-
-
Notifications
You must be signed in to change notification settings - Fork 233
/
tapdmv.com.config.js
65 lines (58 loc) · 1.55 KB
/
tapdmv.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
63
64
65
const axios = require('axios')
const dayjs = require('dayjs')
module.exports = {
site: 'tapdmv.com',
days: 2,
request: {
maxContentLength: 10485760 // 10 Mb
},
url({ channel, date }) {
return `https://epg.tapdmv.com/calendar/${
channel.site_id
}?%24limit=10000&%24sort%5BcreatedAt%5D=-1&start=${date.toJSON()}&end=${date
.add(1, 'd')
.toJSON()}`
},
parser: function ({ content, date }) {
let programs = []
const items = parseItems(content, date)
items.forEach(item => {
programs.push({
title: item.program.trim(),
description: item.description,
category: item.genre,
image: item.thumbnailImage,
start: parseStart(item),
stop: parseStop(item)
})
})
return programs
},
async channels() {
const items = await axios
.get('https://epg.tapdmv.com/calendar?$limit=10000&$sort[createdAt]=-1')
.then(r => r.data.data)
.catch(console.log)
return items.map(item => {
const [, name] = item.name.match(/epg-tapgo-([^.]+).json/)
return {
lang: 'en',
site_id: item.id,
name
}
})
}
}
function parseStart(item) {
return dayjs(item.startTime)
}
function parseStop(item) {
return dayjs(item.endTime)
}
function parseItems(content, date) {
if (!content) return []
const data = JSON.parse(content)
if (!Array.isArray(data)) return []
const d = date.format('YYYY-MM-DD')
return data.filter(i => i.startTime.includes(d))
}