Files
epg/sites/allente.no/allente.no.config.js

69 lines
1.8 KiB
JavaScript
Raw Normal View History

2025-07-31 22:29:01 +03:00
const dayjs = require('dayjs')
module.exports = {
site: 'allente.no',
days: 2,
request: {
cache: {
ttl: 60 * 60 * 1000 // 1 hour
}
},
2025-08-17 16:11:44 +02:00
url({ channel, date }) {
const country = channel.site_id.split('#')[0]
return `https://cs-vcb.allente.${country}/epg/events?date=${date.format('YYYY-MM-DD')}`
2025-07-31 22:29:01 +03:00
},
parser({ content, channel }) {
let programs = []
const items = parseItems(content, channel)
items.forEach(item => {
if (!item.details) return
const start = dayjs(item.time)
const stop = start.add(item.details.duration, 'm')
programs.push({
title: item.title,
category: item.details.categories,
description: item.details.description,
image: item.details.image,
season: parseSeason(item),
episode: parseEpisode(item),
start,
stop
})
})
return programs
},
2025-08-17 18:37:19 +02:00
async channels({ country }) {
2025-07-31 22:29:01 +03:00
const axios = require('axios')
2025-08-17 16:11:44 +02:00
const date = dayjs().format('YYYY-MM-DD')
2025-07-31 22:29:01 +03:00
2025-08-17 16:11:44 +02:00
const res = await axios.get(`https://cs-vcb.allente.${country}/epg/events?date=${date}`)
const data = res.data
if (!data || !Array.isArray(data.channels)) return []
2025-08-17 16:12:18 +02:00
const lang = country === 'dk' ? 'da' : country
2025-08-17 16:11:44 +02:00
return data.channels.map(item => ({
2025-08-17 16:12:18 +02:00
lang: lang,
2025-08-17 16:11:44 +02:00
site_id: `${country}#${item.id}`,
name: item.name
}))
2025-07-31 22:29:01 +03:00
}
}
function parseItems(content, channel) {
const data = JSON.parse(content)
if (!data || !Array.isArray(data.channels)) return []
2025-08-17 16:11:44 +02:00
const channelId = (channel.site_id || '').split('#')[1] || channel.site_id
const channelData = data.channels.find(i => i.id === channelId)
2025-07-31 22:29:01 +03:00
return channelData && Array.isArray(channelData.events) ? channelData.events : []
}
function parseSeason(item) {
return item.details.season || null
}
function parseEpisode(item) {
return item.details.episode || null
}