mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Merge pull request #577 from iptv-org/fix-mncvision.id
Update mncvision.id
This commit is contained in:
commit
10eef6cae3
4 changed files with 79 additions and 50 deletions
14
package-lock.json
generated
14
package-lock.json
generated
|
@ -13,7 +13,7 @@
|
||||||
"commander": "^8.2.0",
|
"commander": "^8.2.0",
|
||||||
"csv-parser": "^3.0.0",
|
"csv-parser": "^3.0.0",
|
||||||
"dayjs": "^1.10.4",
|
"dayjs": "^1.10.4",
|
||||||
"epg-grabber": "^0.20.0",
|
"epg-grabber": "^0.21.0",
|
||||||
"epg-parser": "^0.1.6",
|
"epg-parser": "^0.1.6",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"fs-extra": "^10.0.1",
|
"fs-extra": "^10.0.1",
|
||||||
|
@ -2198,9 +2198,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/epg-grabber": {
|
"node_modules/epg-grabber": {
|
||||||
"version": "0.20.0",
|
"version": "0.21.0",
|
||||||
"resolved": "https://registry.npmjs.org/epg-grabber/-/epg-grabber-0.20.0.tgz",
|
"resolved": "https://registry.npmjs.org/epg-grabber/-/epg-grabber-0.21.0.tgz",
|
||||||
"integrity": "sha512-6xmz1AfYKDduEjZqQlYyacR41fb8ITDymORyOcKmTdCs9XXrofYL84lULkEmhsNfksAuPf5hMef/uFptbDh/GA==",
|
"integrity": "sha512-8H+xUp521vFKkL7m3vefWpC00UQULYHfyWm+TNGXsFPYXSQ4Mke0647Vzp5RmnH1tHcIzxGON/s580tdM56WTw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"axios-cookiejar-support": "^1.0.1",
|
"axios-cookiejar-support": "^1.0.1",
|
||||||
|
@ -7556,9 +7556,9 @@
|
||||||
"integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A=="
|
"integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A=="
|
||||||
},
|
},
|
||||||
"epg-grabber": {
|
"epg-grabber": {
|
||||||
"version": "0.20.0",
|
"version": "0.21.0",
|
||||||
"resolved": "https://registry.npmjs.org/epg-grabber/-/epg-grabber-0.20.0.tgz",
|
"resolved": "https://registry.npmjs.org/epg-grabber/-/epg-grabber-0.21.0.tgz",
|
||||||
"integrity": "sha512-6xmz1AfYKDduEjZqQlYyacR41fb8ITDymORyOcKmTdCs9XXrofYL84lULkEmhsNfksAuPf5hMef/uFptbDh/GA==",
|
"integrity": "sha512-8H+xUp521vFKkL7m3vefWpC00UQULYHfyWm+TNGXsFPYXSQ4Mke0647Vzp5RmnH1tHcIzxGON/s580tdM56WTw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"axios-cookiejar-support": "^1.0.1",
|
"axios-cookiejar-support": "^1.0.1",
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
"commander": "^8.2.0",
|
"commander": "^8.2.0",
|
||||||
"csv-parser": "^3.0.0",
|
"csv-parser": "^3.0.0",
|
||||||
"dayjs": "^1.10.4",
|
"dayjs": "^1.10.4",
|
||||||
"epg-grabber": "^0.20.0",
|
"epg-grabber": "^0.21.0",
|
||||||
"epg-parser": "^0.1.6",
|
"epg-parser": "^0.1.6",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"fs-extra": "^10.0.1",
|
"fs-extra": "^10.0.1",
|
||||||
|
|
|
@ -12,7 +12,7 @@ dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'mncvision.id',
|
site: 'mncvision.id',
|
||||||
url: `https://mncvision.id/schedule/table`,
|
url: 'https://mncvision.id/schedule/table',
|
||||||
request: {
|
request: {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: function ({ channel, date }) {
|
data: function ({ channel, date }) {
|
||||||
|
@ -30,21 +30,33 @@ module.exports = {
|
||||||
'Content-Type': 'multipart/form-data; boundary=X-EPG-BOUNDARY'
|
'Content-Type': 'multipart/form-data; boundary=X-EPG-BOUNDARY'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async parser({ content, date }) {
|
async parser({ content, date, headers }) {
|
||||||
const programs = []
|
const programs = []
|
||||||
const items = parseItems(content)
|
|
||||||
|
let items = parseItems(content)
|
||||||
|
const pages = parsePages(content)
|
||||||
|
const cookies = headers && headers['set-cookie'] ? headers['set-cookie'].join(';') : ''
|
||||||
|
for (let url of pages) {
|
||||||
|
const nextContent = await axios
|
||||||
|
.get(url, {
|
||||||
|
headers: {
|
||||||
|
Cookie: cookies
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(r => r.data)
|
||||||
|
.catch(console.log)
|
||||||
|
items = items.concat(parseItems(nextContent))
|
||||||
|
}
|
||||||
|
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
const title = parseTitle(item)
|
|
||||||
const start = parseStart(item, date)
|
const start = parseStart(item, date)
|
||||||
const duration = parseDuration(item)
|
const duration = parseDuration(item)
|
||||||
const stop = start.add(duration, 'm')
|
const stop = start.add(duration, 'm')
|
||||||
const description = await loadDescription(item)
|
|
||||||
|
|
||||||
programs.push({
|
programs.push({
|
||||||
title,
|
title: parseTitle(item),
|
||||||
description,
|
description: await loadDescription(item),
|
||||||
start: start.toJSON(),
|
start,
|
||||||
stop: stop.toJSON()
|
stop
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,3 +129,16 @@ function parseItems(content) {
|
||||||
|
|
||||||
return $('tr[valign="top"]').toArray()
|
return $('tr[valign="top"]').toArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parsePages(content) {
|
||||||
|
const $ = cheerio.load(content)
|
||||||
|
const links = $('#schedule > div.schedule_search_result_container > div.box.well > a').toArray()
|
||||||
|
|
||||||
|
const pages = {}
|
||||||
|
for (let link of links) {
|
||||||
|
const url = $(link).attr('href')
|
||||||
|
pages[url] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
return Object.keys(pages)
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// node ./scripts/channels.js --config=./sites/mncvision.id/mncvision.id.config.js --output=./sites/mncvision.id/mncvision.id_id.channels.xml
|
// 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.channels.xml --output=.gh-pages/guides/id/mncvision.id.epg.xml --days=2
|
// npx epg-grabber --config=sites/mncvision.id/mncvision.id.config.js --channels=sites/mncvision.id/mncvision.id_id.channels.xml --output=guide.xml --days=2
|
||||||
|
|
||||||
const { parser, url, request } = require('./mncvision.id.config.js')
|
const { parser, url, request } = require('./mncvision.id.config.js')
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
|
@ -16,7 +16,11 @@ const channel = {
|
||||||
site_id: '203',
|
site_id: '203',
|
||||||
xmltv_id: 'AnimalPlanetSoutheastAsia.us'
|
xmltv_id: 'AnimalPlanetSoutheastAsia.us'
|
||||||
}
|
}
|
||||||
const content = `<!DOCTYPE html><html lang="en"><head></head><body> <table class="table table-striped table-bordered table-hover table-condensed" cellspacing="0" cellpadding="0" border="0"> <tr> <th width='10%'>Jam Tayang</th> <th width='80%' align='left'>Program Acara</th> <th width='10%'>Durasi</th> </tr><tr valign="top"> <td class="text-center">00:00</td><td><a href="https://mncvision.id/schedule/detail/20211112000000203/African-Wild-S1-Seals/1" title="African Wild S1: Seals" rel="facebox">African Wild S1: Seals</a></td><td class="text-center">01:00</td></tr></table></body></html>`
|
const setCookie = [
|
||||||
|
's1nd0vL=0qpsmm7dpjmi7nt8d2h5epf16rmgg8a8; expires=Sat, 05-Mar-2022 15:44:22 GMT; Max-Age=7200; path=/; HttpOnly'
|
||||||
|
]
|
||||||
|
const content0 = `<!DOCTYPE html><html lang="en"> <head></head> <body> <div id="id-content-schedule-table" class="lang-indonesia tm-content-container"> <div class="container content-schedule-table"> <h1 class="page-header tm">Jadwal Tayang Cari</h1> <div id="schedule" class="schedule_table panel tm tm-block tm-block-1"> <div class="schedule_search_result_container"> <div class='schedule_search_desc_container'><span class="subpage-title">Jadwal Tayang</span> Channel: <span class='label label-default'>41</span> Tanggal: <span class='label label-default'>2022-03-05</span></div><table class="table table-striped table-bordered table-hover table-condensed" cellspacing="0" cellpadding="0" border="0"> <tr> <th width='10%'>Jam Tayang</th> <th width='80%' align='left'>Program Acara</th> <th width='10%'>Durasi</th> </tr><tr valign="top"> <td class="text-center">00:00</td><td><a href="https://www.mncvision.id/schedule/detail/2022030500000041/Hey-Duggee-S3-Ep-22/1" title="Hey Duggee S3, Ep 22" rel="facebox">Hey Duggee S3, Ep 22</a></td><td class="text-center">00:07</td></tr></table> <div align="center" class="box well">page: <strong>1</strong><a href="https://www.mncvision.id/schedule/table/startno/50" data-ci-pagination-page="2">2</a><a href="https://www.mncvision.id/schedule/table/startno/50" data-ci-pagination-page="2" rel="next">></a></div></div></div></div></div></body></html>`
|
||||||
|
const content50 = `<!DOCTYPE html><html lang="en"> <head></head> <body> <div id="id-content-schedule-table" class="lang-indonesia tm-content-container"> <div class="container content-schedule-table"> <h1 class="page-header tm">Jadwal Tayang Cari</h1> <div id="schedule" class="schedule_table panel tm tm-block tm-block-1"> <div class="schedule_search_result_container"> <div class='schedule_search_desc_container'><span class="subpage-title">Jadwal Tayang</span> Channel: <span class='label label-default'>41</span> Tanggal: <span class='label label-default'>2022-03-05</span></div><table class="table table-striped table-bordered table-hover table-condensed" cellspacing="0" cellpadding="0" border="0"> <tr> <th width='10%'>Jam Tayang</th> <th width='80%' align='left'>Program Acara</th> <th width='10%'>Durasi</th> </tr><tr valign="top"> <td class="text-center">08:25</td><td><a href="https://www.mncvision.id/schedule/detail/2022030508250041/Hey-Duggee-S1-Ep-46/1" title="Hey Duggee S1, Ep 46" rel="facebox">Hey Duggee S1, Ep 46</a></td><td class="text-center">00:07</td></tr></table> <div align="center" class="box well">page: <a href="https://www.mncvision.id/schedule/table/startno/" data-ci-pagination-page="1" rel="prev"><</a><a href="https://www.mncvision.id/schedule/table/startno/" data-ci-pagination-page="1" rel="start">1</a><strong>2</strong><a href="https://www.mncvision.id/schedule/table/startno/100" data-ci-pagination-page="3" rel="next">></a></div></div></div></div></div></body></html>`
|
||||||
|
|
||||||
it('can generate valid url', () => {
|
it('can generate valid url', () => {
|
||||||
expect(url).toBe('https://mncvision.id/schedule/table')
|
expect(url).toBe('https://mncvision.id/schedule/table')
|
||||||
|
@ -34,45 +38,45 @@ it('can generate valid request data', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can parse response', done => {
|
it('can parse response', done => {
|
||||||
axios.get.mockImplementation(() =>
|
axios.get.mockImplementation((url, options = {}) => {
|
||||||
Promise.resolve({
|
if (url === 'https://www.mncvision.id/schedule/detail/2022030500000041/Hey-Duggee-S3-Ep-22/1') {
|
||||||
data: `<!DOCTYPE html><html lang="en"><head></head><body><blockquote class="bloquet synopsis">
|
return Promise.resolve({
|
||||||
|
data: `<!DOCTYPE html><html lang="en"><head></head><body><blockquote class="bloquet synopsis">
|
||||||
Nikmati suasana kehidupan koloni anjing laut di kawasan pantai barat Afrika Selatan. </blockquote></body></html>`
|
Nikmati suasana kehidupan koloni anjing laut di kawasan pantai barat Afrika Selatan. </blockquote></body></html>`
|
||||||
})
|
})
|
||||||
)
|
} else if (
|
||||||
|
url === 'https://www.mncvision.id/schedule/table/startno/50' &&
|
||||||
|
options.headers &&
|
||||||
|
options.headers['Cookie'] === setCookie.join(';')
|
||||||
|
) {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: content50
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
parser({ date, channel, content })
|
return Promise.resolve({ data: '' })
|
||||||
|
})
|
||||||
|
|
||||||
|
parser({ date, content: content0, headers: { 'set-cookie': setCookie } })
|
||||||
.then(result => {
|
.then(result => {
|
||||||
|
result = result.map(p => {
|
||||||
|
p.start = p.start.toJSON()
|
||||||
|
p.stop = p.stop.toJSON()
|
||||||
|
return p
|
||||||
|
})
|
||||||
|
|
||||||
expect(result).toMatchObject([
|
expect(result).toMatchObject([
|
||||||
{
|
{
|
||||||
start: '2021-11-11T17:00:00.000Z',
|
start: '2021-11-11T17:00:00.000Z',
|
||||||
stop: '2021-11-11T18:00:00.000Z',
|
stop: '2021-11-11T17:07:00.000Z',
|
||||||
title: 'African Wild S1: Seals',
|
title: 'Hey Duggee S3, Ep 22',
|
||||||
description:
|
description:
|
||||||
'Nikmati suasana kehidupan koloni anjing laut di kawasan pantai barat Afrika Selatan.'
|
'Nikmati suasana kehidupan koloni anjing laut di kawasan pantai barat Afrika Selatan.'
|
||||||
}
|
},
|
||||||
])
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
done(error)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('can parse response with empty description', done => {
|
|
||||||
axios.get.mockImplementation(() =>
|
|
||||||
Promise.resolve({
|
|
||||||
data: `<!DOCTYPE html><html lang="en"><head></head><body><blockquote class="bloquet synopsis"> - </blockquote></body></html>`
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
parser({ date, channel, content })
|
|
||||||
.then(result => {
|
|
||||||
expect(result).toMatchObject([
|
|
||||||
{
|
{
|
||||||
start: '2021-11-11T17:00:00.000Z',
|
start: '2021-11-12T01:25:00.000Z',
|
||||||
stop: '2021-11-11T18:00:00.000Z',
|
stop: '2021-11-12T01:32:00.000Z',
|
||||||
title: 'African Wild S1: Seals',
|
title: 'Hey Duggee S1, Ep 46',
|
||||||
description: null
|
description: null
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue