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 }) }) diff --git a/sites/dstv.com/dstv.com.test.js b/sites/dstv.com/dstv.com.test.js index e5b3e536..da9607f8 100644 --- a/sites/dstv.com/dstv.com.test.js +++ b/sites/dstv.com/dstv.com.test.js @@ -7,20 +7,17 @@ const customParseFormat = require('dayjs/plugin/customParseFormat') dayjs.extend(customParseFormat) dayjs.extend(utc) -const date = dayjs.utc('2021-10-24', 'YYYY-MM-DD').startOf('d') +const date = dayjs.utc('2021-11-24', 'YYYY-MM-DD').startOf('d') const channel = { site_id: 'b0dc42b8-c651-4c3c-8713-a7fcd04744ee#M4H', xmltv_id: 'MNetMovies4.za', logo: 'https://rndcdn.dstv.com/dstvcms/2020/09/01/M-Net_Movies_4_Logo_4-3_lightbackground_xlrg.png' } -const content = JSON.stringify({ - M4H: "
21:30
Deadly Flight
08:25
I Still Believe
15:50
Despicable Me
20:35
The Foreigner
21:30
Deadly Flight
08:25
I Still Believe
15:50
Despicable Me
20:35
The Foreigner