Update allente sites.

Signed-off-by: Toha <tohenk@yahoo.com>
This commit is contained in:
Toha
2026-07-04 19:32:45 +07:00
parent 41a54452e8
commit f59a46bb00
26 changed files with 257889 additions and 421 deletions
+49 -49
View File
@@ -1,68 +1,68 @@
const dayjs = require('dayjs')
const eventIds = []
module.exports = {
site: 'allente.no',
days: 2,
request: {
cache: {
ttl: 60 * 60 * 1000 // 1 hour
ttl: 24 * 60 * 60 * 1000 // 1 day
}
},
url({ channel, date }) {
const country = channel.site_id.split('#')[0]
return `https://cs-vcb.allente.${country}/epg/events?date=${date.format('YYYY-MM-DD')}`
url({ date }) {
return `https://www.allente.no/api/epg/refetch-epg-data?Start=${date.format('YYYY-MM-DD')}`
},
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
})
})
const programs = []
if (typeof content === 'string' || Buffer.isBuffer(content)) {
content = JSON.parse(content)
}
if (Array.isArray(content?.channels)) {
content.channels
.filter(item => item.id === channel.site_id)
.forEach(item => {
if (Array.isArray(item.programs)) {
item.programs
// make program unique across days
.filter(event => !eventIds.includes(event.id))
.forEach(event => {
eventIds.push(event.id)
programs.push({
title: event.title,
description: event.shortDescription,
category: event.genres,
image: event.splashImageUri,
season: event.seasonNumber ? event.seasonNumber : null,
episode: event.episodeNumber ? event.episodeNumber : null,
year: event.releaseYear ? event.releaseYear.toString() : null,
start: dayjs(event.eventStart),
stop: dayjs(event.eventEnd)
})
})
}
})
}
return programs
},
async channels({ country }) {
async channels() {
const channels = []
const axios = require('axios')
const date = dayjs().format('YYYY-MM-DD')
const res = await axios.get(`https://www.allente.no/api/epg/refetch-epg-data?Start=${dayjs().format('YYYY-MM-DD')}`)
.then(res => res.data)
.catch(console.error)
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 []
if (Array.isArray(res.channels)) {
channels.push(...res.channels
.map(item => ({
lang: 'no',
site_id: item.id,
name: item.name
})
))
}
const lang = country === 'dk' ? 'da' : country
return data.channels.map(item => ({
lang: lang,
site_id: `${country}#${item.id}`,
name: item.name
}))
return channels
}
}
function parseItems(content, channel) {
const data = JSON.parse(content)
if (!data || !Array.isArray(data.channels)) return []
const channelId = (channel.site_id || '').split('#')[1] || channel.site_id
const channelData = data.channels.find(i => i.id === channelId)
return channelData && Array.isArray(channelData.events) ? channelData.events : []
}
function parseSeason(item) {
return item.details.season || null
}
function parseEpisode(item) {
return item.details.episode || null
}