From 0d32c3dedddb63a01b66b391f9c671d1b14be87d Mon Sep 17 00:00:00 2001 From: Newbiect <51307314+Newbiect@users.noreply.github.com> Date: Tue, 31 Dec 2024 17:11:46 -0500 Subject: [PATCH] Update pluto.tv.config.js --- sites/pluto.tv/pluto.tv.config.js | 36 +++++++++++++++++++------------ 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/sites/pluto.tv/pluto.tv.config.js b/sites/pluto.tv/pluto.tv.config.js index 5436273b..ade3ea2c 100644 --- a/sites/pluto.tv/pluto.tv.config.js +++ b/sites/pluto.tv/pluto.tv.config.js @@ -1,22 +1,30 @@ -const dayjs = require('dayjs'); -const axios = require('axios'); +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const timezone = require('dayjs/plugin/timezone') +const axios = require('axios') + +dayjs.extend(utc) +dayjs.extend(timezone) module.exports = { site: 'pluto.tv', - days: 2, + days: 3, url: function ({ date, channel }) { - const channelId = channel.site_id; - const startTime = dayjs.utc(date).startOf('day').toISOString(); - const endTime = dayjs.utc(date).add(this.days - 1, 'day').endOf('day').toISOString(); + const channelId = channel.site_id - const generatedUrl = `https://api.pluto.tv/v2/channels/${channelId}?start=${startTime}&stop=${endTime}`; - return generatedUrl; + const localTimezone = dayjs.tz.guess() + + const startTime = dayjs(date).tz(localTimezone).startOf('day').toISOString() + const endTime = dayjs(date).tz(localTimezone).add(this.days, 'day').endOf('day').toISOString() + + const generatedUrl = `https://api.pluto.tv/v2/channels/${channelId}?start=${startTime}&stop=${endTime}` + return generatedUrl }, parser: function ({ content }) { - const data = JSON.parse(content); - const programs = []; + const data = JSON.parse(content) + const programs = [] if (data.timelines) { data.timelines.forEach(item => { @@ -33,10 +41,10 @@ module.exports = { icon: item.episode?.series?.tile?.path || '', start: item.start, stop: item.stop - }); - }); + }) + }) } - return programs; + return programs } -}; +}