diff --git a/sites/cablego.com.pe/cablego.com.pe.channels.xml b/sites/cablego.com.pe/cablego.com.pe.channels.xml index 71f22746..21514dec 100644 --- a/sites/cablego.com.pe/cablego.com.pe.channels.xml +++ b/sites/cablego.com.pe/cablego.com.pe.channels.xml @@ -1,94 +1,98 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AMERICA TV + ATV ATV+ BHTV CONECTA2 TV CONGRESO TV DE PELICULA - DISTRITO COMEDIA ECUADOR TV EUROPA EUROPA EXITOSA TV GLOBAL GOLDEN EDGE - KARIBEÑA LATINA NATIVA - OVACION PANAMERICANA TV PASIONES PBO diff --git a/sites/cablego.com.pe/cablego.com.pe.config.js b/sites/cablego.com.pe/cablego.com.pe.config.js index 5789fb37..9a0d247d 100644 --- a/sites/cablego.com.pe/cablego.com.pe.config.js +++ b/sites/cablego.com.pe/cablego.com.pe.config.js @@ -15,7 +15,8 @@ module.exports = { request: { method: 'POST', headers: { - 'x-requested-with': 'XMLHttpRequest' + 'x-requested-with': 'XMLHttpRequest', + cookie: '_nss=1' }, cache: { ttl: 60 * 60 * 1000 // 1 hour @@ -54,35 +55,33 @@ module.exports = { return programs }, async channels() { - const promises = [0, 1, 2, 3, 4].map(page => { - return axios.post( - `https://cablego.com.pe/epg/default/2022-11-28?page=${page}&do=loadPage`, - null, - { - headers: { - 'x-requested-with': 'XMLHttpRequest' - } - } - ) - }) + const pages = [0, 1, 2, 3, 4] - const channels = [] - await Promise.allSettled(promises).then(results => { - results.forEach((r, page) => { - if (r.status === 'fulfilled') { - const html = r.value.data.snippets['snippet--channelGrid'] - const $ = cheerio.load(html) - $('.epg-channel-strip').each((i, el) => { - const channelId = $(el).find('.epg-channel-logo').attr('id') - channels.push({ - lang: 'es', - site_id: `${page}#${channelId}`, - name: $(el).find('img').attr('alt') - }) - }) - } + let channels = [] + for (const page of pages) { + const url = `https://cablego.com.pe/epg/default/${dayjs().format( + 'YYYY-MM-DD' + )}?page=${page}&do=loadPage` + const data = await axios + .post(url, null, { + headers: { + 'x-requested-with': 'XMLHttpRequest', + cookie: '_nss=1' + } + }) + .then(r => r.data) + .catch(console.log) + + const $ = cheerio.load(data.snippets['snippet--channelGrid']) + $('.epg-channel-strip').each((i, el) => { + const channelId = $(el).find('.epg-channel-logo').attr('id') + channels.push({ + lang: 'es', + site_id: `${page}#${channelId}`, + name: $(el).find('img').attr('alt') + }) }) - }) + } return channels }