Files
epg/sites/movistarplus.es/movistarplus.es.config.js

104 lines
3.2 KiB
JavaScript
Raw Normal View History

2025-09-28 17:55:05 +03:00
const axios = require('axios')
const dayjs = require('dayjs')
const timezone = require('dayjs/plugin/timezone')
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
dayjs.extend(timezone)
dayjs.tz.setDefault('Europe/Madrid')
2025-09-28 17:55:05 +03:00
module.exports = {
site: 'movistarplus.es',
days: 2,
url({ channel, date }) {
return `https://ottcache.dof6.com/movistarplus/webplayer/OTT/epg?from=${date.format('YYYY-MM-DDTHH:mm:ss')}&span=1&channel=${channel.site_id}&version=8&mdrm=true&tlsstream=true&demarcation=18`
2025-09-28 17:55:05 +03:00
},
request: {
headers: {
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Language': 'es-ES,es;q=0.9,en;q=0.8',
Referer: 'https://www.movistarplus.es/programacion-tv'
},
maxRedirects: 5
},
2026-02-19 18:20:28 +01:00
async parser({ content }) {
2025-09-28 17:55:05 +03:00
let programs = []
let items = await parseItems(content)
2025-09-28 17:55:05 +03:00
if (!items.length) return programs
items.forEach(el => {
2025-09-28 17:55:05 +03:00
programs.push({
title: el.title,
description: el.description,
season: el.season,
episode: el.episode,
start: el.start,
stop: el.stop
})
2025-09-28 17:55:05 +03:00
})
return programs
2025-09-28 17:55:05 +03:00
},
async channels() {
const json = await axios
.get('https://ottcache.dof6.com/movistarplus/webplayer/OTT/contents/channels?mdrm=true&tlsstream=true&demarcation=18&version=8')
2025-09-28 17:55:05 +03:00
.then(r => r.data)
.catch(console.log)
// Load JSON, CodCadenaTv is the closest to the old MVSTR site ch. ID
return json.map(channel => {
2025-09-28 17:55:05 +03:00
return {
lang: 'es',
site_id: channel.CodCadenaTv,
name: channel.Nombre,
logo: channel.Logo ? channel.Logos[0].url : null
2025-09-28 17:55:05 +03:00
}
})
}
}
async function parseItems(content) {
2025-09-28 17:55:05 +03:00
try {
const data = JSON.parse(content)
const programs = Array.isArray(data) ? data : [data]
return await Promise.all(programs.map(async (json) => {
const start = dayjs.utc(Number(json?.FechaHoraInicio))
const stop = dayjs.utc(Number(json?.FechaHoraFin))
const ficha = json?.Ficha || null
if (!ficha) {
return {
title: json?.Titulo || '',
description: json?.Resena || '',
start,
stop
}
} else {
try {
const fichaJson = await axios.get(ficha).then(r => r.data)
return {
title: json?.Titulo || fichaJson?.Titulo || '',
description: fichaJson?.Descripcion || json?.Resena || '',
actors: fichaJson?.Actores || [],
directors: fichaJson?.Directores || [],
classification: fichaJson?.Clasificacion || '',
season: fichaJson?.Temporada || null,
episode: fichaJson?.NumeroEpisodio || null,
start,
stop
}
} catch {
return {
title: json?.Titulo || '',
description: json?.Resena || '',
start,
stop
}
}
}
}))
2025-09-28 17:55:05 +03:00
} catch {
return []
}
}