mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create tv2go.t-2.net.config.js
This commit is contained in:
parent
b6356e3789
commit
3e783359ff
1 changed files with 129 additions and 0 deletions
129
sites/tv2go.t-2.net/tv2go.t-2.net.config.js
Normal file
129
sites/tv2go.t-2.net/tv2go.t-2.net.config.js
Normal file
|
@ -0,0 +1,129 @@
|
|||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const md5 = require('./jquery.md5')
|
||||
|
||||
const API = {
|
||||
locale: 'sl-SI',
|
||||
version: '9.4',
|
||||
format: 'json',
|
||||
uuid: '464830403846070',
|
||||
token: '6dace810-55d5-11e3-949a-0800200c9a66'
|
||||
}
|
||||
|
||||
const config = {
|
||||
site: 'tv2go.t-2.net',
|
||||
url({ date, channel }) {
|
||||
const data = config.request.data({ date, channel })
|
||||
const endpoint = 'client/tv/getEpg'
|
||||
const hash = generateHash(data, endpoint)
|
||||
|
||||
return `https://tv2go.t-2.net/Catherine/api/${API.version}/${API.format}/${API.uuid}/${hash}/${endpoint}`
|
||||
},
|
||||
request: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
data({ date, channel }) {
|
||||
const channelId = parseInt(channel.site_id)
|
||||
|
||||
return {
|
||||
locale: API.locale,
|
||||
channelId: [channelId],
|
||||
startTime: date.valueOf(),
|
||||
endTime: date.add(1, 'd').valueOf(),
|
||||
imageInfo: [{ height: 500, width: 1100 }],
|
||||
includeBookmarks: false,
|
||||
includeShow: true
|
||||
}
|
||||
}
|
||||
},
|
||||
logo({ channel }) {
|
||||
return channel.logo
|
||||
},
|
||||
parser({ content }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.name,
|
||||
category: parseCategory(item),
|
||||
description: parseDescription(item),
|
||||
icon: parseIcon(item),
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const data = {
|
||||
locale: API.locale,
|
||||
type: 'TV',
|
||||
imageInfo: [{ type: 'DARK', height: 70, width: 98 }]
|
||||
}
|
||||
const endpoint = 'client/channels/list'
|
||||
const hash = generateHash(data, endpoint)
|
||||
const response = await axios
|
||||
.post(
|
||||
`https://tv2go.t-2.net/Catherine/api/${API.version}/${API.format}/${API.uuid}/${hash}/${endpoint}`,
|
||||
data,
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
)
|
||||
.catch(console.log)
|
||||
|
||||
return response.data.channels.map(item => {
|
||||
return {
|
||||
lang: 'sl',
|
||||
site_id: item.id,
|
||||
name: item.name,
|
||||
logo: item.images[0] ? `https://tv2go.t-2.net${item.images[0].url}` : null
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs(parseInt(item.startTimestamp))
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs(parseInt(item.endTimestamp))
|
||||
}
|
||||
|
||||
function parseIcon(item) {
|
||||
return item.images && item.images[0] ? `https://tv2go.t-2.net${item.images[0].url}` : null
|
||||
}
|
||||
|
||||
function parseCategory(item) {
|
||||
return item.show && Array.isArray(item.show.genres) ? item.show.genres.map(c => c.name) : []
|
||||
}
|
||||
|
||||
function parseDescription(item) {
|
||||
return item.show ? item.show.shortDescription : null
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
let data
|
||||
try {
|
||||
data = JSON.parse(content)
|
||||
} catch (e) {
|
||||
return []
|
||||
}
|
||||
if (!data || !Array.isArray(data.entries)) return []
|
||||
|
||||
return data.entries
|
||||
}
|
||||
|
||||
function generateHash(data, endpoint) {
|
||||
const salt = `${API.token}${API.version}${API.format}${API.uuid}`
|
||||
|
||||
return md5(salt + endpoint + JSON.stringify(data))
|
||||
}
|
||||
|
||||
module.exports = config
|
Loading…
Add table
Add a link
Reference in a new issue