Update tvinsider.com.config.js

Add episode-num, sub-title and previously-shown (dependent on https://github.com/freearhey/epg-grabber/issues/26)
This commit is contained in:
Igor Santander Angelini
2025-06-14 01:14:58 -03:00
committed by GitHub
parent 11e3f2cabe
commit 87dada1781

View File

@@ -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()