Update movistarplus.es.config.js

This commit is contained in:
Aleksandr Statciuk 2022-03-11 21:22:41 +03:00
parent ec9f8026ef
commit ce79bee196

View file

@ -4,6 +4,7 @@ dayjs.extend(customParseFormat)
module.exports = {
site: 'movistarplus.es',
ignore: true, // removes the site from the list until the test is passed
url: function ({ date }) {
return `https://www.movistarplus.es/programacion-tv/${date.format('YYYY-MM-DD')}?v=json`
},
@ -13,8 +14,11 @@ module.exports = {
if (!items.length) return programs
let guideDate = date
items.forEach(item => {
let startTime = dayjs(`${guideDate.format('YYYY-MM-DD')} ${item.HORA_INICIO}`,"YYYY-MM-DD HH:mm")
let stopTime = dayjs(`${guideDate.format('YYYY-MM-DD')} ${item.HORA_FIN}`,"YYYY-MM-DD HH:mm")
let startTime = dayjs(
`${guideDate.format('YYYY-MM-DD')} ${item.HORA_INICIO}`,
'YYYY-MM-DD HH:mm'
)
let stopTime = dayjs(`${guideDate.format('YYYY-MM-DD')} ${item.HORA_FIN}`, 'YYYY-MM-DD HH:mm')
if (stopTime.isBefore(startTime)) {
guideDate = guideDate.add(1, 'd')
stopTime = stopTime.add(1, 'd')
@ -28,11 +32,11 @@ module.exports = {
})
return programs
}
}
}
function parseItems(content, channel) {
function parseItems(content, channel) {
const json = typeof content === 'string' ? JSON.parse(content) : content
if (!(`${channel.site_id}-CODE` in json.data)) return []
const data = json.data[`${channel.site_id}-CODE`]
return data ? data.PROGRAMAS : []
}
}