mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update mncvision.id.config.js
This commit is contained in:
parent
3bd16933fc
commit
16f91db4bf
1 changed files with 28 additions and 11 deletions
|
@ -30,30 +30,26 @@ module.exports = {
|
|||
'Content-Type': 'multipart/form-data; boundary=X-EPG-BOUNDARY'
|
||||
}
|
||||
},
|
||||
async parser({ content, date, headers }) {
|
||||
async parser({ content, date, headers, channel }) {
|
||||
const 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) {
|
||||
const nextContent = await axios
|
||||
.get(url, {
|
||||
headers: {
|
||||
Cookie: cookies
|
||||
}
|
||||
})
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
items = items.concat(parseItems(nextContent))
|
||||
items = items.concat(parseItems(await loadNextPage(url, cookies)))
|
||||
}
|
||||
|
||||
const langCookies = await loadLangCookies(channel)
|
||||
|
||||
for (const item of items) {
|
||||
const start = parseStart(item, date)
|
||||
const duration = parseDuration(item)
|
||||
const stop = start.add(duration, 'm')
|
||||
programs.push({
|
||||
title: parseTitle(item),
|
||||
description: await loadDescription(item, cookies),
|
||||
description: await loadDescription(item, langCookies),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
|
@ -83,6 +79,27 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
|
||||
async function loadNextPage(url, cookies) {
|
||||
return axios
|
||||
.get(url, {
|
||||
headers: {
|
||||
Cookie: cookies
|
||||
}
|
||||
})
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
}
|
||||
|
||||
async function loadLangCookies(channel) {
|
||||
const lang = channel.lang === 'en' ? 'english' : 'indonesia'
|
||||
const url = `https://www.mncvision.id/language_switcher/setlang/${lang}/`
|
||||
|
||||
return axios
|
||||
.get(url)
|
||||
.then(r => r.headers['set-cookie'].join(';'))
|
||||
.catch(console.error)
|
||||
}
|
||||
|
||||
async function loadDescription(item, cookies) {
|
||||
const $item = cheerio.load(item)
|
||||
const progUrl = $item('a').attr('href')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue