Update meo.pt.config.js
This commit is contained in:
@@ -1,18 +1,14 @@
|
|||||||
const dayjs = require('dayjs')
|
const { DateTime } = require('luxon')
|
||||||
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)
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'meo.pt',
|
site: 'meo.pt',
|
||||||
days: 2,
|
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: {
|
request: {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
Origin: 'https://www.meo.pt'
|
||||||
|
},
|
||||||
data: function ({ channel, date }) {
|
data: function ({ channel, date }) {
|
||||||
return {
|
return {
|
||||||
service: 'channelsguide',
|
service: 'channelsguide',
|
||||||
@@ -29,8 +25,8 @@ module.exports = {
|
|||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
const start = parseStart(item)
|
const start = parseStart(item)
|
||||||
let stop = parseStop(item)
|
let stop = parseStop(item)
|
||||||
if (stop.isBefore(start)) {
|
if (stop < start) {
|
||||||
stop = stop.add(1, 'd')
|
stop = stop.plus({ days: 1 })
|
||||||
}
|
}
|
||||||
programs.push({
|
programs.push({
|
||||||
title: item.name,
|
title: item.name,
|
||||||
@@ -44,11 +40,15 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseStart(item) {
|
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) {
|
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) {
|
function parseItems(content) {
|
||||||
|
|||||||
Reference in New Issue
Block a user