mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 17:10:07 -04:00
Create canalplus-reunion.com.config.js
This commit is contained in:
parent
f91ecc91dd
commit
3a9c49461d
1 changed files with 47 additions and 0 deletions
47
sites/canalplus-reunion.com/canalplus-reunion.com.config.js
Normal file
47
sites/canalplus-reunion.com/canalplus-reunion.com.config.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
const dayjs = require('dayjs')
|
||||
|
||||
module.exports = {
|
||||
site: 'canalplus-reunion.com',
|
||||
url: function ({ channel, date }) {
|
||||
const diff = date.diff(dayjs().startOf('d'), 'd')
|
||||
|
||||
return `https://service.canal-overseas.com/ott-frontend/vector/63001/channel/${channel.site_id}/events?filter.day=${diff}`
|
||||
},
|
||||
logo({ channel }) {
|
||||
return channel.logo
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
if (item.title === 'Fin des programmes') return
|
||||
programs.push({
|
||||
title: item.title,
|
||||
icon: item.URLImageDefault,
|
||||
start: parseStart(item).toJSON(),
|
||||
stop: parseStop(item).toJSON()
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.unix(item.startTime)
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.unix(item.endTime)
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !data.timeSlices) return []
|
||||
const items = data.timeSlices.reduce((acc, curr) => {
|
||||
acc = acc.concat(curr.contents)
|
||||
return acc
|
||||
}, [])
|
||||
|
||||
return items
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue