mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Update nos.pt.config.js
This commit is contained in:
parent
aeb6967526
commit
07787c55b1
1 changed files with 15 additions and 48 deletions
|
@ -22,28 +22,17 @@ module.exports = {
|
||||||
for (let item of items) {
|
for (let item of items) {
|
||||||
const prev = programs[programs.length - 1]
|
const prev = programs[programs.length - 1]
|
||||||
const $item = cheerio.load(item)
|
const $item = cheerio.load(item)
|
||||||
let start = parseStart($item, date)
|
|
||||||
if (prev) {
|
|
||||||
if (start.isBefore(prev.start)) {
|
|
||||||
start = start.add(1, 'd')
|
|
||||||
date = date.add(1, 'd')
|
|
||||||
}
|
|
||||||
prev.stop = start
|
|
||||||
}
|
|
||||||
let stop = parseStop($item, date)
|
|
||||||
if (stop.isBefore(start)) {
|
|
||||||
stop = stop.add(1, 'd')
|
|
||||||
date = date.add(1, 'd')
|
|
||||||
}
|
|
||||||
const channelAcronym = parseChannelAcronym(content)
|
const channelAcronym = parseChannelAcronym(content)
|
||||||
const programId = parseProgramId($item)
|
const programId = parseProgramId($item)
|
||||||
const details = await loadProgramDetails(channelAcronym, programId)
|
const details = await loadProgramDetails(channelAcronym, programId)
|
||||||
|
|
||||||
programs.push({
|
programs.push({
|
||||||
title: parseTitle($item),
|
title: details.title,
|
||||||
description: details.description,
|
description: details.description,
|
||||||
icon: details.icon,
|
icon: parseIcon(details),
|
||||||
start,
|
start: dayjs(details.start),
|
||||||
stop
|
stop: dayjs(details.stop)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,15 +82,21 @@ async function loadProgramDetails(channelAcronym, programId) {
|
||||||
|
|
||||||
if (!data) return {}
|
if (!data) return {}
|
||||||
|
|
||||||
const [, description, iconFilename] = data.d.split('_#|$_')
|
const [title, description, image, , , , start, stop] = data.d.split('_#|$_')
|
||||||
const icon = iconFilename ? `https://images.nos.pt/${iconFilename}` : null
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
title,
|
||||||
description,
|
description,
|
||||||
icon
|
image,
|
||||||
|
start,
|
||||||
|
stop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseIcon(details) {
|
||||||
|
return details.image ? `https://images.nos.pt/${details.image}` : null
|
||||||
|
}
|
||||||
|
|
||||||
function parseProgramId($item) {
|
function parseProgramId($item) {
|
||||||
return $item('a').attr('id')
|
return $item('a').attr('id')
|
||||||
}
|
}
|
||||||
|
@ -112,34 +107,6 @@ function parseChannelAcronym(content) {
|
||||||
return $('#channel-logo > img').attr('alt')
|
return $('#channel-logo > img').attr('alt')
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseTitle($item) {
|
|
||||||
return $item('a').attr('title').trim()
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseStart($item, date) {
|
|
||||||
const [time] = $item('.duration')
|
|
||||||
.text()
|
|
||||||
.replace(/\s+/g, ' ')
|
|
||||||
.trim()
|
|
||||||
.match(/^\d{2}:\d{2}/) || [null]
|
|
||||||
|
|
||||||
if (!time) return null
|
|
||||||
|
|
||||||
return dayjs.tz(`${date.format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm', 'Europe/Lisbon')
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseStop($item, date) {
|
|
||||||
const [time] = $item('.duration')
|
|
||||||
.text()
|
|
||||||
.replace(/\s+/g, ' ')
|
|
||||||
.trim()
|
|
||||||
.match(/\d{2}:\d{2}$/) || [null]
|
|
||||||
|
|
||||||
if (!time) return null
|
|
||||||
|
|
||||||
return dayjs.tz(`${date.format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm', 'Europe/Lisbon')
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseItems(content, date) {
|
function parseItems(content, date) {
|
||||||
const day = date.date()
|
const day = date.date()
|
||||||
const $ = cheerio.load(content)
|
const $ = cheerio.load(content)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue