diff --git a/sites/gatotv.com/__data__/content_0.html b/sites/gatotv.com/__data__/content_0.html new file mode 100644 index 00000000..3252332a --- /dev/null +++ b/sites/gatotv.com/__data__/content_0.html @@ -0,0 +1,1851 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+| +Tweetear + | + ++ + | + +
| + + | +|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
+
+
+
+
+
+
+
+
+
+
+
+Canal #0+Martes 13 de junio de 2023+ ++ + +
+
+
+
+
++ + +
+
+
+
+
+
++ +
+ + + +
+
+
+
+
+
+
+
+ +
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
++ + + +
+
+
+
+ +
+
+
+
+
+
+
+
++ +
+
+
+
+
+
+
+
++ +
+
+
+
+
+
+
+
+ |
+||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| + + + | +|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
La guía de Televisión en Español de series, películas, telenovelas y programas de televisión para Argentina, Bolivia, Chile, Colombia, Costa Rica, Cuba, Ecuador, El Salvador, Estados Unidos, Guatemala, Honduras, México, Nicaragua, Panamá, Paraguay, Perú, Puerto Rico, República Dominicana, Uruguay, Venezuela, el resto de Latinoamérica, España y el mundo latino.
Lo que está en la tele, disfrútalo en tu tele.
| Versión Móvil | +| | +Mapa del sitio | +| | +Términos y Condiciones | +| | +Contáctenos | +| | +| | +| | +| | +
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
|
- -Puerto Rico + +España | @@ -1387,22 +1422,13 @@ Los hermanos Reyes, son tres hombres buenos y honestos que un día una tragedia|||
-
-
- |
- -Claro TV Puerto Rico + +Movistar+ -Canal 9 +Canal 7 | |||
| Versión Móvil | +Versión Móvil | | | Mapa del sitio | | | @@ -1573,9 +1599,9 @@ scpt.parentNode.insertBefore(elem, scpt); @@ -1692,7 +1718,7 @@ function () { var options = { format: '%l:%M:%S %P', utc: true, -utcOffset: -5 +utcOffset: 3 } //Clock $('.jclock').remove(); @@ -1755,7 +1781,7 @@ function () { var options = { format: '%H:%M:%S', utc: true, -utcOffset: -5 +utcOffset: 3 } //Clock $('.jclock').remove(); diff --git a/sites/gatotv.com/gatotv.com.config.js b/sites/gatotv.com/gatotv.com.config.js index 3ca7b477..bff22d0f 100644 --- a/sites/gatotv.com/gatotv.com.config.js +++ b/sites/gatotv.com/gatotv.com.config.js @@ -2,14 +2,7 @@ const axios = require('axios') const cheerio = require('cheerio') const url = require('url') const path = require('path') -const dayjs = require('dayjs') -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) +const { DateTime } = require('luxon') module.exports = { site: 'gatotv.com', @@ -21,20 +14,17 @@ module.exports = { let programs = [] const items = parseItems(content) date = date.subtract(1, 'd') - items.forEach((item, index) => { + items.forEach((item, i) => { const prev = programs[programs.length - 1] const $item = cheerio.load(item) let start = parseStart($item, date) - if (prev) { - if (start.isBefore(prev.start)) { - start = start.add(1, 'd') - date = date.add(1, 'd') - } - prev.stop = start + if (i === 0 && start.hour >= 5) { + start = start.plus({ days: 1 }) + date = date.add(1, 'd') } - let stop = parseStop($item, start) - if (stop.isBefore(start)) { - stop = stop.add(1, 'd') + let stop = parseStop($item, date) + if (stop < start) { + stop = stop.plus({ days: 1 }) date = date.add(1, 'd') } @@ -87,13 +77,17 @@ function parseIcon($item) { function parseStart($item, date) { const time = $item('td:nth-child(1) > div > time').attr('datetime') - return dayjs.tz(`${date.format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm', 'EST') + return DateTime.fromFormat(`${date.format('YYYY-MM-DD')} ${time}`, 'yyyy-MM-dd HH:mm', { + zone: 'EST' + }).toUTC() } function parseStop($item, date) { const time = $item('td:nth-child(2) > div > time').attr('datetime') - return dayjs.tz(`${date.format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm', 'EST') + return DateTime.fromFormat(`${date.format('YYYY-MM-DD')} ${time}`, 'yyyy-MM-dd HH:mm', { + zone: 'EST' + }).toUTC() } function parseItems(content) { diff --git a/sites/gatotv.com/gatotv.com.test.js b/sites/gatotv.com/gatotv.com.test.js index e0ac41dc..814a7953 100644 --- a/sites/gatotv.com/gatotv.com.test.js +++ b/sites/gatotv.com/gatotv.com.test.js @@ -1,5 +1,5 @@ // 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.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 const { parser, url, request } = require('./gatotv.com.config.js') const fs = require('fs') @@ -10,18 +10,18 @@ const customParseFormat = require('dayjs/plugin/customParseFormat') dayjs.extend(customParseFormat) dayjs.extend(utc) -const date = dayjs.utc('2023-01-31', 'YYYY-MM-DD').startOf('d') +let date = dayjs.utc('2023-06-13', 'YYYY-MM-DD').startOf('d') const channel = { - site_id: 'punto_2_puerto_rico', - xmltv_id: 'WKAQDT2.us' + site_id: 'm_0', + xmltv_id: '0porMovistarPlus.es' } it('can generate valid url', () => { - expect(url({ channel, date })).toBe('https://www.gatotv.com/canal/punto_2_puerto_rico/2023-01-31') + expect(url({ channel, date })).toBe('https://www.gatotv.com/canal/m_0/2023-06-13') }) it('can parse response', () => { - const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8') + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content_0.html'), 'utf8') const results = parser({ date, channel, content }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() @@ -30,24 +30,44 @@ it('can parse response', () => { }) expect(results[0]).toMatchObject({ - start: '2023-01-31T04:30:00.000Z', - stop: '2023-01-31T05:30:00.000Z', - title: 'Decisiones de mujeres' + start: '2023-06-13T04:30:00.000Z', + stop: '2023-06-13T05:32:00.000Z', + title: 'Supergarcía' }) - expect(results[2]).toMatchObject({ - start: '2023-01-31T06:30:00.000Z', - stop: '2023-01-31T07:30:00.000Z', - title: 'El Señor de los Cielos', - icon: 'https://imagenes.gatotv.com/categorias/telenovelas/miniatura/el_senor_de_los_cielos.jpg', - description: - 'La vida de Amado Carrillo Fuentes, conocido como “El Señor de los Cielos”, uno de los cabecillas del Cuartel de Juárez.' + expect(results[1]).toMatchObject({ + start: '2023-06-13T05:32:00.000Z', + stop: '2023-06-13T06:59:00.000Z', + title: 'La resistencia' }) - expect(results[33]).toMatchObject({ - start: '2023-02-01T04:30:00.000Z', - stop: '2023-02-01T05:30:00.000Z', - title: 'Decisiones de mujeres' + expect(results[25]).toMatchObject({ + start: '2023-06-14T04:46:00.000Z', + stop: '2023-06-14T05:00:00.000Z', + title: 'Una familia absolutamente normal' + }) +}) + +it('can parse response when the guide starts from midnight', () => { + date = date.add(1, 'd') + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content_1.html'), 'utf8') + const results = parser({ date, channel, content }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + + return p + }) + + expect(results[0]).toMatchObject({ + start: '2023-06-14T05:00:00.000Z', + stop: '2023-06-14T05:32:00.000Z', + title: 'Ilustres Ignorantes' + }) + + expect(results[26]).toMatchObject({ + start: '2023-06-15T04:30:00.000Z', + stop: '2023-06-15T05:30:00.000Z', + title: 'Showriano' }) })