From 42ce11a6bab799dc5cefcbe21f8b8989856f8244 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Mon, 27 Jan 2025 04:50:14 +0300 Subject: [PATCH] Update tvtv.us.config.js --- sites/tvtv.us/tvtv.us.config.js | 41 +++++++++++---------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/sites/tvtv.us/tvtv.us.config.js b/sites/tvtv.us/tvtv.us.config.js index 098be11f..87823fcd 100644 --- a/sites/tvtv.us/tvtv.us.config.js +++ b/sites/tvtv.us/tvtv.us.config.js @@ -1,42 +1,24 @@ const dayjs = require('dayjs') -const utc = require('dayjs/plugin/utc') - -dayjs.extend(utc) module.exports = { site: 'tvtv.us', days: 2, - url: function ({ date, channel }) { - if (!dayjs.isDayjs(date)) { - throw new Error('Invalid date object passed to url function') - } - + url({ date, channel }) { return `https://www.tvtv.us/api/v1/lineup/USA-NY71652-X/grid/${date.toJSON()}/${date .add(1, 'day') .toJSON()}/${channel.site_id}` }, - request: { - method: 'GET', - headers: { - Accept: '*/*', - Connection: 'keep-alive', - 'User-Agent': - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36', - 'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"', - 'sec-ch-ua-mobile': '?0', - 'sec-ch-ua-platform': '"Windows"' - } - }, - parser: function ({ content }) { + parser({ content }) { let programs = [] const items = parseItems(content) items.forEach(item => { - const start = dayjs.utc(item.startTime) - const stop = start.add(item.runTime, 'minute') + const start = dayjs(item.startTime) + const stop = start.add(item.duration, 'minute') + programs.push({ title: item.title, - description: item.subtitle, + subtitle: item.subtitle || null, start, stop }) @@ -47,7 +29,12 @@ module.exports = { } function parseItems(content) { - const json = JSON.parse(content) - if (!json.length) return [] - return json[0] + try { + const json = JSON.parse(content) + if (!json.length) return [] + + return json[0] + } catch { + return [] + } }