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

64 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-11-18 15:20:16 +03:00
const axios = require('axios')
const dayjs = require('dayjs')
module.exports = {
site: 'allente.se',
2023-01-10 12:40:01 +03:00
days: 2,
2021-11-18 15:20:16 +03:00
url({ date, channel }) {
const [country] = channel.site_id.split('#')
return `https://cs-vcb.allente.${country}/epg/events?date=${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,
icon: item.details.image,
2022-08-23 20:23:49 +01:00
season: parseSeason(item),
episode: parseEpisode(item),
2021-11-18 15:20:16 +03:00
start,
stop
})
})
return programs
},
async channels({ country, lang }) {
const data = await axios
.get(`https://cs-vcb.allente.${country}/epg/events?date=2021-11-17`)
.then(r => r.data)
.catch(console.log)
return data.channels.map(item => {
return {
lang,
site_id: `${country}#${item.id}`,
2022-02-01 04:04:51 +03:00
name: item.name
2021-11-18 15:20:16 +03:00
}
})
}
}
function parseItems(content, channel) {
const [_, channelId] = channel.site_id.split('#')
const data = JSON.parse(content)
if (!data || !Array.isArray(data.channels)) return []
const channelData = data.channels.find(i => i.id === channelId)
return channelData && Array.isArray(channelData.events) ? channelData.events : []
}
2022-08-23 20:23:49 +01:00
function parseSeason(item) {
2022-12-29 23:50:36 +03:00
return item.details.season || null
2022-08-23 20:23:49 +01:00
}
function parseEpisode(item) {
2022-12-29 23:50:36 +03:00
return item.details.episode || null
}