mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Update rtb.gov.bn.config.js
This commit is contained in:
parent
48e0737661
commit
8d496af7c6
1 changed files with 12 additions and 10 deletions
|
@ -24,21 +24,23 @@ module.exports = {
|
||||||
return channel.logo
|
return channel.logo
|
||||||
},
|
},
|
||||||
parser: async function ({ buffer, date }) {
|
parser: async function ({ buffer, date }) {
|
||||||
let PM = false
|
|
||||||
let programs = []
|
let programs = []
|
||||||
const items = await parseItems(buffer)
|
const items = await parseItems(buffer)
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
|
const prev = programs[programs.length - 1]
|
||||||
let start = parseStart(item, date)
|
let start = parseStart(item, date)
|
||||||
if (start.hour() > 11) PM = true
|
if (prev) {
|
||||||
if (start.hour() < 12 && PM) start = start.add(1, 'd')
|
if (start.isBefore(prev.start)) {
|
||||||
const stop = start.add(1, 'h')
|
start = start.add(1, 'd')
|
||||||
if (programs.length) {
|
date = date.add(1, 'd')
|
||||||
programs[programs.length - 1].stop = start.toJSON()
|
|
||||||
}
|
}
|
||||||
|
prev.stop = start
|
||||||
|
}
|
||||||
|
const stop = start.add(1, 'h')
|
||||||
programs.push({
|
programs.push({
|
||||||
title: item.title,
|
title: item.title,
|
||||||
start: start.toJSON(),
|
start,
|
||||||
stop: stop.toJSON()
|
stop
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -47,9 +49,9 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStart(item, date) {
|
function parseStart(item, date) {
|
||||||
const time = `${date.format('YYYY-MM-DD')} ${item.time}`
|
const dateString = `${date.format('YYYY-MM-DD')} ${item.time}`
|
||||||
|
|
||||||
return dayjs.tz(time, 'YYYY-MM-DD HH:mm', 'Asia/Brunei')
|
return dayjs.tz(dateString, 'YYYY-MM-DD HH:mm', 'Asia/Brunei')
|
||||||
}
|
}
|
||||||
|
|
||||||
async function parseItems(buffer) {
|
async function parseItems(buffer) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue