From 53fd22e0a435b7539faf50fda6b0c99a4b489444 Mon Sep 17 00:00:00 2001 From: StrangeDrVN <172238701+StrangeDrVN@users.noreply.github.com> Date: Sun, 19 Apr 2026 21:59:29 +0530 Subject: [PATCH] update channels api + programs --- sites/mewatch.sg/mewatch.sg.channels.xml | 138 +++++++++++++++++++---- sites/mewatch.sg/mewatch.sg.config.js | 76 ++++++++----- sites/mewatch.sg/mewatch.sg.test.js | 37 +++--- 3 files changed, 183 insertions(+), 68 deletions(-) diff --git a/sites/mewatch.sg/mewatch.sg.channels.xml b/sites/mewatch.sg/mewatch.sg.channels.xml index e84bfbccd..b304c3d6b 100644 --- a/sites/mewatch.sg/mewatch.sg.channels.xml +++ b/sites/mewatch.sg/mewatch.sg.channels.xml @@ -1,28 +1,122 @@ - CNA - LIVE 1 - LIVE 2 - Suria - Vasantham + Action Hollywood Movies + W-Sport + River Monsters + Fear Factor + MasterChef + Vijay Takkar + Hub VV Drama HD + BBC Earth HD + ONE HD + Hub Sports 3 HD + KTV HD + HITS HD + FIGHT SPORTS HD + KBS World HD + Hub E City HD + Hub Sports 1 HD + Hub Sports 2 HD + Nick Jr. HD + Nickelodeon Asia HD + DreamWorks HD + HISTORY HD + ANC + The Filipino Channel HD + HITS MOVIES HD + Astro Warna HD + Astro Sensasi HD + ONE (Malay) + BBC News HD + CCTV-4 + Phoenix Chinese Channel HD + Phoenix InfoNews Channel HD + TVBS-NEWS + ETTV Asia HD + Cartoon Network + Crime + Investigation HD + Discovery HD + Travelxp HD + BBC Lifestyle HD + HGTV HD + ROCK Entertainment HD + Deal or No Deal + AXN HD + Lifetime HD + Fox News Channel HD + Sky News HD + Euronews HD + CNBC HD + CNN HD + CTI Asia HD + Hub Ruyi + TVB Xing He HD + Celestial Movies HD + Zee TV HD + Zee Thirai + Vijay TV HD + Sun TV + Sun Music + Sony Entertainment Television + SONY MAX + COLORS + COLORS Tamil HD + Asianet + Asianet Movies + Cricbuzz + Cricbuzz 2 + SPOTV + SPOTV2 + beIN SPORTS 5 HD + beIN SPORTS HD + beIN SPORTS 2 HD + Hub Sports 6 HD + Hub Sports 5 HD + beIN SPORTS 3 HD + Hub Sports 4 HD + Hub Sports 8 HD + beIN SPORTS 4 HD + Hub Sports 7 HD + That's 80s + That's Rock + That's 70s + ADITHYA TV + Animax HD + CBeebies HD + CCM + CGTN Channel 5 Channel 8 Channel U - HBO - HBO Hits - HBO Signature - HBO Family - Cinemax - SPL01 - SPL02 - Global Trekker - TRACE Urban - NOW Rock - NOW 70s - NOW 80s - oktolidays - ROCK Entertainment - ROCK Action - Animax + Cinema One Global CinemaWorld - + Citra Entertainment + CNA + Dragon TV + FIFA+ + FoodON + Hub Premier 1 + Hub Premier 2 + Hub Premier 3 + Hub Premier 4 + Hub Premier 5 + Hub Premier 6 + Hub Premier 7 + Hub Premier 8 + Hub Premier 9 + Hub Premier 10 + Hub Premier 11 + Kalaignar TV + Karisma + Kartoon Channel! + LIVE 1 + SPL CH01 + Suria + TG Junior + TRACE Sport Stars + TVBS Asia + Vannathirai + Vasantham + Zee Cinema HD + Zee Tamil HD + \ No newline at end of file diff --git a/sites/mewatch.sg/mewatch.sg.config.js b/sites/mewatch.sg/mewatch.sg.config.js index 1b793c83a..375c374cc 100644 --- a/sites/mewatch.sg/mewatch.sg.config.js +++ b/sites/mewatch.sg/mewatch.sg.config.js @@ -24,12 +24,25 @@ module.exports = { const items = parseItems(content, channel) items.forEach(item => { const info = item.item + + let title = info.title || '' + let subTitle = info.episodeTitle || null + + if (subTitle && title.includes(` - ${subTitle}`)) { + title = title.replace(` - ${subTitle}`, '') + } + + if (title === subTitle) { + subTitle = null + } + programs.push({ - title: info.title, - description: info.description, - image: info.images.tile, - episode: info.episodeNumber, - season: info.seasonNumber, + title, + subTitle, + description: info.description || null, + image: info.images?.tile || null, + episode: info.episodeNumber || null, + season: info.seasonNumber || null, start: parseStart(item), stop: parseStop(item), rating: parseRating(info) @@ -40,29 +53,40 @@ module.exports = { }, async channels() { const axios = require('axios') - const cheerio = require('cheerio') - const data = await axios - .get('https://www.mewatch.sg/channel-guide') - .then(r => r.data) - .catch(console.log) - + const LIST_ID = '239614' let channels = [] - const $ = cheerio.load(data) - $('#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 = null] = url.match(/\/(\d+)\?player-fullscreen/) ?? [] + let page = 1 + let hasNextPage = true - if (!site_id) { - return + while (hasNextPage) { + const url = `https://cdn.mewatch.sg/api/lists/${LIST_ID}?page=${page}&page_size=100&segments=all` + + try { + const r = await axios.get(url) + const data = r.data + + if (data && Array.isArray(data.items)) { + data.items.forEach(item => { + if (item.type === 'channel' || item.itemType === 'channel') { + channels.push({ + lang: 'en', + name: item.title, + site_id: item.id + }) + } + }) + } + + if (data.paging && data.paging.next) { + page++ + } else { + hasNextPage = false + } + } catch (error) { + console.error(`Error fetching page ${page}:`, error.message) + hasNextPage = false } - - channels.push({ - lang: 'en', - name, - site_id - }) - }) + } return channels } @@ -97,4 +121,4 @@ function parseItems(content, channel) { const channelData = data.find(i => i.channelId === channel.site_id) return channelData && Array.isArray(channelData.schedules) ? channelData.schedules : [] -} +} \ No newline at end of file diff --git a/sites/mewatch.sg/mewatch.sg.test.js b/sites/mewatch.sg/mewatch.sg.test.js index f65ecb3f9..6364cde07 100644 --- a/sites/mewatch.sg/mewatch.sg.test.js +++ b/sites/mewatch.sg/mewatch.sg.test.js @@ -9,13 +9,13 @@ dayjs.extend(utc) const date = dayjs.utc('2022-06-11', 'YYYY-MM-DD').startOf('d') const channel = { - site_id: '97098', - xmltv_id: 'Channel5Singapore.sg' + site_id: '571922', + xmltv_id: 'AnimaxAsia.sg@SD' } it('can generate valid url', () => { expect(url({ channel, date })).toBe( - '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' + 'https://cdn.mewatch.sg/api/schedules?channels=571922&date=2022-06-10&duration=24&ff=idp,ldp,rpt,cd&hour=12&intersect=true&lang=en&segments=all' ) }) @@ -27,23 +27,20 @@ it('can parse response', () => { return p }) - expect(result).toMatchObject([ - { - start: '2022-06-11T21:00:00.000Z', - stop: '2022-06-11T21:30:00.000Z', - title: 'Open Homes S3 - EP 2', - description: - 'Mike heads down to the Sydney beaches to visit a beachside renovation with all the bells and whistles, we see a kitchen tip and recipe anyone can do at home. We finish up in the prestigious Byron bay to visit a multi million dollar award winning home.', - image: - "https://production.togglestatic.com/shain/v1/dataservice/ResizeImage/$value?Format='jpg'&Quality=85&ImageId='4853697'&EntityType='LinearSchedule'&EntityId='788a7dd9-9b12-446f-91b4-c8ac9fec95e5'&Width=1280&Height=720&device=web_browser&subscriptions=Anonymous&segmentationTags=all", - episode: 2, - season: 3, - rating: { - system: 'IMDA', - value: 'G' - } - } - ]) + expect(result.length).toBe(45) + expect(result[0]).toMatchObject({ + title: 'Tsukimichi -Moonlit Fantasy- Season 2', + subTitle: 'Why Am I A Teacher?!', + description: + 'After arriving in Rotsgard, Makoto and Shiki gather info for their new store but soon help a girl named Luria in trouble.', + image: + "https://prod98.togglestatic.com/shain/v1/dataservice/ResizeImage/$value?Format='jpg'&Quality=85&ImageId='13651065'&EntityType='LinearSchedule'&EntityId='fdb1a2e4-efe5-41dd-8560-84d4c3f50459'&Width=1280&Height=720", + episode: 4, + season: null, + start: '2026-04-19T00:00:00.000Z', + stop: '2026-04-19T00:30:00.000Z', + rating: { system: 'IMDA', value: 'PG13' } + }) }) it('can handle empty guide', () => {