diff --git a/sites/tv24.se/tv24.se.config.js b/sites/tv24.se/tv24.se.config.js index 7430e204..495e8369 100644 --- a/sites/tv24.se/tv24.se.config.js +++ b/sites/tv24.se/tv24.se.config.js @@ -34,6 +34,9 @@ module.exports = { actors: details.actors, icon: details.icon, category: details.category, + sub_title: details.sub_title, + season: details.season, + episode: details.episode, start, stop }) @@ -88,7 +91,10 @@ async function loadProgramDetails($item) { icon: parseIcon($), actors: parseActors($), description: parseDescription($), - category: parseCategory($) + category: parseCategory($), + sub_title: parseSubTitle($), + season: parseSeason($), + episode: parseEpisode($) }) } @@ -99,6 +105,30 @@ function parseIcon($) { return url } +function parseSeason($) { + const [_, season] = $('.sub-title') + .text() + .trim() + .match(/Säsong (\d+)/) || [null, ''] + + return parseInt(season) +} + +function parseEpisode($) { + const [_, episode] = $('.sub-title') + .text() + .trim() + .match(/Avsnitt (\d+)/) || [null, ''] + + return parseInt(episode) +} + +function parseSubTitle($) { + const [_, subtitle] = $('.sub-title').text().trim().split(': ') + + return subtitle +} + function parseCategory($) { return $('.extras > dt:contains(Kategori)').next().text().trim().split(' / ') }