mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update programtv.onet.pl.config.js
This commit is contained in:
parent
d2a0ef6fe3
commit
e0e399ab57
1 changed files with 6 additions and 13 deletions
|
@ -1,19 +1,12 @@
|
||||||
const cheerio = require('cheerio')
|
const cheerio = require('cheerio')
|
||||||
const dayjs = require('dayjs')
|
const { DateTime } = require('luxon')
|
||||||
const utc = require('dayjs/plugin/utc')
|
|
||||||
const timezone = require('dayjs/plugin/timezone')
|
|
||||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
|
||||||
|
|
||||||
dayjs.extend(utc)
|
|
||||||
dayjs.extend(timezone)
|
|
||||||
dayjs.extend(customParseFormat)
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
delay: 5000,
|
delay: 5000,
|
||||||
site: 'programtv.onet.pl',
|
site: 'programtv.onet.pl',
|
||||||
days: 2,
|
days: 2,
|
||||||
url: function ({ date, channel }) {
|
url: function ({ date, channel }) {
|
||||||
const currDate = dayjs.utc().startOf('d')
|
const currDate = DateTime.now().toUTC().startOf('day')
|
||||||
const day = date.diff(currDate, 'd')
|
const day = date.diff(currDate, 'd')
|
||||||
|
|
||||||
return `https://programtv.onet.pl/program-tv/${channel.site_id}?dzien=${day}`
|
return `https://programtv.onet.pl/program-tv/${channel.site_id}?dzien=${day}`
|
||||||
|
@ -26,13 +19,13 @@ module.exports = {
|
||||||
const $item = cheerio.load(item)
|
const $item = cheerio.load(item)
|
||||||
let start = parseStart($item, date)
|
let start = parseStart($item, date)
|
||||||
if (prev) {
|
if (prev) {
|
||||||
if (start.isBefore(prev.start)) {
|
if (start < prev.start) {
|
||||||
start = start.add(1, 'd')
|
start = start.plus({ days: 1 })
|
||||||
date = date.add(1, 'd')
|
date = date.add(1, 'd')
|
||||||
}
|
}
|
||||||
prev.stop = start
|
prev.stop = start
|
||||||
}
|
}
|
||||||
const stop = start.add(1, 'h')
|
const stop = start.plus({ hours: 1 })
|
||||||
programs.push({
|
programs.push({
|
||||||
title: parseTitle($item),
|
title: parseTitle($item),
|
||||||
description: parseDescription($item),
|
description: parseDescription($item),
|
||||||
|
@ -50,7 +43,7 @@ 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}`
|
||||||
|
|
||||||
return dayjs.tz(dateString, 'MM/DD/YYYY HH:mm', 'Europe/Warsaw')
|
return DateTime.fromFormat(dateString, 'MM/dd/yyyy HH:mm', { zone: 'Europe/Warsaw' }).toUTC()
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseCategory($item) {
|
function parseCategory($item) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue