mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 01:20:08 -04:00
Create delta.nl.config.js
This commit is contained in:
parent
a74f40b47c
commit
e8b135f71d
1 changed files with 60 additions and 0 deletions
60
sites/delta.nl/delta.nl.config.js
Normal file
60
sites/delta.nl/delta.nl.config.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
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] || []
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue