fixes movistar plus
All checks were successful
Build docker container / build (push) Successful in 4m32s
All checks were successful
Build docker container / build (push) Successful in 4m32s
This commit is contained in:
parent
99c7d0e2c6
commit
e7b49898df
@ -1,8 +1,5 @@
|
|||||||
// credit for this fix goes to davidclaeysquinones for his PR on https://github.com/iptv-org/epg/pull/2440
|
|
||||||
|
|
||||||
const { DateTime } = require('luxon')
|
const { DateTime } = require('luxon')
|
||||||
|
|
||||||
const API_CHANNEL_ENDPOINT = 'https://www.movistarplus.es/programacion-tv'
|
|
||||||
const API_PROGRAM_ENDPOINT = 'https://comunicacion.movistarplus.es'
|
const API_PROGRAM_ENDPOINT = 'https://comunicacion.movistarplus.es'
|
||||||
const API_IMAGE_ENDPOINT = 'https://www.movistarplus.es/recorte/n/caratulaH/';
|
const API_IMAGE_ENDPOINT = 'https://www.movistarplus.es/recorte/n/caratulaH/';
|
||||||
|
|
||||||
@ -17,78 +14,60 @@ module.exports = {
|
|||||||
headers: {
|
headers: {
|
||||||
Origin: API_PROGRAM_ENDPOINT,
|
Origin: API_PROGRAM_ENDPOINT,
|
||||||
Referer: `${API_PROGRAM_ENDPOINT}/programacion/`,
|
Referer: `${API_PROGRAM_ENDPOINT}/programacion/`,
|
||||||
"Content-Type" : 'application/x-www-form-urlencoded; charset=UTF-8'
|
"Content-Type" : 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||||
},
|
},
|
||||||
data: function ({ channel, date }) {
|
data: function ({ channel, date }) {
|
||||||
return {
|
return {
|
||||||
action: 'getProgramation',
|
action: 'getProgramation',
|
||||||
day: date.format('YYYY-MM-DD'),
|
day: date.format('YYYY-MM-DD'),
|
||||||
"channels[]": channel.site_id
|
"channels[]": channel.site_id,
|
||||||
}
|
};
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
parser({ content, channel, date }) {
|
parser({ content, channel, date }) {
|
||||||
let programs = []
|
let programs = []
|
||||||
let items = parseItems(content, channel)
|
let items = parseItems(content, channel);
|
||||||
if (!items.length) return programs
|
if (!items.length) return programs;
|
||||||
let guideDate = date
|
|
||||||
|
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
let startTime = DateTime.fromFormat(
|
let startTime = DateTime.fromFormat(
|
||||||
`${item.f_evento_rejilla}`,
|
`${item.f_evento_rejilla}`,
|
||||||
'yyyy-MM-dd HH:mm:ss',
|
'yyyy-MM-dd HH:mm:ss',
|
||||||
{
|
{ zone: 'Europe/Madrid' }
|
||||||
zone: 'Europe/Madrid'
|
).toUTC();
|
||||||
}
|
|
||||||
).toUTC()
|
|
||||||
let stopTime = DateTime.fromFormat(
|
let stopTime = DateTime.fromFormat(
|
||||||
`${item.f_fin_evento_rejilla}`,
|
`${item.f_fin_evento_rejilla}`,
|
||||||
'yyyy-MM-dd HH:mm:ss',
|
'yyyy-MM-dd HH:mm:ss',
|
||||||
{
|
{ zone: 'Europe/Madrid' }
|
||||||
zone: 'Europe/Madrid'
|
|
||||||
}
|
|
||||||
).toUTC()
|
).toUTC()
|
||||||
|
|
||||||
|
// Adjust stop time if it's on the next day
|
||||||
if (stopTime < startTime) {
|
if (stopTime < startTime) {
|
||||||
guideDate = guideDate.add(1, 'd')
|
stopTime = stopTime.plus({ days: 1 });
|
||||||
stopTime = stopTime.plus({ days: 1 })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
programs.push({
|
programs.push({
|
||||||
title: item.des_evento_rejilla,
|
title: item.des_evento_rejilla,
|
||||||
icon: parseIcon(item, channel),
|
icon: parseIcon(item, channel),
|
||||||
category: item.des_genero,
|
category: item.des_genero,
|
||||||
start: startTime,
|
start: startTime,
|
||||||
stop: stopTime
|
stop: stopTime,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return programs
|
return programs
|
||||||
},
|
},
|
||||||
async channels() {
|
|
||||||
const axios = require('axios')
|
|
||||||
const dayjs = require('dayjs')
|
|
||||||
const data = await axios
|
|
||||||
.get(`${API_CHANNEL_ENDPOINT}/${dayjs().format('YYYY-MM-DD')}?v=json`)
|
|
||||||
.then(r => r.data)
|
|
||||||
.catch(console.log)
|
|
||||||
|
|
||||||
return Object.values(data.data).map(item => {
|
|
||||||
return {
|
|
||||||
lang: 'es',
|
|
||||||
site_id: item.DATOS_CADENA.CODIGO,
|
|
||||||
name: item.DATOS_CADENA.NOMBRE
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseIcon(item, channel) {
|
function parseIcon(item, channel) {
|
||||||
return `${API_IMAGE_ENDPOINT}/M${channel.site_id}P${item.ELEMENTO}`;
|
return `${API_IMAGE_ENDPOINT}/M${channel.site_id}P${item.cod_evento_rejilla}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItems(content, channel) {
|
function parseItems(content, channel) {
|
||||||
const json = typeof content === 'string' ? JSON.parse(content) : content
|
const json = typeof content === 'string' ? JSON.parse(content) : content;
|
||||||
const data = json.channelsProgram;
|
const data = json.channelsProgram;
|
||||||
|
|
||||||
if(data.length != 1)
|
if (data.length !== 1) return [];
|
||||||
return []
|
|
||||||
return data[0];
|
return data[0];
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user