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 diff --git a/sites/mewatch.sg/mewatch.sg.config.js b/sites/mewatch.sg/mewatch.sg.config.js index 4c945609..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 = [] @@ -40,7 +51,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', 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' ) })