From 9f79043e18cd97cea78fc7440656a8c40cf72927 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 24 Nov 2021 21:52:04 +0300 Subject: [PATCH] Update dstv.com.config.js --- sites/dstv.com/dstv.com.config.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/sites/dstv.com/dstv.com.config.js b/sites/dstv.com/dstv.com.config.js index b0eb0745..bf5558d1 100644 --- a/sites/dstv.com/dstv.com.config.js +++ b/sites/dstv.com/dstv.com.config.js @@ -19,24 +19,26 @@ module.exports = { return channel.logo }, parser({ content, date, channel }) { - let PM = false const programs = [] const items = parseItems(content, date, channel) items.forEach(item => { - const title = item.title + const prev = programs[programs.length - 1] let start = parseStart(item, date) - if (start.hour() > 18 && !PM) start = start.subtract(1, 'd') - else if (start.hour() > 11 && start.hour() < 18) PM = true - else if (start.hour() < 12 && PM) start = start.add(1, 'd') - const stop = start.add(1, 'h') - if (programs.length) { - programs[programs.length - 1].stop = start.toString() + if (prev) { + if (start.isBefore(prev.start)) { + start = start.add(1, 'd') + date = date.add(1, 'd') + } + prev.stop = start + } else if (start.hour() > 12) { + start = start.subtract(1, 'd') + date = date.subtract(1, 'd') } - + const stop = start.add(1, 'h') programs.push({ - title, - start: start.toString(), - stop: stop.toString() + title: item.title, + start, + stop }) })