mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
const axios = require('axios')
|
|
const dayjs = require('dayjs')
|
|
|
|
module.exports = {
|
|
site: 'delta.nl',
|
|
url: function ({ channel, date }) {
|
|
return `https://clientapi.tv.delta.nl/guide/channels/list?start=${date.unix()}&end=${date
|
|
.add(1, 'd')
|
|
.unix()}&includeDetails=true&channels=${channel.site_id}`
|
|
},
|
|
logo({ channel }) {
|
|
return channel.logo
|
|
},
|
|
parser: function ({ content, channel }) {
|
|
let programs = []
|
|
const items = parseItems(content, channel)
|
|
items.forEach(item => {
|
|
programs.push({
|
|
title: item.title,
|
|
icon: item.images.thumbnail.url,
|
|
start: parseStart(item).toJSON(),
|
|
stop: parseStop(item).toJSON()
|
|
})
|
|
})
|
|
|
|
return programs
|
|
},
|
|
async channels() {
|
|
const items = await axios
|
|
.get('https://clientapi.tv.delta.nl/channels/list')
|
|
.then(r => r.data)
|
|
.catch(console.log)
|
|
|
|
return items
|
|
.filter(i => i.type === 'TV')
|
|
.map(item => {
|
|
return {
|
|
lang: 'nl',
|
|
site_id: item['ID'],
|
|
name: item.name,
|
|
logo: item.images.logo
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
function parseStart(item) {
|
|
return dayjs.unix(item.start)
|
|
}
|
|
|
|
function parseStop(item) {
|
|
return dayjs.unix(item.end)
|
|
}
|
|
|
|
function parseItems(content, channel) {
|
|
const data = JSON.parse(content)
|
|
if (!data) return []
|
|
|
|
return data[channel.site_id] || []
|
|
}
|