mirror of
https://github.com/iptv-org/epg
synced 2026-04-04 18:11:32 -04:00
Update movistarplus.es.config.js
Update code to add program description into the EPG.
This commit is contained in:
@@ -6,21 +6,53 @@ module.exports = {
|
||||
site: 'movistarplus.es',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://www.movistarplus.es/programacion-tv/${channel.site_id}/${date.format(
|
||||
'YYYY-MM-DD'
|
||||
)}`
|
||||
return `https://www.movistarplus.es/programacion-tv/${channel.site_id}/${date.format('YYYY-MM-DD')}`
|
||||
},
|
||||
parser({ content }) {
|
||||
async parser({ content }) {
|
||||
let programs = []
|
||||
let items = parseItems(content)
|
||||
if (!items.length) return programs
|
||||
items.forEach(el => {
|
||||
|
||||
const $ = cheerio.load(content)
|
||||
const programDivs = $('div[id^="ele-"]').toArray()
|
||||
|
||||
const headers = {
|
||||
'Referer': 'https://comunicacion.movistarplus.es/programacion-tv/',
|
||||
'Origin': 'https://comunicacion.movistarplus.es',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
|
||||
};
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const el = items[i]
|
||||
let programDescription = ''
|
||||
let programId = ''
|
||||
|
||||
try {
|
||||
if (programDivs[i]) {
|
||||
programId = programDivs[i].attribs.id.replace('ele-', '')
|
||||
|
||||
const descUrl = `https://comunicacion.movistarplus.es/detalle-de-programacion/?cee=${programId}`
|
||||
const response = await axios.get(descUrl, {
|
||||
headers: headers,
|
||||
timeout: 5000
|
||||
})
|
||||
|
||||
const $desc = cheerio.load(response.data)
|
||||
programDescription = $desc('div.program-details div.sinopsis div.sinopsis_large').text().trim() ||
|
||||
$desc('div.sinopsis_large').text().trim()
|
||||
}
|
||||
} catch (error) {
|
||||
continue
|
||||
}
|
||||
|
||||
programs.push({
|
||||
title: el.item.name,
|
||||
start: dayjs(el.item.startDate),
|
||||
stop: dayjs(el.item.endDate)
|
||||
stop: dayjs(el.item.endDate),
|
||||
description: programDescription
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
@@ -52,7 +84,6 @@ function parseItems(content) {
|
||||
let scheme = $('script:contains("@type": "ItemList")').html()
|
||||
scheme = JSON.parse(scheme)
|
||||
if (!scheme || !Array.isArray(scheme.itemListElement)) return []
|
||||
|
||||
return scheme.itemListElement
|
||||
} catch {
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user