Fix movistarplus.es

#777
This commit is contained in:
Aleksandr Statciuk 2022-05-10 20:22:40 +03:00
parent 42720ad62c
commit ce7f70d351
2 changed files with 18 additions and 8 deletions

View file

@ -1,7 +1,9 @@
const dayjs = require('dayjs')
const timezone = require('dayjs/plugin/timezone')
const utc = require('dayjs/plugin/utc')
var customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(utc)
dayjs.extend(timezone)
dayjs.extend(customParseFormat)
module.exports = {
@ -15,8 +17,16 @@ module.exports = {
if (!items.length) return programs
let guideDate = date
items.forEach(item => {
let startTime = dayjs.utc(`${guideDate.format('YYYY-MM-DD')} ${item.HORA_INICIO}`,"YYYY-MM-DD HH:mm")
let stopTime = dayjs.utc(`${guideDate.format('YYYY-MM-DD')} ${item.HORA_FIN}`, 'YYYY-MM-DD HH:mm')
let startTime = dayjs.tz(
`${guideDate.format('YYYY-MM-DD')} ${item.HORA_INICIO}`,
'YYYY-MM-DD HH:mm',
'Europe/Madrid'
)
let stopTime = dayjs.tz(
`${guideDate.format('YYYY-MM-DD')} ${item.HORA_FIN}`,
'YYYY-MM-DD HH:mm',
'Europe/Madrid'
)
if (stopTime.isBefore(startTime)) {
guideDate = guideDate.add(1, 'd')
stopTime = stopTime.add(1, 'd')

View file

@ -22,20 +22,20 @@ it('can parse response', () => {
const result = parser({ content, channel, date })
expect(result).toMatchObject([
{
start: '2022-03-11T06:00:00.000Z',
stop: '2022-03-11T08:30:00.000Z',
start: '2022-03-11T05:00:00.000Z',
stop: '2022-03-11T07:30:00.000Z',
category: 'Información',
title: `Telediario Matinal`
},
{
start: '2022-03-11T22:15:00.000Z',
stop: '2022-03-12T00:30:00.000Z',
start: '2022-03-11T21:15:00.000Z',
stop: '2022-03-11T23:30:00.000Z',
category: 'Información',
title: `Las Claves del Siglo XXI: Episodio 8`
},
{
start: '2022-03-12T03:10:00.000Z',
stop: '2022-03-12T06:00:00.000Z',
start: '2022-03-12T02:10:00.000Z',
stop: '2022-03-12T05:00:00.000Z',
category: 'Información',
title: `Noticias 24H`
}