mirror of
https://github.com/iptv-org/epg
synced 2026-03-22 20:00:59 -04:00
Update movistarplus.es.config.js
Changed how program description is obtained.
This commit is contained in:
@@ -14,42 +14,29 @@ module.exports = {
|
||||
if (!items.length) return programs
|
||||
|
||||
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'
|
||||
};
|
||||
const programElements = $('div[id^="ele-"]').get()
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const el = items[i]
|
||||
let programDescription = ''
|
||||
let programId = ''
|
||||
let description = null
|
||||
|
||||
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()
|
||||
if (programElements[i]) {
|
||||
const programDiv = $(programElements[i])
|
||||
const programLink = programDiv.find('a').attr('href')
|
||||
|
||||
if (programLink) {
|
||||
const idMatch = programLink.match(/id=(\d+)/)
|
||||
if (idMatch && idMatch[1]) {
|
||||
description = await getProgramDescription(programLink).catch(() => null)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
continue
|
||||
}
|
||||
|
||||
programs.push({
|
||||
title: el.item.name,
|
||||
description: description,
|
||||
start: dayjs(el.item.startDate),
|
||||
stop: dayjs(el.item.endDate),
|
||||
description: programDescription
|
||||
stop: dayjs(el.item.endDate)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -84,8 +71,27 @@ 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 []
|
||||
}
|
||||
}
|
||||
|
||||
async function getProgramDescription(programUrl) {
|
||||
try {
|
||||
const response = await axios.get(programUrl, {
|
||||
headers: {
|
||||
'Referer': 'https://www.movistarplus.es/programacion-tv/'
|
||||
}
|
||||
})
|
||||
|
||||
const $ = cheerio.load(response.data)
|
||||
const description = $('.show-content .text p').first().text().trim() || null
|
||||
|
||||
return description
|
||||
} catch (error) {
|
||||
console.error(`Error fetching description from ${programUrl}:`, error.message)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user