From 30995f7c33a4789548a94447fe6effce244e29ee Mon Sep 17 00:00:00 2001 From: freearhey Date: Mon, 12 Jun 2023 09:38:43 +0300 Subject: [PATCH] Update gatotv.com.config.js --- sites/gatotv.com/gatotv.com.config.js | 34 +++++++++++---------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/sites/gatotv.com/gatotv.com.config.js b/sites/gatotv.com/gatotv.com.config.js index 3ca7b477..bff22d0f 100644 --- a/sites/gatotv.com/gatotv.com.config.js +++ b/sites/gatotv.com/gatotv.com.config.js @@ -2,14 +2,7 @@ const axios = require('axios') const cheerio = require('cheerio') const url = require('url') const path = require('path') -const dayjs = require('dayjs') -const utc = require('dayjs/plugin/utc') -const timezone = require('dayjs/plugin/timezone') -const customParseFormat = require('dayjs/plugin/customParseFormat') - -dayjs.extend(utc) -dayjs.extend(timezone) -dayjs.extend(customParseFormat) +const { DateTime } = require('luxon') module.exports = { site: 'gatotv.com', @@ -21,20 +14,17 @@ module.exports = { let programs = [] const items = parseItems(content) date = date.subtract(1, 'd') - items.forEach((item, index) => { + items.forEach((item, i) => { const prev = programs[programs.length - 1] const $item = cheerio.load(item) let start = parseStart($item, date) - if (prev) { - if (start.isBefore(prev.start)) { - start = start.add(1, 'd') - date = date.add(1, 'd') - } - prev.stop = start + if (i === 0 && start.hour >= 5) { + start = start.plus({ days: 1 }) + date = date.add(1, 'd') } - let stop = parseStop($item, start) - if (stop.isBefore(start)) { - stop = stop.add(1, 'd') + let stop = parseStop($item, date) + if (stop < start) { + stop = stop.plus({ days: 1 }) date = date.add(1, 'd') } @@ -87,13 +77,17 @@ function parseIcon($item) { function parseStart($item, date) { const time = $item('td:nth-child(1) > div > time').attr('datetime') - return dayjs.tz(`${date.format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm', 'EST') + return DateTime.fromFormat(`${date.format('YYYY-MM-DD')} ${time}`, 'yyyy-MM-dd HH:mm', { + zone: 'EST' + }).toUTC() } function parseStop($item, date) { const time = $item('td:nth-child(2) > div > time').attr('datetime') - return dayjs.tz(`${date.format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm', 'EST') + return DateTime.fromFormat(`${date.format('YYYY-MM-DD')} ${time}`, 'yyyy-MM-dd HH:mm', { + zone: 'EST' + }).toUTC() } function parseItems(content) {