mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Update comteco.com.bo.config.js
This commit is contained in:
parent
b15d50eaec
commit
1ab112f864
1 changed files with 30 additions and 31 deletions
|
@ -1,5 +1,4 @@
|
||||||
const jsdom = require('jsdom')
|
const cheerio = require('cheerio')
|
||||||
const { JSDOM } = jsdom
|
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
const timezone = require('dayjs/plugin/timezone')
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
|
@ -11,8 +10,14 @@ dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'comteco.com.bo',
|
site: 'comteco.com.bo',
|
||||||
|
url: function ({ channel }) {
|
||||||
|
return `https://comteco.com.bo/pages/canales-y-programacion-tv/paquete-oro/${channel.site_id}`
|
||||||
|
},
|
||||||
request: {
|
request: {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
},
|
||||||
data: function ({ date }) {
|
data: function ({ date }) {
|
||||||
const params = new URLSearchParams()
|
const params = new URLSearchParams()
|
||||||
params.append('_method', 'POST')
|
params.append('_method', 'POST')
|
||||||
|
@ -20,57 +25,51 @@ module.exports = {
|
||||||
params.append('fechafin', date.format('D/M/YYYY'))
|
params.append('fechafin', date.format('D/M/YYYY'))
|
||||||
|
|
||||||
return params
|
return params
|
||||||
},
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
url: function ({ channel }) {
|
|
||||||
return `https://comteco.com.bo/pages/canales-y-programacion-tv/paquete-oro/${channel.site_id}`
|
|
||||||
},
|
|
||||||
logo: function ({ content }) {
|
logo: function ({ content }) {
|
||||||
const dom = new JSDOM(content)
|
const $ = cheerio.load(content)
|
||||||
const img = dom.window.document.querySelector(
|
const imgSrc = $('#myform > div.row > div:nth-child(1) > div.col-xs-5.col-sm-7 > img').attr(
|
||||||
'#myform > div.row > div:nth-child(1) > div.col-xs-5.col-sm-7 > img'
|
'src'
|
||||||
)
|
)
|
||||||
|
|
||||||
return img ? `https://comteco.com.bo${img.src}` : null
|
return imgSrc ? `https://comteco.com.bo${imgSrc}` : null
|
||||||
},
|
},
|
||||||
parser: function ({ content, date }) {
|
parser: function ({ content, date }) {
|
||||||
const programs = []
|
const programs = []
|
||||||
const items = parseItems(content)
|
const items = parseItems(content)
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
const title = parseTitle(item)
|
const prev = programs[programs.length - 1]
|
||||||
let start = parseStart(item, date)
|
const $item = cheerio.load(item)
|
||||||
const stop = start.add(30, 'm')
|
let start = parseStart($item, date)
|
||||||
if (programs.length) {
|
if (prev) {
|
||||||
programs[programs.length - 1].stop = start
|
if (start.isBefore(prev.start)) {
|
||||||
|
start = start.add(1, 'd')
|
||||||
|
date = date.add(1, 'd')
|
||||||
|
}
|
||||||
|
prev.stop = start
|
||||||
}
|
}
|
||||||
|
const stop = start.add(30, 'm')
|
||||||
programs.push({ title, start, stop })
|
programs.push({ title: parseTitle($item), start, stop })
|
||||||
})
|
})
|
||||||
|
|
||||||
return programs
|
return programs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStart(item, date) {
|
function parseStart($item, date) {
|
||||||
let time = (
|
const timeString = $item('div > div.col-xs-11 > p > span').text().trim()
|
||||||
item.querySelector('div > div.col-xs-11 > p > span') || { textContent: '' }
|
const dateString = `${date.format('YYYY-MM-DD')} ${timeString}`
|
||||||
).textContent.trim()
|
|
||||||
time = `${date.format('MM/DD/YYYY')} ${time}`
|
|
||||||
|
|
||||||
return dayjs.tz(time, 'MM/DD/YYYY HH:mm:ss', 'America/La_Paz')
|
return dayjs.tz(dateString, 'YYYY-MM-DD HH:mm:ss', 'America/La_Paz')
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseTitle(item) {
|
function parseTitle($item) {
|
||||||
return (
|
return $item('div > div.col-xs-11 > p > strong').text().trim()
|
||||||
item.querySelector('div > div.col-xs-11 > p > strong') || { textContent: '' }
|
|
||||||
).textContent.trim()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItems(content) {
|
function parseItems(content) {
|
||||||
const dom = new JSDOM(content)
|
const $ = cheerio.load(content)
|
||||||
|
|
||||||
return dom.window.document.querySelectorAll('#datosasociados > div > .list-group-item')
|
return $('#datosasociados > div > .list-group-item').toArray()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue