mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create pbsguam.org.config.js
This commit is contained in:
parent
26ef050ea3
commit
39fc20e8db
1 changed files with 38 additions and 0 deletions
38
sites/pbsguam.org/pbsguam.org.config.js
Normal file
38
sites/pbsguam.org/pbsguam.org.config.js
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const isBetween = require('dayjs/plugin/isBetween')
|
||||||
|
|
||||||
|
dayjs.extend(isBetween)
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'pbsguam.org',
|
||||||
|
url: 'https://pbsguam.org/calendar/',
|
||||||
|
logo({ channel }) {
|
||||||
|
return channel.logo
|
||||||
|
},
|
||||||
|
parser: function ({ content, date }) {
|
||||||
|
let programs = []
|
||||||
|
const items = parseItems(content, date)
|
||||||
|
items.forEach(item => {
|
||||||
|
programs.push({
|
||||||
|
title: item.title,
|
||||||
|
start: dayjs(item.start),
|
||||||
|
stop: dayjs(item.end)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return programs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content, date) {
|
||||||
|
const [_, json] = content.match(/EventsSchedule_1 = (.*);/i) || [null, null]
|
||||||
|
if (!json) return []
|
||||||
|
const data = JSON.parse(json)
|
||||||
|
if (!data || !Array.isArray(data.feed)) return []
|
||||||
|
|
||||||
|
return data.feed.filter(
|
||||||
|
i =>
|
||||||
|
dayjs(i.start).isBetween(date, date.add(1, 'd')) ||
|
||||||
|
dayjs(i.end).isBetween(date, date.add(1, 'd'))
|
||||||
|
)
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue