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

66 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-10-15 14:08:23 +03:00
const dayjs = require('dayjs')
module.exports = {
site: 'allente.se',
days: 2,
2023-12-02 18:21:08 +03:00
request: {
cache: {
ttl: 60 * 60 * 1000 // 1 hour
}
},
url({ date }) {
return `https://cs-vcb.allente.se/epg/events?date=${date.format('YYYY-MM-DD')}`
2023-10-15 14:08:23 +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,
2024-06-24 16:49:35 +03:00
image: item.details.image,
2023-10-15 14:08:23 +03:00
season: parseSeason(item),
episode: parseEpisode(item),
start,
stop
})
})
return programs
},
2023-12-02 18:21:08 +03:00
async channels() {
2023-11-21 14:55:28 +03:00
const axios = require('axios')
2023-10-15 14:08:23 +03:00
const data = await axios
2023-12-02 18:21:08 +03:00
.get(`https://cs-vcb.allente.se/epg/events?date=${dayjs().format('YYYY-MM-DD')}`)
2023-10-15 14:08:23 +03:00
.then(r => r.data)
.catch(console.log)
return data.channels.map(item => {
return {
2023-12-02 18:21:08 +03:00
lang: 'sv',
site_id: item.id,
2023-10-15 14:08:23 +03:00
name: item.name
}
})
}
}
function parseItems(content, channel) {
const data = JSON.parse(content)
if (!data || !Array.isArray(data.channels)) return []
2023-12-02 18:21:08 +03:00
const channelData = data.channels.find(i => i.id === channel.site_id)
2023-10-15 14:08:23 +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
}