From 87dada178187464874ba4f1623cbe7f4e484bc3c Mon Sep 17 00:00:00 2001 From: Igor Santander Angelini <35164020+IgorAngelini@users.noreply.github.com> Date: Sat, 14 Jun 2025 01:14:58 -0300 Subject: [PATCH] Update tvinsider.com.config.js Add episode-num, sub-title and previously-shown (dependent on https://github.com/freearhey/epg-grabber/issues/26) --- sites/tvinsider.com/tvinsider.com.config.js | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sites/tvinsider.com/tvinsider.com.config.js b/sites/tvinsider.com/tvinsider.com.config.js index 21416917..9162c3bd 100644 --- a/sites/tvinsider.com/tvinsider.com.config.js +++ b/sites/tvinsider.com/tvinsider.com.config.js @@ -14,6 +14,7 @@ module.exports = { items.forEach(item => { const prev = programs[programs.length - 1] const $item = cheerio.load(item) + const episodeInfo = parseEP($item); let start = parseStart($item, date) if (!start) return if (prev) { @@ -26,6 +27,9 @@ module.exports = { description: parseDescription($item), category: parseCategory($item), date: parseDate($item), + ...episodeInfo, + subTitles: parseSubtitle($item), + previouslyShown: parsePreviously($item), start, stop }) @@ -63,6 +67,32 @@ module.exports = { function parseTitle($item) { return $item('h3').text().trim() } +function parseEP($item){ + const text = $item('h6').text().trim(); + const match = text.match(/Season\s+(\d+)\s*•\s*Episode\s+(\d+)/i); + + if (!match) return {}; // Return an empty object if no match, so properties are undefined later + + const season = parseInt(match[1], 10); + const episode = parseInt(match[2], 10); + + return { season, episode }; // Return an object with season and episode +} + +function parseSubtitle($item) { + return $item('h5').text().trim() +} + +function parsePreviously($item){ + const h3Text = $item('h3').text().trim(); + const isNewShow = /New$/.test(h3Text); + + if (isNewShow) { + return null; + } else { + return {}; + } +} function parseDescription($item) { return $item('p').text().trim()