mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 09:30:06 -04:00
Merge pull request #2076 from iptv-org/fix-movistarplus.es
Fix movistarplus.es
This commit is contained in:
commit
5d6ea2442d
2 changed files with 19 additions and 21 deletions
|
@ -1,10 +1,4 @@
|
|||
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)
|
||||
const { DateTime } = require('luxon')
|
||||
|
||||
module.exports = {
|
||||
site: 'movistarplus.es',
|
||||
|
@ -18,25 +12,25 @@ module.exports = {
|
|||
if (!items.length) return programs
|
||||
let guideDate = date
|
||||
items.forEach(item => {
|
||||
let startTime = dayjs.tz(
|
||||
let startTime = DateTime.fromFormat(
|
||||
`${guideDate.format('YYYY-MM-DD')} ${item.HORA_INICIO}`,
|
||||
'YYYY-MM-DD HH:mm',
|
||||
'Europe/Madrid'
|
||||
)
|
||||
let stopTime = dayjs.tz(
|
||||
'yyyy-MM-dd HH:mm',
|
||||
{ zone: 'Europe/Madrid' }
|
||||
).toUTC()
|
||||
let stopTime = DateTime.fromFormat(
|
||||
`${guideDate.format('YYYY-MM-DD')} ${item.HORA_FIN}`,
|
||||
'YYYY-MM-DD HH:mm',
|
||||
'Europe/Madrid'
|
||||
)
|
||||
if (stopTime.isBefore(startTime)) {
|
||||
'yyyy-MM-dd HH:mm',
|
||||
{ zone: 'Europe/Madrid' }
|
||||
).toUTC()
|
||||
if (stopTime < startTime) {
|
||||
guideDate = guideDate.add(1, 'd')
|
||||
stopTime = stopTime.add(1, 'd')
|
||||
stopTime = stopTime.plus({ days: 1 })
|
||||
}
|
||||
programs.push({
|
||||
title: item.TITULO,
|
||||
category: item.GENERO,
|
||||
start: startTime.toJSON(),
|
||||
stop: stopTime.toJSON()
|
||||
start: startTime,
|
||||
stop: stopTime
|
||||
})
|
||||
})
|
||||
return programs
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// npx epg-grabber --config=sites/movistarplus.es/movistarplus.es.config.js --channels=sites/movistarplus.es/movistarplus.es.channels.xml --output=guide.xml --days=2
|
||||
// npx epg-grabber --config=sites/movistarplus.es/movistarplus.es.config.js --channels=sites/movistarplus.es/movistarplus.es.channels.xml --output=guide.xml
|
||||
|
||||
const { parser, url, request } = require('./movistarplus.es.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
|
@ -19,7 +19,11 @@ it('can generate valid url', () => {
|
|||
|
||||
it('can parse response', () => {
|
||||
const content = `{"success":"true","msg":"","data":{"TVE-CODE":{"DATOS_CADENA":{"CODIGO":"TVE","MARCA":"TVE","NOMBRE":"LA 1","URL":"https://www.movistarplus.es/canal?nombre=LA%2B1&id=TVE","DIAL_PRINCIPAL":["01"],"DIALES":[1],"UID":null,"CASID":null,"SERVICEUID":null,"SERVICEUID2":null,"SERVICEID":null,"ESVIRTUAL":null,"ESSATELITE":null,"UPSELLING":null,"puntoReproduccion":null},"PROGRAMAS":[{"DIRECTO":false,"TEMPORADA":"","TITULO":"Telediario Matinal","GENERO":"Información","CODIGO_GENERO":"IF","DURACION":150,"DURACION_VISUAL":150,"HORA_INICIO":"06:00","HORA_FIN":"08:30","ELEMENTO":"1709045","EVENTO":"99422566","ShowId":null,"x1":0,"x2":0,"Disponible":null,"URL":"https://www.movistarplus.es/ficha/telediario-matinal?tipo=R&id=99422566"},{"DIRECTO":false,"TEMPORADA":"","TITULO":"Las Claves del Siglo XXI: Episodio 8","GENERO":"Información","CODIGO_GENERO":"IF","DURACION":135,"DURACION_VISUAL":135,"HORA_INICIO":"22:15","HORA_FIN":"00:30","ELEMENTO":"2051356","EVENTO":"99422634","ShowId":null,"x1":0,"x2":0,"Disponible":null,"URL":"https://www.movistarplus.es/ficha/las-claves-del-siglo-xxi-t1/episodio-8?tipo=R&id=99422634"},{"DIRECTO":false,"TEMPORADA":"","TITULO":"Noticias 24H","GENERO":"Información","CODIGO_GENERO":"IF","DURACION":170,"DURACION_VISUAL":170,"HORA_INICIO":"03:10","HORA_FIN":"06:00","ELEMENTO":"518403","EVENTO":"99422646","ShowId":null,"x1":0,"x2":0,"Disponible":null,"URL":"https://www.movistarplus.es/ficha/noticias-24h?tipo=R&id=99422646"}]}}}`
|
||||
const result = parser({ content, channel, date })
|
||||
const result = parser({ content, channel, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-03-11T05:00:00.000Z',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue