diff --git a/sites/mncvision.id/__data__/content.html b/sites/mncvision.id/__data__/content.html new file mode 100644 index 00000000..319e0fae --- /dev/null +++ b/sites/mncvision.id/__data__/content.html @@ -0,0 +1,808 @@ + + + + + + + + + + + + + + + + + + + + + + + + +Schedule | Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ +
+
+

Jadwal Tayang Cari

+ +
+ +
+ + + +
+
Jadwal Tayang Channel: 38 Tanggal: 2022-10-05
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Jam TayangProgram AcaraDurasi
00:00Adventures With Miao Mi, Ep 100:06
00:06Adventures With Miao Mi, Ep 300:07
00:13Jili And Gulu, Ep 900:09
00:22Miao Mi Classroom, Ep 22900:11
00:33Leo Wildlife Ranger S2, Ep 2700:13
00:46Leo Wildlife Ranger S2, Ep 2800:14
01:00Write With Miao Mi, Ep 3700:04
01:04Fun Alliance, Ep 4700:07
01:11Fun Alliance, Ep 4800:08
01:19Emmy & GooRoo Big Book, Ep 1100:05
01:24Miao Mi Classroom, Ep 29500:04
01:28Rainbow Chicks S6, Ep 2500:10
01:38Rainbow Chicks S6, Ep 2600:11
01:49Miao Mi Classroom, Ep 22900:11
02:00Write With Miao Mi, Ep 3700:03
02:03Egg Car, Ep 1300:15
02:18Kiki And Nuna, Ep 1400:09
02:27Miao Mi Classroom, Ep 29500:03
02:30Rainbow Chicks S4, Ep 1800:10
02:40Rainbow Chicks S4, Ep 1900:10
02:50Jili And Gulu, Ep 800:10
03:00Adventures With Miao Mi, Ep 100:06
03:06Adventures With Miao Mi, Ep 300:07
03:13Jili And Gulu, Ep 900:09
03:22Miao Mi Classroom, Ep 22900:11
03:33Leo Wildlife Ranger S2, Ep 2700:13
03:46Leo Wildlife Ranger S2, Ep 2800:14
04:00Write With Miao Mi, Ep 3700:04
04:04Fun Alliance, Ep 4700:07
04:11Fun Alliance, Ep 4800:08
04:19Emmy & GooRoo Big Book, Ep 1100:05
04:24Miao Mi Classroom, Ep 29500:04
04:28Rainbow Chicks S6, Ep 2500:10
04:38Rainbow Chicks S6, Ep 2600:11
04:49Miao Mi Classroom, Ep 22900:11
05:00Write With Miao Mi, Ep 3700:03
05:03Egg Car, Ep 1400:15
05:18Kiki And Nuna, Ep 1500:09
05:27Miao Mi Classroom, Ep 29600:03
05:30Rainbow Chicks S4, Ep 1900:10
05:40Rainbow Chicks S4, Ep 2000:10
05:50Jili And Gulu, Ep 900:10
06:00Adventures With Miao Mi, Ep 200:06
06:06Adventures With Miao Mi, Ep 100:07
06:13Jili And Gulu, Ep 1000:09
06:22Miao Mi Classroom, Ep 22900:11
06:33Leo Wildlife Ranger S2, Ep 2800:13
06:46Leo Wildlife Ranger S2, Ep 2900:14
07:00Write With Miao Mi, Ep 3700:04
07:04Fun Alliance, Ep 4800:07
+
page: 12
+
+ +
+ EPG +
+
+ + + + + + + + + + + + + + + + + + + diff --git a/sites/mncvision.id/__data__/content_p2.html b/sites/mncvision.id/__data__/content_p2.html new file mode 100644 index 00000000..ee9c02d7 --- /dev/null +++ b/sites/mncvision.id/__data__/content_p2.html @@ -0,0 +1,808 @@ + + + + + + + + + + + + + + + + + + + + + + + + +Schedule | Table | Startno + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ +
+
+

Jadwal Tayang Cari

+ +
+ +
+ + + +
+
Jadwal Tayang Channel: 38 Tanggal: 2022-10-05
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Jam TayangProgram AcaraDurasi
07:11Fun Alliance, Ep 4900:08
07:19Emmy & GooRoo Big Book, Ep 1200:05
07:24Miao Mi Classroom, Ep 29600:04
07:28Rainbow Chicks S6, Ep 2600:10
07:38Rainbow Chicks S7, Ep 100:10
07:48Miao Mi Classroom, Ep 22900:12
08:00Write With Miao Mi, Ep 3700:03
08:03Egg Car, Ep 1400:15
08:18Kiki And Nuna, Ep 1500:09
08:27Miao Mi Classroom, Ep 29600:03
08:30Rainbow Chicks S4, Ep 1900:10
08:40Rainbow Chicks S4, Ep 2000:10
08:50Jili And Gulu, Ep 900:10
09:00Adventures With Miao Mi, Ep 200:06
09:06Adventures With Miao Mi, Ep 100:07
09:13Jili And Gulu, Ep 1000:09
09:22Miao Mi Classroom, Ep 22900:11
09:33Leo Wildlife Ranger S2, Ep 2800:13
09:46Leo Wildlife Ranger S2, Ep 2900:14
10:00Write With Miao Mi, Ep 3700:04
10:04Fun Alliance, Ep 4800:07
10:11Fun Alliance, Ep 4900:08
10:19Emmy & GooRoo Big Book, Ep 1200:05
10:24Miao Mi Classroom, Ep 29600:04
10:28Rainbow Chicks S6, Ep 2600:10
10:38Rainbow Chicks S7, Ep 100:10
10:48Miao Mi Classroom, Ep 22900:12
11:00Write With Miao Mi, Ep 3700:03
11:03Egg Car, Ep 1400:15
11:18Kiki And Nuna, Ep 1500:09
11:27Miao Mi Classroom, Ep 29600:03
11:30Rainbow Chicks S4, Ep 1900:10
11:40Rainbow Chicks S4, Ep 2000:10
11:50Jili And Gulu, Ep 900:10
12:00Adventures With Miao Mi, Ep 200:06
12:06Adventures With Miao Mi, Ep 100:07
12:13Jili And Gulu, Ep 1000:09
12:22Miao Mi Classroom, Ep 22900:11
12:33Leo Wildlife Ranger S2, Ep 2800:13
12:46Leo Wildlife Ranger S2, Ep 2900:14
13:00Write With Miao Mi, Ep 3700:04
13:04Fun Alliance, Ep 4800:07
13:11Fun Alliance, Ep 4900:08
13:19Emmy & GooRoo Big Book, Ep 1200:05
13:24Miao Mi Classroom, Ep 29600:04
13:28Rainbow Chicks S6, Ep 2600:10
13:38Rainbow Chicks S7, Ep 100:10
13:48Miao Mi Classroom, Ep 22900:12
14:00Write With Miao Mi, Ep 3700:03
14:03Egg Car, Ep 1400:15
+
page: 12
+
+ +
+ EPG +
+
+ + + + + + + + + + + + + + + + + + + diff --git a/sites/mncvision.id/__data__/no_content.html b/sites/mncvision.id/__data__/no_content.html new file mode 100644 index 00000000..b9301c56 --- /dev/null +++ b/sites/mncvision.id/__data__/no_content.html @@ -0,0 +1,550 @@ + + + + + + + + + + + + + + + + + + + + + + + + +Schedule | Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ +
+
+

Jadwal Tayang Cari

+ +
+ +
+ + + +
+
Jadwal Tayang Channel: 381 Tanggal: 2022-10-05
+
Maaf.. data jadwal acara tidak ada
+
+ +
+ EPG +
+
+ + + + + + + + + + + + + + + + + + + diff --git a/sites/mncvision.id/__data__/program_en.html b/sites/mncvision.id/__data__/program_en.html new file mode 100644 index 00000000..d5a4c806 --- /dev/null +++ b/sites/mncvision.id/__data__/program_en.html @@ -0,0 +1,27 @@ +
+ +

