mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
62 lines
1.8 KiB
JavaScript
62 lines
1.8 KiB
JavaScript
const jsdom = require('jsdom')
|
|
const { JSDOM } = jsdom
|
|
const dayjs = require('dayjs')
|
|
const utc = require('dayjs/plugin/utc')
|
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
|
|
|
dayjs.extend(utc)
|
|
dayjs.extend(customParseFormat)
|
|
|
|
module.exports = {
|
|
lang: 'es',
|
|
site: 'comteco.com.bo',
|
|
channels: 'comteco.com.bo.channels.xml',
|
|
output: '.gh-pages/guides/comteco.com.bo.guide.xml',
|
|
url: function ({ channel }) {
|
|
return `https://comteco.com.bo/pages/canales-y-programacion-tv/paquete-oro/${channel.site_id}`
|
|
},
|
|
logo: function ({ content }) {
|
|
const dom = new JSDOM(content)
|
|
const img = dom.window.document.querySelector(
|
|
'#myform > div.row > div:nth-child(1) > div.col-xs-5.col-sm-7 > img'
|
|
)
|
|
|
|
return img ? `https://comteco.com.bo${img.src}` : null
|
|
},
|
|
parser: function ({ content, date }) {
|
|
const programs = []
|
|
const dom = new JSDOM(content)
|
|
const items = dom.window.document.querySelectorAll('#datosasociados > div > .list-group-item')
|
|
items.forEach(item => {
|
|
const time = (
|
|
item.querySelector('div > div.col-xs-11 > p > span') || { textContent: '' }
|
|
).textContent
|
|
.toString()
|
|
.trim()
|
|
const title = (
|
|
item.querySelector('div > div.col-xs-11 > p > strong') || { textContent: '' }
|
|
).textContent
|
|
.toString()
|
|
.trim()
|
|
|
|
if (time && title) {
|
|
const start = dayjs
|
|
.utc(time, 'HH:mm:ss')
|
|
.set('D', date.get('D'))
|
|
.set('M', date.get('M'))
|
|
.set('y', date.get('y'))
|
|
|
|
if (programs.length && !programs[programs.length - 1].stop) {
|
|
programs[programs.length - 1].stop = start
|
|
}
|
|
|
|
programs.push({
|
|
title,
|
|
start: start.toString()
|
|
})
|
|
}
|
|
})
|
|
|
|
return programs
|
|
}
|
|
}
|