mirror of
https://github.com/iptv-org/epg
synced 2026-05-07 01:46:59 -04:00
Update programtv.onet.pl.config.js
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
const axios = require('axios')
|
||||||
const cheerio = require('cheerio')
|
const cheerio = require('cheerio')
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
@@ -15,10 +16,10 @@ module.exports = {
|
|||||||
|
|
||||||
return `https://programtv.onet.pl/program-tv/${channel.site_id}?dzien=${day}`
|
return `https://programtv.onet.pl/program-tv/${channel.site_id}?dzien=${day}`
|
||||||
},
|
},
|
||||||
parser: function ({ content, date }) {
|
async parser({ content, date }) {
|
||||||
const programs = []
|
const programs = []
|
||||||
const items = parseItems(content)
|
const items = parseItems(content)
|
||||||
items.forEach(item => {
|
for (const 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)
|
let start = parseStart($item, date)
|
||||||
@@ -30,19 +31,27 @@ module.exports = {
|
|||||||
prev.stop = start
|
prev.stop = start
|
||||||
}
|
}
|
||||||
const stop = start.add(1, 'hour')
|
const stop = start.add(1, 'hour')
|
||||||
|
|
||||||
|
const programUrl = parseProgramUrl($item)
|
||||||
|
const details = await loadProgramDetails(programUrl)
|
||||||
|
let image
|
||||||
|
if (details) {
|
||||||
|
image = details.image
|
||||||
|
}
|
||||||
|
|
||||||
programs.push({
|
programs.push({
|
||||||
title: parseTitle($item),
|
title: parseTitle($item),
|
||||||
description: parseDescription($item),
|
description: parseDescription($item),
|
||||||
|
image,
|
||||||
category: parseCategory($item),
|
category: parseCategory($item),
|
||||||
start,
|
start,
|
||||||
stop
|
stop
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
return programs
|
return programs
|
||||||
},
|
},
|
||||||
async channels() {
|
async channels() {
|
||||||
const axios = require('axios')
|
|
||||||
const data = await axios
|
const data = await axios
|
||||||
.get('https://programtv.onet.pl/stacje')
|
.get('https://programtv.onet.pl/stacje')
|
||||||
.then(r => r.data)
|
.then(r => r.data)
|
||||||
@@ -67,6 +76,27 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadProgramDetails(url) {
|
||||||
|
const html = await axios
|
||||||
|
.get(url)
|
||||||
|
.then(r => r.data)
|
||||||
|
.catch(console.error)
|
||||||
|
if (!html) return
|
||||||
|
|
||||||
|
const $ = cheerio.load(html)
|
||||||
|
|
||||||
|
return {
|
||||||
|
image: $('meta[property="og:image"]').attr('content')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseProgramUrl($item) {
|
||||||
|
const href = $item('.titles > a').attr('href')
|
||||||
|
const url = new URL(href, 'https://programtv.onet.pl')
|
||||||
|
|
||||||
|
return url.href
|
||||||
|
}
|
||||||
|
|
||||||
function parseStart($item, date) {
|
function parseStart($item, date) {
|
||||||
const timeString = $item('.hours > .hour').text()
|
const timeString = $item('.hours > .hour').text()
|
||||||
const dateString = `${date.format('MM/DD/YYYY')} ${timeString}`
|
const dateString = `${date.format('MM/DD/YYYY')} ${timeString}`
|
||||||
|
|||||||
Reference in New Issue
Block a user