From 564e3f301cd091861cb692c30db62b04c26c995c Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 10 Apr 2022 02:19:25 +0300 Subject: [PATCH] Update startimestv.com.config.js --- .../startimestv.com/startimestv.com.config.js | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/sites/startimestv.com/startimestv.com.config.js b/sites/startimestv.com/startimestv.com.config.js index d7cdd4e2..1a6f6a81 100644 --- a/sites/startimestv.com/startimestv.com.config.js +++ b/sites/startimestv.com/startimestv.com.config.js @@ -31,14 +31,37 @@ module.exports = { return programs }, - async channels() { + async channels({ country }) { + const area = { + ke: 6, + ng: 2, + tz: 3, + ug: 4, + rw: 5, + gh: 32, + mw: 14, + ci: 22, + gn: 12, + bi: 9, + cg: 16, + cd: 11, + mg: 13, + mz: 15, + cm: 20, + ga: 19 + } const data = await axios - .get(`https://www.startimestv.com/tv_guide.html`) + .get(`https://www.startimestv.com/tv_guide.html`, { + headers: { + Cookie: `default_areaID=${area[country]}` + } + }) .then(r => r.data) .catch(console.log) const $ = cheerio.load(data) const script = $('body > script:nth-child(10)').html() - const [_, json] = script.match(/var obj = eval\( '(.*)' \);/) || [null, null] + let [_, json] = script.match(/var obj = eval\( '(.*)' \);/) || [null, null] + json = json.replace(/\\'/g, '') const items = JSON.parse(json) return items.map(i => ({