mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Create programme-tv.vini.pf.config.js
This commit is contained in:
parent
18fc1b3101
commit
6bb2bf5a05
1 changed files with 94 additions and 0 deletions
94
sites/programme-tv.vini.pf/programme-tv.vini.pf.config.js
Normal file
94
sites/programme-tv.vini.pf/programme-tv.vini.pf.config.js
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const axios = require('axios')
|
||||||
|
|
||||||
|
const API = {
|
||||||
|
url: `https://programme-tv.vini.pf/programmesJSON`
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'programme-tv.vini.pf',
|
||||||
|
url: API.url,
|
||||||
|
request: {
|
||||||
|
method: 'POST',
|
||||||
|
timeout: 30000,
|
||||||
|
data({ date }) {
|
||||||
|
return {
|
||||||
|
dateDebut: `${date.subtract(10, 'h').format('YYYY-MM-DDTHH:mm:ss')}-10:00`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
logo({ channel }) {
|
||||||
|
return channel.logo
|
||||||
|
},
|
||||||
|
parser: async function ({ content, channel, date }) {
|
||||||
|
const programs = []
|
||||||
|
const items = parseItems(content, channel)
|
||||||
|
if (items.length) {
|
||||||
|
for (let hours of [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) {
|
||||||
|
const nextContent = await loadNextItems(date, hours)
|
||||||
|
const nextItems = parseItems(nextContent, channel)
|
||||||
|
for (let item of nextItems) {
|
||||||
|
if (!items.find(i => i.nidP === item.nidP)) {
|
||||||
|
items.push(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
items.forEach(item => {
|
||||||
|
programs.push({
|
||||||
|
title: item.titreP,
|
||||||
|
description: item.desc,
|
||||||
|
category: item.categorieP,
|
||||||
|
icon: item.srcP,
|
||||||
|
start: dayjs.unix(item.timestampDeb),
|
||||||
|
stop: dayjs.unix(item.timestampFin)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return programs
|
||||||
|
},
|
||||||
|
async channels({ country, lang }) {
|
||||||
|
const data = await axios
|
||||||
|
.post(`https://programme-tv.vini.pf/programmesJSON`)
|
||||||
|
.then(r => r.data)
|
||||||
|
.catch(console.log)
|
||||||
|
|
||||||
|
return data.programmes.map(item => {
|
||||||
|
const channelId = item.url.replace('/', '')
|
||||||
|
return {
|
||||||
|
lang: 'fr',
|
||||||
|
site_id: channelId,
|
||||||
|
name: channelId,
|
||||||
|
logo: item.src
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadNextItems(date, hours) {
|
||||||
|
date = date.add(hours, 'h')
|
||||||
|
|
||||||
|
return axios
|
||||||
|
.post(
|
||||||
|
API.url,
|
||||||
|
{
|
||||||
|
dateDebut: `${date.subtract(10, 'h').format('YYYY-MM-DDTHH:mm:ss')}-10:00`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
responseType: 'arraybuffer'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(res => res.data.toString())
|
||||||
|
.catch(console.log)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content, channel) {
|
||||||
|
if (!content) return []
|
||||||
|
const data = JSON.parse(content)
|
||||||
|
if (!data || !Array.isArray(data.programmes)) return []
|
||||||
|
const channelData = data.programmes.find(i => i.url === `/${channel.site_id}`)
|
||||||
|
if (!channelData) return []
|
||||||
|
|
||||||
|
return channelData.programmes || []
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue