Files
epg/sites/vidio.com/vidio.com.config.js
T

89 lines
2.4 KiB
JavaScript
Raw Normal View History

2025-07-01 18:47:25 +00:00
const axios = require('axios')
2024-11-23 22:51:24 +07:00
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const timezone = require('dayjs/plugin/timezone')
const customParseFormat = require('dayjs/plugin/customParseFormat')
2025-07-01 18:47:25 +00:00
const crypto = require('crypto')
2024-11-23 22:51:24 +07:00
dayjs.extend(utc)
dayjs.extend(timezone)
dayjs.extend(customParseFormat)
2025-07-01 18:47:25 +00:00
const WEB_CLIENT_SECRET = Buffer.from('dPr0QImQ7bc5o9LMntNba2DOsSbZcjUh')
const WEB_CLIENT_IV = Buffer.from('C8RWsrtFsoeyCyPt')
2023-10-15 14:08:23 +03:00
module.exports = {
site: 'vidio.com',
days: 2,
2025-07-01 18:47:25 +00:00
url({ date, channel }) {
return `https://api.vidio.com/livestreamings/${channel.site_id}/schedules?filter[date]=${date.format('YYYY-MM-DD')}`
2023-10-15 14:08:23 +03:00
},
2025-07-01 18:47:25 +00:00
request: {
async headers() {
const session = await loadSessionDetails()
if (!session || !session.api_key) return null
var cipher = crypto.createCipheriv('aes-256-cbc', WEB_CLIENT_SECRET, WEB_CLIENT_IV)
return {
'X-API-Key': cipher.update(session.api_key, 'utf8', 'base64') + cipher.final('base64'),
'X-Secure-Level': 2
2023-10-15 14:08:23 +03:00
}
2025-07-01 18:47:25 +00:00
}
},
parser({ content }) {
const programs = []
const json = JSON.parse(content)
if (Array.isArray(json?.data)) {
for (const program of json.data) {
programs.push({
title: program.attributes.title,
description: program.attributes.description,
start: dayjs(program.attributes.start_time),
stop: dayjs(program.attributes.end_time),
image: program.attributes.image_landscape_url
})
2023-10-15 14:08:23 +03:00
}
2025-07-01 18:47:25 +00:00
}
2023-10-15 14:08:23 +03:00
return programs
2023-11-05 23:24:47 +07:00
},
async channels() {
2025-07-01 18:47:25 +00:00
const channels = []
const json = await axios
.get(
'https://api.vidio.com/livestreamings?stream_type=tv_stream',
{
headers: await this.request.headers()
}
)
2023-11-05 23:24:47 +07:00
.then(response => response.data)
.catch(console.error)
2025-07-01 18:47:25 +00:00
if (Array.isArray(json?.data)) {
for (const channel of json.data) {
channels.push({
2024-11-23 22:51:24 +07:00
lang: 'id',
2025-07-01 18:47:25 +00:00
site_id: channel.id,
name: channel.attributes.title
2024-11-23 22:51:24 +07:00
})
}
2025-07-01 18:47:25 +00:00
}
2023-11-05 23:24:47 +07:00
return channels
}
2023-10-15 14:08:23 +03:00
}
2025-07-01 18:47:25 +00:00
function loadSessionDetails() {
return axios
.post(
'https://www.vidio.com/auth',
{},
{
headers: {
'Content-Type': 'application/json'
}
}
)
.then(r => r.data)
.catch(console.log)
}