From e54a15e3f8f81c5ac3236776d699343bd398ff81 Mon Sep 17 00:00:00 2001 From: Toha Date: Sat, 23 Nov 2024 22:45:14 +0700 Subject: [PATCH] Update mncvision.id guide. Signed-off-by: Toha --- sites/mncvision.id/mncvision.id.config.js | 66 +++++++++++++------ .../mncvision.id/mncvision.id_en.channels.xml | 29 ++++++-- .../mncvision.id/mncvision.id_id.channels.xml | 29 ++++++-- 3 files changed, 89 insertions(+), 35 deletions(-) diff --git a/sites/mncvision.id/mncvision.id.config.js b/sites/mncvision.id/mncvision.id.config.js index 8a791500..f2bf93bc 100644 --- a/sites/mncvision.id/mncvision.id.config.js +++ b/sites/mncvision.id/mncvision.id.config.js @@ -13,6 +13,7 @@ dayjs.extend(customParseFormat) const languages = { en: 'english', id: 'indonesia' } const cookies = {} const timeout = 30000 +const nworker = 25 module.exports = { site: 'mncvision.id', @@ -47,29 +48,11 @@ module.exports = { jar: null }, async parser({ content, headers, date, channel }) { - const programs = [] - if (!cookies[channel.lang]) { cookies[channel.lang] = parseCookies(headers) } - const [$, items] = parseItems(content) - for (const item of items) { - const $item = $(item) - const start = parseStart($item, date) - const duration = parseDuration($item) - const stop = start.add(duration, 'm') - const description = await loadDescription($item, cookies[channel.lang]) - programs.push({ - title: parseTitle($item), - season: parseSeason($item), - episode: parseEpisode($item), - description, - start, - stop - }) - } - return programs + return await parseItems(content, date, cookies[channel.lang]) }, async channels({ lang = 'id' }) { const axios = require('axios') @@ -129,10 +112,51 @@ function parseTitle($item) { return $item.find('td:nth-child(2) > a').text() } -function parseItems(content) { +async function parseItems(content, date, cookies) { + const programs = [] const $ = cheerio.load(content) + const items = $('tr[valign="top"]').toArray() + if (items.length) { + const workers = [] + const n = Math.min(nworker, items.length) + while (workers.length < n) { + const worker = () => { + if (items.length) { + const $item = $(items.shift()) + const done = (description = null) => { + const start = parseStart($item, date) + const duration = parseDuration($item) + const stop = start.add(duration, 'm') + programs.push({ + title: parseTitle($item), + season: parseSeason($item), + episode: parseEpisode($item), + description, + start, + stop + }) + worker() + } + loadDescription($item, cookies) + .then(description => done(description)) + } else { + workers.splice(workers.indexOf(worker), 1) + } + } + workers.push(worker) + worker() + } + await new Promise(resolve => { + const interval = setInterval(() => { + if (workers.length === 0) { + clearInterval(interval) + resolve() + } + }, 500) + }) + } - return [$, $('tr[valign="top"]').toArray()] + return programs } function loadLangCookies(channel) { diff --git a/sites/mncvision.id/mncvision.id_en.channels.xml b/sites/mncvision.id/mncvision.id_en.channels.xml index c8325dc9..0b5ac7fc 100644 --- a/sites/mncvision.id/mncvision.id_en.channels.xml +++ b/sites/mncvision.id/mncvision.id_en.channels.xml @@ -1,21 +1,28 @@ - Okezone TV - Celebrities TV ABC Australia Al Jazeera English Animax ANTV Arirang AXN - AXN HD + AXN HD BBC Earth BBC Earth HD BBC World News + beIN Sports 1 + beIN Sports 1 HD + beIN Sports 2 + beIN Sports 2 HD + beIN Sports 3 + beIN Sports 3 HD + beIN SPORTS 4 + beIN SPORTS 5 Bloomberg BTV CBeebies - CCM + Celebrities TV + CCM Celestial Movies CGTN CGTN Documentary @@ -33,6 +40,7 @@ CNBC Crime Investigation Dreamworks + Dreamworks HD DW English Entertainment EURONEWS @@ -43,8 +51,10 @@ Galaxy Galaxy Premium Global Trekker + Global Trekker HD GTV GTV HD + Hanacaraka TV History HITS HITS MOVIES @@ -53,10 +63,12 @@ IDX HD IMC Indosiar + Indosiar HD iNews iNews HD JAKTV Kids TV + Kids TV HD KIX Kompas TV LIFE @@ -66,9 +78,11 @@ Metro TV MNCTV MNCTV HD + Moonbug MTV 90's MTV LIVE Music TV + Music TV HD Muslim TV My Cinema My Cinema Asia @@ -80,19 +94,19 @@ Nickelodeon Nickelodeon Jr Nick Jr. HD - OK TV + FOOD TRAVEL + Food Travel HD ONE ONE HD Outdoor Channel Outdoor channel HD - PARAMOUNT - PARAMOUNT HD Al Quran Al Kareem RCTI RCTI HD Rock Entertainment Rock Action SCTV + SCTV HD SEA TODAY Sindo News TV Sindo News TV HD @@ -101,6 +115,7 @@ Sportstars 2 Sportstars 2 HD Sportstars 3 + sportstars 3 HD Sportstars 4 Sportstars 4 HD Sportstars diff --git a/sites/mncvision.id/mncvision.id_id.channels.xml b/sites/mncvision.id/mncvision.id_id.channels.xml index 4ddb79a9..06213fae 100644 --- a/sites/mncvision.id/mncvision.id_id.channels.xml +++ b/sites/mncvision.id/mncvision.id_id.channels.xml @@ -1,21 +1,28 @@ - Okezone TV - Celebrities TV ABC Australia Al Jazeera English Animax ANTV Arirang AXN - AXN HD + AXN HD BBC Earth BBC Earth HD BBC World News + beIN Sports 1 + beIN Sports 1 HD + beIN Sports 2 + beIN Sports 2 HD + beIN Sports 3 + beIN Sports 3 HD + beIN SPORTS 4 + beIN SPORTS 5 Bloomberg BTV CBeebies - CCM + Celebrities TV + CCM Celestial Movies CGTN CGTN Documentary @@ -33,6 +40,7 @@ CNBC Crime Investigation Dreamworks + Dreamworks HD DW English Entertainment EURONEWS @@ -43,8 +51,10 @@ Galaxy Galaxy Premium Global Trekker + Global Trekker HD GTV GTV HD + Hanacaraka TV History HITS HITS MOVIES @@ -53,10 +63,12 @@ IDX HD IMC Indosiar + Indosiar HD iNews iNews HD JAKTV Kids TV + Kids TV HD KIX Kompas TV LIFE @@ -66,9 +78,11 @@ Metro TV MNCTV MNCTV HD + Moonbug MTV 90's MTV LIVE Music TV + Music TV HD Muslim TV My Cinema My Cinema Asia @@ -80,19 +94,19 @@ Nickelodeon Nickelodeon Jr Nick Jr. HD - OK TV + FOOD TRAVEL + Food Travel HD ONE ONE HD Outdoor Channel Outdoor channel HD - PARAMOUNT - PARAMOUNT HD Al Quran Al Kareem RCTI RCTI HD Rock Entertainment Rock Action SCTV + SCTV HD SEA TODAY Sindo News TV Sindo News TV HD @@ -101,6 +115,7 @@ Sportstars 2 Sportstars 2 HD Sportstars 3 + sportstars 3 HD Sportstars 4 Sportstars 4 HD Sportstars