mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Merge pull request #1421 from iptv-org/add-cablego.com.pe
Add guide from cablego.com.pe
This commit is contained in:
commit
a30b6501ac
6 changed files with 282 additions and 0 deletions
17
.github/workflows/cablego.com.pe.yml
vendored
Normal file
17
.github/workflows/cablego.com.pe.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
name: cablego.com.pe
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 3 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
workflow_run:
|
||||||
|
workflows: [_trigger]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
jobs:
|
||||||
|
load:
|
||||||
|
uses: ./.github/workflows/_load.yml
|
||||||
|
with:
|
||||||
|
site: ${{github.workflow}}
|
||||||
|
secrets:
|
||||||
|
APP_ID: ${{ secrets.APP_ID }}
|
||||||
|
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
|
1
sites/cablego.com.pe/__data__/content.json
Normal file
1
sites/cablego.com.pe/__data__/content.json
Normal file
File diff suppressed because one or more lines are too long
1
sites/cablego.com.pe/__data__/no_content.json
Normal file
1
sites/cablego.com.pe/__data__/no_content.json
Normal file
File diff suppressed because one or more lines are too long
108
sites/cablego.com.pe/cablego.com.pe.config.js
Normal file
108
sites/cablego.com.pe/cablego.com.pe.config.js
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const axios = require('axios')
|
||||||
|
const cheerio = require('cheerio')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
|
|
||||||
|
dayjs.extend(utc)
|
||||||
|
dayjs.extend(timezone)
|
||||||
|
dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'cablego.com.pe',
|
||||||
|
request: {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'x-requested-with': 'XMLHttpRequest'
|
||||||
|
},
|
||||||
|
cache: {
|
||||||
|
ttl: 60 * 60 * 1000 // 1 hour
|
||||||
|
}
|
||||||
|
},
|
||||||
|
url({ channel, date }) {
|
||||||
|
const [page] = channel.site_id.split('#')
|
||||||
|
|
||||||
|
return `https://cablego.com.pe/epg/default/${date.format(
|
||||||
|
'YYYY-MM-DD'
|
||||||
|
)}?page=${page}&do=loadPage`
|
||||||
|
},
|
||||||
|
parser: function ({ content, channel, date }) {
|
||||||
|
let programs = []
|
||||||
|
const items = parseItems(content, channel)
|
||||||
|
items.forEach(item => {
|
||||||
|
const $item = cheerio.load(item)
|
||||||
|
const prev = programs[programs.length - 1]
|
||||||
|
let start = parseStart($item, date)
|
||||||
|
if (!start) return
|
||||||
|
if (prev) {
|
||||||
|
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: parseTitle($item),
|
||||||
|
start,
|
||||||
|
stop
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
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 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')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return channels
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseTitle($item) {
|
||||||
|
return $item('span:nth-child(2) > a').text().trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStart($item, date) {
|
||||||
|
const time = $item('.epg-show-start').text().trim()
|
||||||
|
|
||||||
|
return dayjs.tz(`${date.format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm', 'America/Lima')
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content, channel) {
|
||||||
|
const [, channelId] = channel.site_id.split('#')
|
||||||
|
const data = JSON.parse(content)
|
||||||
|
if (!data || !data.snippets || !data.snippets['snippet--channelGrid']) return []
|
||||||
|
const html = data.snippets['snippet--channelGrid']
|
||||||
|
const $ = cheerio.load(html)
|
||||||
|
|
||||||
|
return $(`#${channelId}`).parent().find('.epg-show').toArray()
|
||||||
|
}
|
54
sites/cablego.com.pe/cablego.com.pe.test.js
Normal file
54
sites/cablego.com.pe/cablego.com.pe.test.js
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
// npm run channels:parse -- --config=./sites/cablego.com.pe/cablego.com.pe.config.js --output=./sites/cablego.com.pe/cablego.com.pe_pe.channels.xml
|
||||||
|
// npx epg-grabber --config=sites/cablego.com.pe/cablego.com.pe.config.js --channels=sites/cablego.com.pe/cablego.com.pe_pe.channels.xml --output=guide.xml --days=2
|
||||||
|
|
||||||
|
const { parser, url, request } = require('./cablego.com.pe.config.js')
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
|
dayjs.extend(customParseFormat)
|
||||||
|
dayjs.extend(utc)
|
||||||
|
|
||||||
|
const date = dayjs.utc('2022-11-28', 'YYYY-MM-DD').startOf('d')
|
||||||
|
const channel = {
|
||||||
|
site_id: '0#LATINA',
|
||||||
|
xmltv_id: 'Latina.pe'
|
||||||
|
}
|
||||||
|
|
||||||
|
it('can generate valid url', () => {
|
||||||
|
expect(url({ channel, date })).toBe(
|
||||||
|
'https://cablego.com.pe/epg/default/2022-11-28?page=0&do=loadPage'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can generate valid request method', () => {
|
||||||
|
expect(request.method).toBe('POST')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can generate valid request headers', () => {
|
||||||
|
expect(request.headers).toMatchObject({
|
||||||
|
'x-requested-with': 'XMLHttpRequest'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can parse response', () => {
|
||||||
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||||
|
let results = parser({ content, channel, date }).map(p => {
|
||||||
|
p.start = p.start.toJSON()
|
||||||
|
p.stop = p.stop.toJSON()
|
||||||
|
return p
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(results[0]).toMatchObject({
|
||||||
|
start: '2022-11-28T05:00:00.000Z',
|
||||||
|
stop: '2022-11-28T06:30:00.000Z',
|
||||||
|
title: 'Especiales Qatar'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can handle empty guide', () => {
|
||||||
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'))
|
||||||
|
const result = parser({ content, channel, date })
|
||||||
|
expect(result).toMatchObject([])
|
||||||
|
})
|
101
sites/cablego.com.pe/cablego.com.pe_pe.channels.xml
Normal file
101
sites/cablego.com.pe/cablego.com.pe_pe.channels.xml
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<site site="cablego.com.pe">
|
||||||
|
<channels>
|
||||||
|
<channel lang="es" xmltv_id="AmericaTelevision.pe" site_id="4#AMERICATV">AMERICA TV</channel>
|
||||||
|
<channel lang="es" xmltv_id="ATV.pe" site_id="0#ATVHD">ATV</channel>
|
||||||
|
<channel lang="es" xmltv_id="ATVPlus.pe" site_id="0#ATVMAS">ATV+</channel>
|
||||||
|
<channel lang="es" xmltv_id="BHTV.pe" site_id="0#BHTV">BHTV</channel>
|
||||||
|
<channel lang="es" xmltv_id="Conecta2TV.pe" site_id="0#CONECTA2">CONECTA2 TV</channel>
|
||||||
|
<channel lang="es" xmltv_id="CongresoTV.pe" site_id="0#CANALCONGRESO">CONGRESO TV</channel>
|
||||||
|
<channel lang="es" xmltv_id="DePeliculaLatinAmerica.mx" site_id="1#DEPELICULA">DE PELICULA</channel>
|
||||||
|
<channel lang="es" xmltv_id="DistritoComedia.mx" site_id="2#DISTRITOCOMEDIA">DISTRITO COMEDIA</channel>
|
||||||
|
<channel lang="es" xmltv_id="EcuadorTV.ec" site_id="4#ECUADORTV">ECUADOR TV</channel>
|
||||||
|
<channel lang="es" xmltv_id="EuropaEuropa.ar" site_id="1#EUROPAEUROPA">EUROPA EUROPA</channel>
|
||||||
|
<channel lang="es" xmltv_id="ExitosaTV.pe" site_id="0#EXITOSATV">EXITOSA TV</channel>
|
||||||
|
<channel lang="es" xmltv_id="GlobalTV.pe" site_id="0#GLOBAL">GLOBAL</channel>
|
||||||
|
<channel lang="es" xmltv_id="GoldenEdgePanregional.mx" site_id="1#GOLDENEDGE">GOLDEN EDGE</channel>
|
||||||
|
<channel lang="es" xmltv_id="Karibena.pe" site_id="3#KARIBENA">KARIBEÑA</channel>
|
||||||
|
<channel lang="es" xmltv_id="Latina.pe" site_id="0#LATINA">LATINA</channel>
|
||||||
|
<channel lang="es" xmltv_id="Nativa.pe" site_id="0#NATIVA">NATIVA</channel>
|
||||||
|
<channel lang="es" xmltv_id="OvacionTV.pe" site_id="3#OVACION">OVACION</channel>
|
||||||
|
<channel lang="es" xmltv_id="PanamericanaTV.pe" site_id="0#PANAMERICANATV">PANAMERICANA TV</channel>
|
||||||
|
<channel lang="es" xmltv_id="PasionesLatinAmerica.us" site_id="1#PASIONES">PASIONES</channel>
|
||||||
|
<channel lang="es" xmltv_id="PBO.pe" site_id="0#PBO">PBO</channel>
|
||||||
|
<channel lang="es" xmltv_id="TVPeru.pe" site_id="0#TVPERU">TV PERU</channel>
|
||||||
|
<channel lang="es" xmltv_id="USMPTV.pe" site_id="0#USMPTV">USMP TV</channel>
|
||||||
|
<channel lang="es" xmltv_id="Venus.ar" site_id="4#VENUS">VENUS</channel>
|
||||||
|
<channel lang="es" xmltv_id="WillaxTV.pe" site_id="0#WILLAX">WILLAX</channel>
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="0#AMC">AMC</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="0#CloverCH">CLOVER CHANNEL</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="0#FOXCHANNEL">STAR CHANNEL</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="0#FX">FX</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="0#ID">ID</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="0#PARAMOUNTCH">PARAMOUNT CHANNEL</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#ANIMALPLANET">ANIMAL PLANET</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#AZCINEMA">CINEMA INOLVIDABLE</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#AZCORAZON">CORAZON</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#CHESTRELLAS">CANAL DE LAS ESTRELLAS</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#CINECANAL">CINECANAL</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#DISCOVERYCHANNEL">DISCOVERY CHANNEL</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#DISCOVERYSCIENCE">DISCOVERY SCIENCE</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#DISCOVERYTHEATER">DISCOVERY THEATER</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#DISCOVERYTURBO">DISCOVERY TURBO</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#DISCOVERYWORLD">DISCOVERY WORLD</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#FILMSandARTS">FILMS & ARTS</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#GOLDENLATINO">GOLDEN LATINO</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#NATGEO">NATGEO</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#SONYMOVIES">SONY MOVIES</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#TELEMUNDO">TELEMUNDO</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="1#UNIVISION">UNIVISION</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#AZMUNDO">MUNDO</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#BITME">BITME</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#DISCOVERYKIDS">DISCOVERY KIDS</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#DISNEYCHANNEL">DISNEY CHANNEL</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#DISNEYJUNIOR">DISNEY JUNIOR</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#DREAMWORKS">DREAMWORKS</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#ESPN">ESPN</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#ESPN2">ESPN2</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#FOODNETWORK">FOOD NETWORK</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#GOURMET">GOURMET</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#HGTV">HGTV</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#HOMEANDHEALTH">HOME & HEALTH</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#KANALD">KANAL D</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#MASCHIC">MAS CHIC</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#NICKELODEON">NICKELODEON</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#NICKJR">NICK JR</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#TELENOVELAS">TELENOVELAS</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#TRAVELANDLIVING">TLC</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="2#ZOOMOO">ZOOMOO</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#ANTENA3">ANTENA 3</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#BANDAMAX">BANDAMAX</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#CGTN">CGTN</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#ESPN3">ESPN3</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#ESPNMAS">ESPN EXTRA</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#FOXSPORTS">ESPN4</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#FOXSPORTS2">FOX SPORTS 2</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#FOXSPORTS3">FOX SPORTS 3</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#IVCNETWORKS">IVC NETWORKS</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#LANACIONAL">LA NACIONAL</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#MTV">MTV</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#NICKMUSIC">NICKMUSIC</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#NOTICIASCARACOL">NOTICIAS CARACOL</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#SBTBRASIL">SBT Brasil</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#TELEFE">TELEFE</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#TELEHITLATINO">TELEHIT LATINO</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#TELEHITMUSICA">TELEHIT MUSICA</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="3#TRECEARGENTINA">TRECE ARGENTINA</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="4#AandEMUNDO">A&E</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="4#AXN">AXN</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="4#DW">DW</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="4#ECH">E!</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="4#HISTORY2">HISTORY 2</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="4#HISTORYCHANNEL">HISTORY CHANNEL</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="4#LIFETIME">LIFE TIME</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="4#PLAYBOY">PLAYBOY</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="4#SONY">SONY</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="4#STUDIOUNIVERSAL">STUDIO UNIVERSAL</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="4#SYFY">SYFY</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="4#UNIVERSAL">UNIVERSAL</channel> -->
|
||||||
|
<!-- <channel lang="es" xmltv_id="" site_id="4#WARNERCHANNEL">WARNER CH</channel> -->
|
||||||
|
</channels>
|
||||||
|
</site>
|
Loading…
Add table
Add a link
Reference in a new issue