Synopsis

+ + +
+ + +
05 Oct 2022, 12:00 AM
00:00 - 00:06 [duration:00:06]
+ +
+ When children begin to disappear, a group of young kids have to face their biggest fears when they square off against a murderous, evil clown.
+ +
+ Miao Mi +
+ + Channel 38 + + +
+
+ + +
+ +
\ No newline at end of file diff --git a/sites/mncvision.id/__data__/program_id.html b/sites/mncvision.id/__data__/program_id.html new file mode 100644 index 00000000..ea6cdbf5 --- /dev/null +++ b/sites/mncvision.id/__data__/program_id.html @@ -0,0 +1,27 @@ +
+ +

Synopsis

+ + +
+ + +
05 Oct 2022, 12:00 AM
00:00 - 00:06 [durasi:00:06]
+ +
+ Ketika anak-anak mulai menghilang, sekelompok anak kecil harus menghadapi ketakutan terbesar mereka ketika mereka melawan sesosok badut pembunuh yang jahat.
+ +
+ Miao Mi +
+ + Channel 38 + + +
+
+ + +
+ +
\ No newline at end of file diff --git a/sites/mncvision.id/mncvision.id.config.js b/sites/mncvision.id/mncvision.id.config.js index 07111aec..0067336a 100644 --- a/sites/mncvision.id/mncvision.id.config.js +++ b/sites/mncvision.id/mncvision.id.config.js @@ -1,4 +1,4 @@ -const FormData = require('form-data') +const _ = require('lodash') const axios = require('axios') const cheerio = require('cheerio') const dayjs = require('dayjs') @@ -16,8 +16,7 @@ module.exports = { request: { method: 'POST', data: function ({ channel, date }) { - const formData = new FormData() - formData.setBoundary('X-EPG-BOUNDARY') + const formData = new URLSearchParams() formData.append('search_model', 'channel') formData.append('af0rmelement', 'aformelement') formData.append('fdate', date.format('YYYY-MM-DD')) @@ -27,29 +26,36 @@ module.exports = { return formData }, headers: { - 'Content-Type': 'multipart/form-data; boundary=X-EPG-BOUNDARY' - } + 'Content-Type': 'application/x-www-form-urlencoded' + }, + jar: null }, async parser({ content, date, headers, channel }) { const programs = [] + const cookies = parseCookies(headers) + if (!cookies) return programs let items = parseItems(content) if (!items.length) return programs const pages = parsePages(content) - const cookies = headers && headers['set-cookie'] ? headers['set-cookie'].join(';') : '' for (let url of pages) { items = items.concat(parseItems(await loadNextPage(url, cookies))) } const langCookies = await loadLangCookies(channel) + if (!langCookies) return programs for (const item of items) { - const start = parseStart(item, date) - const duration = parseDuration(item) + const $item = cheerio.load(item) + const start = parseStart($item, date) + const duration = parseDuration($item) const stop = start.add(duration, 'm') + const description = await loadDescription($item, langCookies) programs.push({ - title: parseTitle(item), - description: await loadDescription(item, langCookies), + title: parseTitle($item), + season: parseSeason($item), + episode: parseEpisode($item), + description, start, stop }) @@ -61,7 +67,7 @@ module.exports = { const data = await axios .get('https://www.mncvision.id/schedule') .then(response => response.data) - .catch(console.log) + .catch(console.error) const $ = cheerio.load(data) const items = $('select[name="fchannel"] option').toArray() @@ -79,46 +85,22 @@ module.exports = { } } -async function loadNextPage(url, cookies) { - return axios - .get(url, { - headers: { - Cookie: cookies - } - }) - .then(r => r.data) - .catch(console.log) +function parseSeason($item) { + const title = parseTitle($item) + const [_, season] = title.match(/ S(\d+)/) || [null, null] + + return season ? parseInt(season) : null } -async function loadLangCookies(channel) { - const lang = channel.lang === 'en' ? 'english' : 'indonesia' - const url = `https://www.mncvision.id/language_switcher/setlang/${lang}/` +function parseEpisode($item) { + const title = parseTitle($item) + const [_, episode] = title.match(/ Ep (\d+)/) || [null, null] - return axios - .get(url) - .then(r => r.headers['set-cookie'].join(';')) - .catch(console.error) + return episode ? parseInt(episode) : null } -async function loadDescription(item, cookies) { - const $item = cheerio.load(item) - const progUrl = $item('a').attr('href') - if (!progUrl) return null - const data = await axios - .get(progUrl, { headers: { 'X-Requested-With': 'XMLHttpRequest', Cookie: cookies } }) - .then(r => r.data) - .catch(console.log) - if (!data) return null - const $page = cheerio.load(data) - const description = $page('.synopsis').text().trim() - if (description === '-') return null - - return description -} - -function parseDuration(item) { - const $ = cheerio.load(item) - let duration = $('td:nth-child(3)').text() +function parseDuration($item) { + let duration = $item('td:nth-child(3)').text() const match = duration.match(/(\d{2}):(\d{2})/) const hours = parseInt(match[1]) const minutes = parseInt(match[2]) @@ -126,18 +108,15 @@ function parseDuration(item) { return hours * 60 + minutes } -function parseStart(item, date) { - const $ = cheerio.load(item) - let time = $('td:nth-child(1)').text() +function parseStart($item, date) { + let time = $item('td:nth-child(1)').text() time = `${date.format('DD/MM/YYYY')} ${time}` return dayjs.tz(time, 'DD/MM/YYYY HH:mm', 'Asia/Jakarta') } -function parseTitle(item) { - const $ = cheerio.load(item) - - return $('td:nth-child(2) > a').text() +function parseTitle($item) { + return $item('td:nth-child(2) > a').text() } function parseItems(content) { @@ -148,13 +127,57 @@ function parseItems(content) { function parsePages(content) { const $ = cheerio.load(content) - const links = $('#schedule > div.schedule_search_result_container > div.box.well > a').toArray() + const links = $('#schedule > div.schedule_search_result_container > div.box.well > a') + .map((i, el) => { + return $(el).attr('href') + }) + .get() - const pages = {} - for (let link of links) { - const url = $(link).attr('href') - pages[url] = true - } - - return Object.keys(pages) + return _.uniq(links) +} + +function loadNextPage(url, cookies) { + return axios + .get(url, { headers: { Cookie: cookies }, timeout: 30000 }) + .then(r => r.data) + .catch(err => { + console.log(err.message) + + return null + }) +} + +function loadLangCookies(channel) { + const languages = { + en: 'english', + id: 'indonesia' + } + const url = `https://www.mncvision.id/language_switcher/setlang/${languages[channel.lang]}/` + + return axios + .get(url, { timeout: 30000 }) + .then(r => parseCookies(r.headers)) + .catch(err => null) +} + +async function loadDescription($item, cookies) { + const url = $item('a').attr('href') + if (!url) return null + const content = await axios + .get(url, { + headers: { 'X-Requested-With': 'XMLHttpRequest', Cookie: cookies }, + timeout: 30000 + }) + .then(r => r.data) + .catch(err => null) + if (!content) return null + + const $page = cheerio.load(content) + const description = $page('.synopsis').text().trim() + + return description !== '-' ? description : null +} + +function parseCookies(headers) { + return Array.isArray(headers['set-cookie']) ? headers['set-cookie'].join(';') : null } diff --git a/sites/mncvision.id/mncvision.id.test.js b/sites/mncvision.id/mncvision.id.test.js index faa3ee3e..91c2ddd3 100644 --- a/sites/mncvision.id/mncvision.id.test.js +++ b/sites/mncvision.id/mncvision.id.test.js @@ -1,8 +1,10 @@ +// npx epg-grabber --config=sites/mncvision.id/mncvision.id.config.js --channels=sites/mncvision.id/mncvision.id_id-id.channels.xml --output=guide.xml --timeout=30000 --days=2 +// npx epg-grabber --config=sites/mncvision.id/mncvision.id.config.js --channels=sites/mncvision.id/mncvision.id_id-en.channels.xml --output=guide.xml --timeout=30000 --days=2 // node ./scripts/channels.js --config=./sites/mncvision.id/mncvision.id.config.js --output=./sites/mncvision.id/mncvision.id_id.channels.xml -// npx epg-grabber --config=sites/mncvision.id/mncvision.id.config.js --channels=sites/mncvision.id/mncvision.id_id-id.channels.xml --output=guide.xml --days=2 -// npx epg-grabber --config=sites/mncvision.id/mncvision.id.config.js --channels=sites/mncvision.id/mncvision.id_id-en.channels.xml --output=guide.xml --days=2 const { parser, url, request } = require('./mncvision.id.config.js') +const fs = require('fs') +const path = require('path') const axios = require('axios') const dayjs = require('dayjs') const utc = require('dayjs/plugin/utc') @@ -12,181 +14,138 @@ dayjs.extend(utc) jest.mock('axios') -const date = dayjs.utc('2021-11-12', 'YYYY-MM-DD').startOf('d') -const channelID = { - site_id: '203', - xmltv_id: 'AnimalPlanetSoutheastAsia.us', +const date = dayjs.utc('2022-10-05', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '38', + xmltv_id: 'MiaoMi.hk', lang: 'id' } -const channelEN = { - site_id: '203', - xmltv_id: 'AnimalPlanetSoutheastAsia.us', - lang: 'en' +const headers = { + 'set-cookie': [ + 's1nd0vL=05e9pr6gi112tdmutsn7big93o75r0b0; expires=Wed, 05-Oct-2022 14:18:22 GMT; Max-Age=7200; path=/; HttpOnly' + ] } -const setCookie = [ - 's1nd0vL=0qpsmm7dpjmi7nt8d2h5epf16rmgg8a8; expires=Sat, 05-Mar-2022 15:44:22 GMT; Max-Age=7200; path=/; HttpOnly' -] - -const content0 = `

Jadwal Tayang Cari

Jadwal Tayang Channel: 41 Tanggal: 2022-03-05
Jam Tayang Program Acara Durasi
00:00Hey Duggee S3, Ep 2200:07
page: 12
` -const content50 = `

Jadwal Tayang Cari

Jadwal Tayang Channel: 41 Tanggal: 2022-03-05
Jam Tayang Program Acara Durasi
08:25Hey Duggee S1, Ep 4600:07
page: 12
` it('can generate valid url', () => { expect(url).toBe('https://mncvision.id/schedule/table') }) +it('can generate valid request method', () => { + expect(request.method).toBe('POST') +}) + it('can generate valid request headers', () => { expect(request.headers).toMatchObject({ - 'Content-Type': 'multipart/form-data; boundary=X-EPG-BOUNDARY' + 'Content-Type': 'application/x-www-form-urlencoded' }) }) it('can generate valid request data', () => { - const result = request.data({ channel: channelID, date }) - expect(result._boundary).toBe('X-EPG-BOUNDARY') + const data = request.data({ channel, date }) + expect(data.get('search_model')).toBe('channel') + expect(data.get('af0rmelement')).toBe('aformelement') + expect(data.get('fdate')).toBe('2022-10-05') + expect(data.get('fchannel')).toBe('38') + expect(data.get('submit')).toBe('Search') }) -it('can parse response in Indonesian', done => { - const setLangCookie = [ - 's1nd0vL=oj87dbpo7cqbg8fit3295075kodja8hl; expires=Fri, 11-Mar-2022 14:40:17 GMT; Max-Age=7200; path=/; HttpOnly' - ] - - axios.get.mockImplementation((url, options = {}) => { +it('can parse response', async () => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html')) + const indonesiaHeaders = { + 'set-cookie': [ + 's1nd0vL=e3vjb0oaf9vijiqsg7cml4i7fdkq16db; expires=Wed, 05-Oct-2022 14:54:16 GMT; Max-Age=7200; path=/; HttpOnly' + ] + } + const englishHeaders = { + 'set-cookie': [ + 's1nd0vL=hfd6hpnpr6gvgart0d8rf7ef6t4gi7nr; expires=Wed, 05-Oct-2022 15:08:55 GMT; Max-Age=7200; path=/; HttpOnly' + ] + } + axios.get.mockImplementation((url, opts) => { if ( url === 'https://www.mncvision.id/schedule/table/startno/50' && - options.headers && - options.headers['Cookie'] === setCookie.join(';') + opts.headers['Cookie'] === headers['set-cookie'][0] ) { return Promise.resolve({ - data: content50 + data: fs.readFileSync(path.resolve(__dirname, '__data__/content_p2.html')) }) } else if (url === 'https://www.mncvision.id/language_switcher/setlang/indonesia/') { return Promise.resolve({ - headers: { - 'set-cookie': setLangCookie - } - }) - } else if ( - url === 'https://www.mncvision.id/schedule/detail/2022030500000041/Hey-Duggee-S3-Ep-22/1' && - options.headers && - options.headers['X-Requested-With'] === 'XMLHttpRequest' && - options.headers['Cookie'] === setLangCookie.join(';') - ) { - return Promise.resolve({ - data: `
- Nikmati suasana kehidupan koloni anjing laut di kawasan pantai barat Afrika Selatan.
` - }) - } - - return Promise.resolve({ data: '' }) - }) - - parser({ date, content: content0, headers: { 'set-cookie': setCookie }, channel: channelID }) - .then(result => { - result = result.map(p => { - p.start = p.start.toJSON() - p.stop = p.stop.toJSON() - return p - }) - - expect(result).toMatchObject([ - { - start: '2021-11-11T17:00:00.000Z', - stop: '2021-11-11T17:07:00.000Z', - title: 'Hey Duggee S3, Ep 22', - description: - 'Nikmati suasana kehidupan koloni anjing laut di kawasan pantai barat Afrika Selatan.' - }, - { - start: '2021-11-12T01:25:00.000Z', - stop: '2021-11-12T01:32:00.000Z', - title: 'Hey Duggee S1, Ep 46', - description: null - } - ]) - done() - }) - .catch(error => { - done(error) - }) -}) - -it('can parse response in English', done => { - const setLangCookie = [ - 's1nd0vL=4li9qu3olhjl9djrl971opl2tgb27p1v; expires=Fri, 11-Mar-2022 14:26:55 GMT; Max-Age=7200; path=/; HttpOnly' - ] - - axios.get.mockImplementation((url, options = {}) => { - if ( - url === 'https://www.mncvision.id/schedule/table/startno/50' && - options.headers && - options.headers['Cookie'] === setCookie.join(';') - ) { - return Promise.resolve({ - data: content50 + headers: indonesiaHeaders }) } else if (url === 'https://www.mncvision.id/language_switcher/setlang/english/') { return Promise.resolve({ - headers: { - 'set-cookie': setLangCookie - } + headers: englishHeaders }) } else if ( - url === 'https://www.mncvision.id/schedule/detail/2022030500000041/Hey-Duggee-S3-Ep-22/1' && - options.headers && - options.headers['X-Requested-With'] === 'XMLHttpRequest' && - options.headers['Cookie'] === setLangCookie.join(';') + url === + 'https://mncvision.id/schedule/detail/2022100500000038/Adventures-With-Miao-Mi-Ep-1/1' && + opts.headers['Cookie'] === indonesiaHeaders['set-cookie'][0] ) { return Promise.resolve({ - data: `
- While Castiel investigates the disappearance of a local teen, Sam and Dean are visited by an old friend.
` + data: fs.readFileSync(path.resolve(__dirname, '__data__/program_id.html')) + }) + } else if ( + url === + 'https://mncvision.id/schedule/detail/2022100500000038/Adventures-With-Miao-Mi-Ep-1/1' && + opts.headers['Cookie'] === englishHeaders['set-cookie'][0] + ) { + return Promise.resolve({ + data: fs.readFileSync(path.resolve(__dirname, '__data__/program_en.html')) }) } return Promise.resolve({ data: '' }) }) - parser({ date, content: content0, headers: { 'set-cookie': setCookie }, channel: channelEN }) - .then(result => { - result = result.map(p => { - p.start = p.start.toJSON() - p.stop = p.stop.toJSON() - return p - }) - - expect(result).toMatchObject([ - { - start: '2021-11-11T17:00:00.000Z', - stop: '2021-11-11T17:07:00.000Z', - title: 'Hey Duggee S3, Ep 22', - description: - 'While Castiel investigates the disappearance of a local teen, Sam and Dean are visited by an old friend.' - }, - { - start: '2021-11-12T01:25:00.000Z', - stop: '2021-11-12T01:32:00.000Z', - title: 'Hey Duggee S1, Ep 46', - description: null - } - ]) - done() - }) - .catch(error => { - done(error) - }) -}) - -it('can handle empty guide', done => { - parser({ - date, - channel: channelID, - content: ``, - headers: { 'set-cookie': setCookie } + let indonesiaResults = await parser({ date, content, channel, headers }) + indonesiaResults = indonesiaResults.map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(indonesiaResults[0]).toMatchObject({ + start: '2022-10-04T17:00:00.000Z', + stop: '2022-10-04T17:06:00.000Z', + title: 'Adventures With Miao Mi, Ep 1', + episode: 1, + description: + 'Ketika anak-anak mulai menghilang, sekelompok anak kecil harus menghadapi ketakutan terbesar mereka ketika mereka melawan sesosok badut pembunuh yang jahat.' + }) + + expect(indonesiaResults[4]).toMatchObject({ + start: '2022-10-04T17:33:00.000Z', + stop: '2022-10-04T17:46:00.000Z', + title: 'Leo Wildlife Ranger S2, Ep 27', + season: 2, + episode: 27 + }) + + let englishResults = await parser({ date, content, channel: { ...channel, lang: 'en' }, headers }) + englishResults = englishResults.map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(englishResults[0]).toMatchObject({ + start: '2022-10-04T17:00:00.000Z', + stop: '2022-10-04T17:06:00.000Z', + title: 'Adventures With Miao Mi, Ep 1', + episode: 1, + description: + 'When children begin to disappear, a group of young kids have to face their biggest fears when they square off against a murderous, evil clown.' }) - .then(result => { - expect(result).toMatchObject([]) - done() - }) - .catch(error => { - done(error) - }) +}) + +it('can handle empty guide', async () => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html')) + let results = await parser({ + date, + channel, + content, + headers + }) + expect(results).toMatchObject([]) }) diff --git a/sites/mncvision.id/mncvision.id_id-en.channels.xml b/sites/mncvision.id/mncvision.id_id-en.channels.xml index ddc6b0d9..ca05e2bd 100644 --- a/sites/mncvision.id/mncvision.id_id-en.channels.xml +++ b/sites/mncvision.id/mncvision.id_id-en.channels.xml @@ -49,9 +49,9 @@ Hits Hits Movies IDX Channel + Ie IMC Indosiar - Ie INews Jak TV Kids TV @@ -92,8 +92,8 @@ TLC Southeast Asia Trans 7 Trans TV - TVN Movies Indonesia TVN Premium Indonesia + TVN Movies Indonesia TVOne TVRI Nasional Vision Prime diff --git a/sites/mncvision.id/mncvision.id_id-id.channels.xml b/sites/mncvision.id/mncvision.id_id-id.channels.xml index 8ef2af26..36252553 100644 --- a/sites/mncvision.id/mncvision.id_id-id.channels.xml +++ b/sites/mncvision.id/mncvision.id_id-id.channels.xml @@ -49,9 +49,9 @@ Hits Hits Movies IDX Channel + Ie IMC Indosiar - Ie INews Jak TV Kids TV @@ -92,8 +92,8 @@ TLC Trans 7 Trans TV - TVN Movies Indonesia TVN Premium Indonesia + TVN Movies Indonesia TVOne TVRI Nasional Vision Prime