From e3ae8f4292c9131d5ecb0c49be097f0cb170db62 Mon Sep 17 00:00:00 2001 From: Mahfud Harun Date: Tue, 3 Sep 2024 21:24:22 +0700 Subject: [PATCH 1/4] Skip channel addition if no `site_id` was found --- sites/mewatch.sg/mewatch.sg.config.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sites/mewatch.sg/mewatch.sg.config.js b/sites/mewatch.sg/mewatch.sg.config.js index 4c945609..6401fc7a 100644 --- a/sites/mewatch.sg/mewatch.sg.config.js +++ b/sites/mewatch.sg/mewatch.sg.config.js @@ -40,7 +40,11 @@ module.exports = { $('#side-nav > div > div > div > nav:nth-child(1) > ul > li > ul > li').each((i, el) => { const name = $(el).find('a > span').text() const url = $(el).find('a').attr('href') - const [, site_id] = url.match(/\/(\d+)\?player-fullscreen/) + const [, site_id = null] = url.match(/\/(\d+)\?player-fullscreen/) ?? [] + + if (!site_id) { + return + } channels.push({ lang: 'en', From 560000312841aedf6ec2a91ae5548fe13959cc1c Mon Sep 17 00:00:00 2001 From: Mahfud Harun Date: Tue, 3 Sep 2024 21:24:42 +0700 Subject: [PATCH 2/4] Update channels.xml --- sites/mewatch.sg/mewatch.sg.channels.xml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sites/mewatch.sg/mewatch.sg.channels.xml b/sites/mewatch.sg/mewatch.sg.channels.xml index 1f94c90b..19733c9e 100644 --- a/sites/mewatch.sg/mewatch.sg.channels.xml +++ b/sites/mewatch.sg/mewatch.sg.channels.xml @@ -1,5 +1,6 @@ + SPL02 Animax Channel 5 Channel 8 @@ -7,7 +8,6 @@ CinemaWorld Cinemax CNA - GEM Global Trekker HBO HBO Family @@ -15,12 +15,14 @@ HBO Signature LIVE 1 LIVE 2 - LIVE 5 - LIVE+ 1 + NOW 70s + NOW 80s + NOW Rock oktolidays ROCK Action ROCK Entertainment SPL01 Suria + TRACE Urban Vasantham From a7a4b3c95be68c0290f25f6606e0fd22f66862b6 Mon Sep 17 00:00:00 2001 From: Mahfud Harun Date: Wed, 4 Sep 2024 00:19:41 +0700 Subject: [PATCH 3/4] Use timezone offset to get programme list --- sites/mewatch.sg/mewatch.sg.config.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sites/mewatch.sg/mewatch.sg.config.js b/sites/mewatch.sg/mewatch.sg.config.js index 6401fc7a..1559fdf0 100644 --- a/sites/mewatch.sg/mewatch.sg.config.js +++ b/sites/mewatch.sg/mewatch.sg.config.js @@ -1,12 +1,23 @@ const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const timezone = require('dayjs/plugin/timezone') +const customParseFormat = require('dayjs/plugin/customParseFormat') + +dayjs.extend(utc) +dayjs.extend(timezone) +dayjs.extend(customParseFormat) module.exports = { site: 'mewatch.sg', days: 2, url: function ({ channel, date }) { - return `https://cdn.mewatch.sg/api/schedules?channels=${channel.site_id}&date=${date.format( + const utcDate = date.isUTC() ? date.tz(dayjs.tz.guess(), true).utc() : date.utc() + + return `https://cdn.mewatch.sg/api/schedules?channels=${channel.site_id}&date=${utcDate.format( 'YYYY-MM-DD' - )}&duration=24&ff=idp,ldp,rpt,cd&hour=21&intersect=true&lang=en&segments=all` + )}&duration=24&ff=idp,ldp,rpt,cd&hour=${utcDate.format( + 'HH' + )}&intersect=true&lang=en&segments=all` }, parser: function ({ content, channel }) { let programs = [] From e7335a8662223d87dd11f58a0a252b0bda31ee58 Mon Sep 17 00:00:00 2001 From: Mahfud Harun Date: Sun, 8 Sep 2024 07:09:35 +0700 Subject: [PATCH 4/4] Update expected URL in test update the `hour` param to 12 because the default TZ in test is `Pacific/Nauru` (GMT+12) --- sites/mewatch.sg/mewatch.sg.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sites/mewatch.sg/mewatch.sg.test.js b/sites/mewatch.sg/mewatch.sg.test.js index adc73f2f..6a949443 100644 --- a/sites/mewatch.sg/mewatch.sg.test.js +++ b/sites/mewatch.sg/mewatch.sg.test.js @@ -13,7 +13,7 @@ const channel = { it('can generate valid url', () => { expect(url({ channel, date })).toBe( - 'https://cdn.mewatch.sg/api/schedules?channels=97098&date=2022-06-11&duration=24&ff=idp,ldp,rpt,cd&hour=21&intersect=true&lang=en&segments=all' + 'https://cdn.mewatch.sg/api/schedules?channels=97098&date=2022-06-10&duration=24&ff=idp,ldp,rpt,cd&hour=12&intersect=true&lang=en&segments=all' ) })