From 9c7000bdc1088cfff7de8347f0d449cd3f370080 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 28 May 2023 21:02:52 +0300 Subject: [PATCH 1/4] Update meo.pt.test.js --- sites/meo.pt/meo.pt.test.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sites/meo.pt/meo.pt.test.js b/sites/meo.pt/meo.pt.test.js index e68fd155..7371fcc6 100644 --- a/sites/meo.pt/meo.pt.test.js +++ b/sites/meo.pt/meo.pt.test.js @@ -1,4 +1,4 @@ -// npx epg-grabber --config=sites/meo.pt/meo.pt.config.js --channels=sites/meo.pt/meo.pt.channels.xml --output=guide.xml --days=2 +// npx epg-grabber --config=sites/meo.pt/meo.pt.config.js --channels=sites/meo.pt/meo.pt.channels.xml --output=guide.xml const { parser, url, request } = require('./meo.pt.config.js') const fs = require('fs') @@ -17,7 +17,7 @@ const channel = { it('can generate valid url', () => { expect(url).toBe( - 'https://www.meo.pt/_layouts/15/Ptsi.Isites.GridTv/GridTvMng.asmx/getProgramsFromChannels' + 'https://authservice.apps.meo.pt/Services/GridTv/GridTvMng.svc/getProgramsFromChannels' ) }) @@ -25,6 +25,12 @@ it('can generate valid request method', () => { expect(request.method).toBe('POST') }) +it('can generate valid request headers', () => { + expect(request.headers).toMatchObject({ + Origin: 'https://www.meo.pt' + }) +}) + it('can generate valid request method', () => { expect(request.data({ channel, date })).toMatchObject({ service: 'channelsguide', @@ -38,14 +44,14 @@ it('can generate valid request method', () => { it('can parse response', () => { const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json')) let results = parser({ content }).map(p => { - p.start = p.start.toJSON() - p.stop = p.stop.toJSON() + p.start = p.start.toISO() + p.stop = p.stop.toISO() return p }) expect(results[0]).toMatchObject({ - start: '2022-12-01T23:35:00.000Z', - stop: '2022-12-02T00:17:00.000Z', + start: '2022-12-01T23:35:00.000+00:00', + stop: '2022-12-02T00:17:00.000+00:00', title: 'Walker, O Ranger Do Texas T6 - Ep. 14' }) }) From 77a7eb2b503c02bff631553c7dd882d0899e51e8 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 28 May 2023 21:02:56 +0300 Subject: [PATCH 2/4] Update meo.pt.config.js --- sites/meo.pt/meo.pt.config.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/sites/meo.pt/meo.pt.config.js b/sites/meo.pt/meo.pt.config.js index b4ae2d7a..25ca0449 100644 --- a/sites/meo.pt/meo.pt.config.js +++ b/sites/meo.pt/meo.pt.config.js @@ -1,18 +1,14 @@ -const dayjs = require('dayjs') -const utc = require('dayjs/plugin/utc') -const customParseFormat = require('dayjs/plugin/customParseFormat') -const timezone = require('dayjs/plugin/timezone') - -dayjs.extend(utc) -dayjs.extend(customParseFormat) -dayjs.extend(timezone) +const { DateTime } = require('luxon') module.exports = { site: 'meo.pt', days: 2, - url: `https://www.meo.pt/_layouts/15/Ptsi.Isites.GridTv/GridTvMng.asmx/getProgramsFromChannels`, + url: `https://authservice.apps.meo.pt/Services/GridTv/GridTvMng.svc/getProgramsFromChannels`, request: { method: 'POST', + headers: { + Origin: 'https://www.meo.pt' + }, data: function ({ channel, date }) { return { service: 'channelsguide', @@ -29,8 +25,8 @@ module.exports = { items.forEach(item => { const start = parseStart(item) let stop = parseStop(item) - if (stop.isBefore(start)) { - stop = stop.add(1, 'd') + if (stop < start) { + stop = stop.plus({ days: 1 }) } programs.push({ title: item.name, @@ -44,11 +40,15 @@ module.exports = { } function parseStart(item) { - return dayjs.tz(`${item.date} ${item.timeIni}`, 'D-M-YYYY HH:mm', 'Europe/Lisbon') + return DateTime.fromFormat(`${item.date} ${item.timeIni}`, 'd-M-yyyy HH:mm', { + zone: 'Europe/Lisbon' + }) } function parseStop(item) { - return dayjs.tz(`${item.date} ${item.timeEnd}`, 'D-M-YYYY HH:mm', 'Europe/Lisbon') + return DateTime.fromFormat(`${item.date} ${item.timeEnd}`, 'd-M-yyyy HH:mm', { + zone: 'Europe/Lisbon' + }) } function parseItems(content) { From a9164116357115b7d70dd2bf3196ff0bcd6da325 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 28 May 2023 21:41:40 +0300 Subject: [PATCH 3/4] Update meo.pt.test.js --- sites/meo.pt/meo.pt.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sites/meo.pt/meo.pt.test.js b/sites/meo.pt/meo.pt.test.js index 7371fcc6..e80f27ac 100644 --- a/sites/meo.pt/meo.pt.test.js +++ b/sites/meo.pt/meo.pt.test.js @@ -44,14 +44,14 @@ it('can generate valid request method', () => { it('can parse response', () => { const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json')) let results = parser({ content }).map(p => { - p.start = p.start.toISO() - p.stop = p.stop.toISO() + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() return p }) expect(results[0]).toMatchObject({ - start: '2022-12-01T23:35:00.000+00:00', - stop: '2022-12-02T00:17:00.000+00:00', + start: '2022-12-01T23:35:00.000Z', + stop: '2022-12-02T00:17:00.000Z', title: 'Walker, O Ranger Do Texas T6 - Ep. 14' }) }) From 8090ce975a7988ac4ab4b3fd83b8afc35c28503a Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 28 May 2023 21:41:43 +0300 Subject: [PATCH 4/4] Update meo.pt.config.js --- sites/meo.pt/meo.pt.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sites/meo.pt/meo.pt.config.js b/sites/meo.pt/meo.pt.config.js index 25ca0449..c899d3a4 100644 --- a/sites/meo.pt/meo.pt.config.js +++ b/sites/meo.pt/meo.pt.config.js @@ -42,13 +42,13 @@ module.exports = { function parseStart(item) { return DateTime.fromFormat(`${item.date} ${item.timeIni}`, 'd-M-yyyy HH:mm', { zone: 'Europe/Lisbon' - }) + }).toUTC() } function parseStop(item) { return DateTime.fromFormat(`${item.date} ${item.timeEnd}`, 'd-M-yyyy HH:mm', { zone: 'Europe/Lisbon' - }) + }).toUTC() } function parseItems(content) {