Skip to content

Commit e0fdf22

Browse files
Merge pull request #2784 from IgorAngelini/patch-1
Add more tags to tvinsider.com
2 parents 9d33060 + 87dada1 commit e0fdf22

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

sites/tvinsider.com/tvinsider.com.config.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
items.forEach(item => {
1515
const prev = programs[programs.length - 1]
1616
const $item = cheerio.load(item)
17+
const episodeInfo = parseEP($item);
1718
let start = parseStart($item, date)
1819
if (!start) return
1920
if (prev) {
@@ -26,6 +27,9 @@ module.exports = {
2627
description: parseDescription($item),
2728
category: parseCategory($item),
2829
date: parseDate($item),
30+
...episodeInfo,
31+
subTitles: parseSubtitle($item),
32+
previouslyShown: parsePreviously($item),
2933
start,
3034
stop
3135
})
@@ -63,6 +67,32 @@ module.exports = {
6367
function parseTitle($item) {
6468
return $item('h3').text().trim()
6569
}
70+
function parseEP($item){
71+
const text = $item('h6').text().trim();
72+
const match = text.match(/Season\s+(\d+)\s*\s*Episode\s+(\d+)/i);
73+
74+
if (!match) return {}; // Return an empty object if no match, so properties are undefined later
75+
76+
const season = parseInt(match[1], 10);
77+
const episode = parseInt(match[2], 10);
78+
79+
return { season, episode }; // Return an object with season and episode
80+
}
81+
82+
function parseSubtitle($item) {
83+
return $item('h5').text().trim()
84+
}
85+
86+
function parsePreviously($item){
87+
const h3Text = $item('h3').text().trim();
88+
const isNewShow = /New$/.test(h3Text);
89+
90+
if (isNewShow) {
91+
return null;
92+
} else {
93+
return {};
94+
}
95+
}
6696

6797
function parseDescription($item) {
6898
return $item('p').text().trim()

0 commit comments

Comments
 (0)