Update gatotv.com.test.js

This commit is contained in:
Aleksandr Statciuk committed 2023-01-31 03:33:57 +03:00
1 parent adb89e208a
commit 9d460e2469
1 file changed
+33 -43
+33 -43
View File
@@ -1,72 +1,62 @@
// node ./scripts/channels.js --config=./sites/gatotv.com/gatotv.com.config.js --output=./sites/gatotv.com/gatotv.com_cr.channels.xml --set=country:costa_rica // npm run channels:parse -- --config=./sites/gatotv.com/gatotv.com.config.js --output=./sites/gatotv.com/gatotv.com.channels.xml
// npx epg-grabber --config=sites/gatotv.com/gatotv.com.config.js --channels=sites/gatotv.com/gatotv.com_ar.channels.xml --output=guide.xml --days=2 // npx epg-grabber --config=sites/gatotv.com/gatotv.com.config.js --channels=sites/gatotv.com/gatotv.com.channels.xml --output=guide.xml --days=2
const { parser, url, request } = require('./gatotv.com.config.js') const { parser, url, request } = require('./gatotv.com.config.js')
const fs = require('fs')
const path = require('path')
const dayjs = require('dayjs') const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc') const utc = require('dayjs/plugin/utc')
const customParseFormat = require('dayjs/plugin/customParseFormat') const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat) dayjs.extend(customParseFormat)
dayjs.extend(utc) dayjs.extend(utc)
const date = dayjs.utc('2021-11-13', 'YYYY-MM-DD').startOf('d') const date = dayjs.utc('2023-01-31', 'YYYY-MM-DD').startOf('d')
const channel = { const channel = {
site_id: '13_de_argentina', site_id: 'punto_2_puerto_rico',
xmltv_id: 'ElTrece.ar' xmltv_id: 'WKAQDT2.us'
} }
const content = `<html> <head></head> <body> <div class="div_content" itemscope="" itemtype="http://schema.org/TelevisionChannel"> <div class="div_SiteMap"></div><div class="div_Clock"></div><div class="div_Dark_Light_Mode"></div><div class="div_divisor"></div><div class="div_divisor"></div><table class="tbl_recommend"></table> <div class="div_divisor"></div><table style="width: 1015px"> <tbody> <tr></tr><tr> <td style="vertical-align: top; width: 677px"> <div class="div_MainDiv"> <div class="div_MainPicture"> <a href="https://www.gatotv.com/canal/13_de_argentina"> <picture> <source media="(prefers-color-scheme: dark)" title="Canal 13 de Argentina (El Trece)" srcset=" https://imagenes.gatotv.com/logos/canales/claros/13_de_argentina-mediano.png "/> <img src="https://imagenes.gatotv.com/logos/canales/oscuros/13_de_argentina-mediano.png" alt="Logo Canal 13 de Argentina (El Trece)" title="Canal 13 de Argentina (El Trece)" width="160" height="70"/> </picture> </a> </div></div><table class="tbl_EPG"> <tbody> <tr> <th id="horarios_de_programacion" class="tbl_EPG_th" colspan="8"> <h2>Horarios de Programación</h2> </th> </tr><tr> <th class="tbl_EPG_th0" colspan="1">Hora Inicio</th> <th class="tbl_EPG_th0" colspan="1">Hora Fin</th> <th class="tbl_EPG_th" colspan="6">Programa</th> </tr><tr> <th id="madrugada" class="tbl_EPG_th" colspan="8">Madrugada</th> </tr><tr class="tbl_EPG_row"><td colspan="1"><div class="tbl_EPG_TimesColumnOutOfSchedule"><time datetime="23:00">23:00</time></div></td><td colspan="1"><div class="tbl_EPG_TimesColumn"><time datetime="00:30">00:30</time></div></td><td colspan="6" class="programa"><div class="tbl_EPG_ProgramsColumn programa"><div class="div_program_title_on_channel"><span>Bienvenidos a bordo</span></div></div></td></tr><tr class="tbl_EPG_row"> <td colspan="1"> <div class="tbl_EPG_TimesColumn"> <time datetime="00:30">00:30</time> </div></td><td colspan="1"> <div class="tbl_EPG_TimesColumn"> <time datetime="01:45">01:45</time> </div></td><td colspan="6" class="pelicula"> <div class="tbl_EPG_ProgramsColumn pelicula"> <div class="div_program_title_on_channel"> <span>Ciudad de sombras</span> </div></div></td></tr><tr class="tbl_EPG_rowAlternate"> <td colspan="1"> <div class="tbl_EPG_TimesColumn"> <time datetime="01:45">01:45</time> </div></td><td colspan="1"> <div class="tbl_EPG_TimesColumn"> <time datetime="03:30">03:30</time> </div></td><td style="padding: 0px; width: 112px"> <a href="https://www.gatotv.com/pelicula/rascacielos_rescate_en_las_alturas" title="Rascacielos: Rescate en las Alturas" > <img src="https://imagenes.gatotv.com/categorias/peliculas/miniatura/rascacielos.jpg" width="112" height="84"/> </a> </td><td colspan="5" class="pelicula"> <div class="tbl_EPG_ProgramsColumn pelicula"> <div class="div_program_title_on_channel"> <a itemprop="url" href="https://www.gatotv.com/pelicula/rascacielos_rescate_en_las_alturas" title="Rascacielos: Rescate en las Alturas" > <span>Rascacielos: Rescate en las Alturas</span> </a> </div>Cuando un ex rescatista de rehenes del FBI evalúa la seguridad de un rascacielos en China, un incendio repentino hace que sea acusado injustamente. </div></td></tr><tr class="tbl_EPG_row"><td colspan="1"><div class="tbl_EPG_TimesColumn"><time datetime="13:30">13:30</time></div></td><td colspan="1"><div class="tbl_EPG_TimesColumn"><time datetime="13:41">13:41</time></div></td><td style="padding:0px; width:112px;"><a href="https://www.gatotv.com/caricatura/los_jovenes_titanes_en_accion" title="Los Jóvenes Titanes En Acción"><img src="https://imagenes.gatotv.com/categorias/caricaturas/miniatura/los_jovenes_titanes_en_accion.jpg" width="112" height="84"></a></td><td colspan="5" class="caricatura"><div class="tbl_EPG_ProgramsColumn caricatura"><div class="div_program_title_on_channel"><a itemprop="url" href="https://www.gatotv.com/caricatura/los_jovenes_titanes_en_accion" title="Los Jóvenes Titanes En Acción"><span>Los Jóvenes Titanes En Acción</span></a></div>Robin, Starfire, Raven, Chico Bestia y Cyborg se preparan para nuevas aventuras cómicas después de hacer un sándwich, jugar algún videojuego o lavar la ropa.</div></td></tr><tr class="tbl_EPG_rowAlternate"> <td colspan="1"> <div class="tbl_EPG_TimesColumn"> <time datetime="23:55">23:55</time> </div></td><td colspan="1"> <div class="tbl_EPG_TimesColumnOutOfSchedule"> <time datetime="04:00">04:00</time> </div></td><td colspan="6" class="programa"> <div class="tbl_EPG_ProgramsColumn programa"> <div class="div_program_title_on_channel"> <span>Decisión 2021</span> </div></div></td></tr></tbody> </table> </td><td style="vertical-align: top; float: right"> <div itemprop="inBroadcastLineup" itemscope="" itemtype="http://schema.org/CableOrSatelliteService" > <table class="tbl_EPG" style="width: 99%"> <tbody> <tr> <th colspan="5" class="tbl_EPG_th">Disponibilidad</th> </tr><tr class="tbl_EPG_row"> <td colspan="1" style="width: 10px; text-align: center"> <a href="https://www.gatotv.com/guia_tv/directv_latin Line truncated
it('can generate valid url', () => { it('can generate valid url', () => {
expect(url({ channel, date })).toBe('https://www.gatotv.com/canal/13_de_argentina/2021-11-13') expect(url({ channel, date })).toBe('https://www.gatotv.com/canal/punto_2_puerto_rico/2023-01-31')
}) })
it('can parse response', () => { it('can parse response', () => {
const result = parser({ date, channel, content }).map(p => { const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8')
const results = parser({ date, channel, content }).map(p => {
p.start = p.start.toJSON() p.start = p.start.toJSON()
p.stop = p.stop.toJSON() p.stop = p.stop.toJSON()
return p return p
}) })
expect(result).toMatchObject([ expect(results[0]).toMatchObject({
{ start: '2023-01-31T04:30:00.000Z',
start: '2021-11-13T04:00:00.000Z', stop: '2023-01-31T05:30:00.000Z',
stop: '2021-11-13T05:30:00.000Z', title: 'Decisiones de mujeres'
title: 'Bienvenidos a bordo' })
},
{ expect(results[2]).toMatchObject({
start: '2021-11-13T05:30:00.000Z', start: '2023-01-31T06:30:00.000Z',
stop: '2021-11-13T06:45:00.000Z', stop: '2023-01-31T07:30:00.000Z',
title: 'Ciudad de sombras' title: 'El Señor de los Cielos',
}, icon: 'https://imagenes.gatotv.com/categorias/telenovelas/miniatura/el_senor_de_los_cielos.jpg',
{
start: '2021-11-13T06:45:00.000Z',
stop: '2021-11-13T08:30:00.000Z',
title: 'Rascacielos: Rescate en las Alturas',
icon: 'https://imagenes.gatotv.com/categorias/peliculas/miniatura/rascacielos.jpg',
description: description:
'Cuando un ex rescatista de rehenes del FBI evalúa la seguridad de un rascacielos en China, un incendio repentino hace que sea acusado injustamente.' 'La vida de Amado Carrillo Fuentes, conocido como “El Señor de los Cielos”, uno de los cabecillas del Cuartel de Juárez.'
}, })
{
start: '2021-11-13T18:30:00.000Z', expect(results[33]).toMatchObject({
stop: '2021-11-13T18:41:00.000Z', start: '2023-02-01T04:30:00.000Z',
title: 'Los Jóvenes Titanes En Acción', stop: '2023-02-01T05:30:00.000Z',
icon: 'https://imagenes.gatotv.com/categorias/caricaturas/miniatura/los_jovenes_titanes_en_accion.jpg', title: 'Decisiones de mujeres'
description: })
'Robin, Starfire, Raven, Chico Bestia y Cyborg se preparan para nuevas aventuras cómicas después de hacer un sándwich, jugar algún videojuego o lavar la ropa.'
},
{
start: '2021-11-14T04:55:00.000Z',
stop: '2021-11-14T09:00:00.000Z',
title: 'Decisión 2021'
}
])
}) })
it('can handle empty guide', () => { it('can handle empty guide', () => {
const result = parser({ const results = parser({
date, date,
channel, channel,
content: `<!DOCTYPE html><html><head></head><body></body></html>` content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'), 'utf8')
}) })
expect(result).toMatchObject([])
expect(results).toMatchObject([])
}) })