mirror of
https://github.com/iptv-org/epg
synced 2026-05-08 02:16: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
|
if (!items.length) return programs
|
||||||
|
|
||||||
const $ = cheerio.load(content)
|
const $ = cheerio.load(content)
|
||||||
const programDivs = $('div[id^="ele-"]').toArray()
|
const programElements = $('div[id^="ele-"]').get()
|
||||||
|
|
||||||
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++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
const el = items[i]
|
const el = items[i]
|
||||||
let programDescription = ''
|
let description = null
|
||||||
let programId = ''
|
|
||||||
|
|
||||||
try {
|
if (programElements[i]) {
|
||||||
if (programDivs[i]) {
|
const programDiv = $(programElements[i])
|
||||||
programId = programDivs[i].attribs.id.replace('ele-', '')
|
const programLink = programDiv.find('a').attr('href')
|
||||||
|
|
||||||
const descUrl = `https://comunicacion.movistarplus.es/detalle-de-programacion/?cee=${programId}`
|
if (programLink) {
|
||||||
const response = await axios.get(descUrl, {
|
const idMatch = programLink.match(/id=(\d+)/)
|
||||||
headers: headers,
|
if (idMatch && idMatch[1]) {
|
||||||
timeout: 5000
|
description = await getProgramDescription(programLink).catch(() => null)
|
||||||
})
|
}
|
||||||
|
|
||||||
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({
|
programs.push({
|
||||||
title: el.item.name,
|
title: el.item.name,
|
||||||
|
description: description,
|
||||||
start: dayjs(el.item.startDate),
|
start: dayjs(el.item.startDate),
|
||||||
stop: dayjs(el.item.endDate),
|
stop: dayjs(el.item.endDate)
|
||||||
description: programDescription
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,8 +71,27 @@ function parseItems(content) {
|
|||||||
let scheme = $('script:contains("@type": "ItemList")').html()
|
let scheme = $('script:contains("@type": "ItemList")').html()
|
||||||
scheme = JSON.parse(scheme)
|
scheme = JSON.parse(scheme)
|
||||||
if (!scheme || !Array.isArray(scheme.itemListElement)) return []
|
if (!scheme || !Array.isArray(scheme.itemListElement)) return []
|
||||||
|
|
||||||
return scheme.itemListElement
|
return scheme.itemListElement
|
||||||
} catch {
|
} catch {
|
||||||
return []
|
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