mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 09:30:06 -04:00
Added guide from programtv.onet.pl
This commit is contained in:
parent
0d32c46e3e
commit
a9da470235
4 changed files with 658 additions and 0 deletions
59
sites/programtv.onet.pl.config.js
Normal file
59
sites/programtv.onet.pl.config.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
const urlParser = require('url')
|
||||
const jsdom = require('jsdom')
|
||||
const { JSDOM } = jsdom
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
module.exports = {
|
||||
lang: 'pl',
|
||||
site: 'programtv.onet.pl',
|
||||
channels: 'programtv.onet.pl.channels.xml',
|
||||
output: '.gh-pages/guides/programtv.onet.pl.guide.xml',
|
||||
url: function ({ date, channel }) {
|
||||
const day = dayjs().diff(date, 'd')
|
||||
return `https://programtv.onet.pl/program-tv/${channel.site_id}?dzien=${day}`
|
||||
},
|
||||
logo: function ({ content }) {
|
||||
const dom = new JSDOM(content)
|
||||
const img = dom.window.document.querySelector('#channelTV > section > header > span > img')
|
||||
|
||||
return img ? 'https:' + img.src : null
|
||||
},
|
||||
parser: function ({ content, date }) {
|
||||
const programs = []
|
||||
const dom = new JSDOM(content)
|
||||
const items = dom.window.document.querySelectorAll(
|
||||
'#channelTV > section > div.emissions > ul > li'
|
||||
)
|
||||
|
||||
items.forEach(item => {
|
||||
const title = (item.querySelector('.titles > a') || { textContent: '' }).textContent
|
||||
const description = (item.querySelector('.titles > p') || { textContent: '' }).textContent
|
||||
const category = (item.querySelector('.titles > .type') || { textContent: '' }).textContent
|
||||
const hour = (item.querySelector('.hours > .hour') || { textContent: '' }).textContent
|
||||
|
||||
const start = dayjs
|
||||
.utc(hour, 'H:mm')
|
||||
.set('D', date.get('D'))
|
||||
.set('M', date.get('M'))
|
||||
.set('y', date.get('y'))
|
||||
|
||||
if (programs.length && !programs[programs.length - 1].stop) {
|
||||
programs[programs.length - 1].stop = start
|
||||
}
|
||||
|
||||
programs.push({
|
||||
title,
|
||||
description,
|
||||
category,
|
||||
start
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue