mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create tv.nu.config.js
This commit is contained in:
parent
c73054f785
commit
a1c170072e
1 changed files with 45 additions and 0 deletions
45
sites/tv.nu/tv.nu.config.js
Normal file
45
sites/tv.nu/tv.nu.config.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
const dayjs = require('dayjs')
|
||||
|
||||
module.exports = {
|
||||
site: 'tv.nu',
|
||||
url: function ({ channel, date }) {
|
||||
return `https://web-api.tv.nu/channels/${channel.site_id}/schedule?date=${date.format(
|
||||
'YYYY-MM-DD'
|
||||
)}&fullDay=true`
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
icon: item.imageLandscape,
|
||||
category: item.genres,
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
if (!item.broadcast || !item.broadcast.startTime) return null
|
||||
|
||||
return dayjs(item.broadcast.startTime)
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
if (!item.broadcast || !item.broadcast.endTime) return null
|
||||
|
||||
return dayjs(item.broadcast.endTime)
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !data.data || !Array.isArray(data.data.broadcasts)) return []
|
||||
|
||||
return data.data.broadcasts
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue