forked from iptv-org/epg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tvplus.com.tr.config.js
98 lines (85 loc) · 2.48 KB
/
tvplus.com.tr.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const axios = require('axios')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(utc)
dayjs.extend(customParseFormat)
module.exports = {
site: 'tvplus.com.tr',
days: 2,
url: 'https://izmottvsc23.tvplus.com.tr:33207/EPG/JSON/PlayBillList',
request: {
method: 'POST',
async headers() {
const response = await axios
.post('https://izmottvsc23.tvplus.com.tr:33207/EPG/JSON/Authenticate', {
terminaltype: 'WEBTV_WIDEVINE',
userType: '3',
timezone: 'UTC'
})
.catch(console.log)
const cookie = Array.isArray(response.headers['set-cookie'])
? response.headers['set-cookie'].join('; ')
: ''
return { cookie }
},
data({ date, channel }) {
return {
type: '2',
channelid: channel.site_id,
begintime: date.format('YYYYMMDDHHmmss'),
endtime: date.add(1, 'd').format('YYYYMMDDHHmmss')
}
}
},
parser: function ({ content }) {
let programs = []
const items = parseItems(content)
items.forEach(item => {
const start = parseStart(item)
const stop = parseStop(item)
programs.push({
title: item.name,
category: item.genres,
description: item.introduce,
icon: parseIcon(item),
start: start.toJSON(),
stop: stop.toJSON()
})
})
return programs
},
async channels() {
const cheerio = require('cheerio')
const channels = []
const data = await axios
.get(`https://tvplus.com.tr/canli-tv/yayin-akisi`)
.then(r => r.data)
.catch(console.log)
const $ = cheerio.load(data)
$('.channelListItem').each((i, el) => {
const name = $(el).find('.channelName').text()
const url = $(el).find('.channelLink').attr('href')
const [, site_id] = url.match(/\-\-(\d+)$/)
channels.push({
lang: 'tr',
name,
site_id
})
})
return channels
}
}
function parseIcon(item) {
return item.pictures && item.pictures.length ? item.pictures[0].href : null
}
function parseStart(item) {
return dayjs.utc(item.starttime, 'YYYYMMDDHHmmss')
}
function parseStop(item) {
return dayjs.utc(item.endtime, 'YYYYMMDDHHmmss')
}
function parseItems(content) {
const data = JSON.parse(content)
return data.playbilllist || []
}