mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update cosmote.gr.config.js
This commit is contained in:
parent
2a9be054d5
commit
4685dd20a5
1 changed files with 14 additions and 17 deletions
|
@ -1,35 +1,32 @@
|
|||
const cheerio = require('cheerio')
|
||||
const dayjs = require('dayjs')
|
||||
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)
|
||||
const { DateTime } = require('luxon')
|
||||
|
||||
module.exports = {
|
||||
site: 'cosmote.gr',
|
||||
days: 2,
|
||||
url: function ({ date, channel }) {
|
||||
return `https://www.cosmote.gr/cosmotetv/residential/program/epg/programchannel?p_p_id=channelprogram_WAR_OTETVportlet&p_p_lifecycle=0&_channelprogram_WAR_OTETVportlet_platform=IPTV&_channelprogram_WAR_OTETVportlet_date=${date.format(
|
||||
return `https://www.cosmotetv.gr/portal/residential/program/epg/programchannel?p_p_id=channelprogram_WAR_OTETVportlet&p_p_lifecycle=0&_channelprogram_WAR_OTETVportlet_platform=IPTV&_channelprogram_WAR_OTETVportlet_date=${date.format(
|
||||
'DD-MM-YYYY'
|
||||
)}&_channelprogram_WAR_OTETVportlet_articleTitleUrl=${channel.site_id}`
|
||||
},
|
||||
parser: function ({ date, content }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
items.forEach((item, i) => {
|
||||
const prev = programs[programs.length - 1]
|
||||
const $item = cheerio.load(item)
|
||||
let start = parseStart($item, date)
|
||||
if (prev && start.isBefore(prev.start)) {
|
||||
start = start.add(1, 'd')
|
||||
if (i === 0 && start.hour > 12 && start.hour < 21) {
|
||||
date = date.subtract(1, 'd')
|
||||
start = start.minus({ days: 1 })
|
||||
}
|
||||
if (prev && start < prev.start) {
|
||||
start = start.plus({ days: 1 })
|
||||
date = date.add(1, 'd')
|
||||
}
|
||||
let stop = parseStop($item, date)
|
||||
if (stop.isBefore(start)) {
|
||||
stop = stop.add(1, 'd')
|
||||
if (stop < start) {
|
||||
stop = stop.plus({ days: 1 })
|
||||
date = date.add(1, 'd')
|
||||
}
|
||||
programs.push({
|
||||
|
@ -64,18 +61,18 @@ function parseStart($item, date) {
|
|||
const timeString = $item('span.start-time').text()
|
||||
const dateString = `${date.format('YYYY-MM-DD')} ${timeString}`
|
||||
|
||||
return dayjs.tz(dateString, 'YYYY-MM-DD HH:mm', 'Europe/Athens')
|
||||
return DateTime.fromFormat(dateString, 'yyyy-MM-dd HH:mm', { zone: 'Europe/Athens' }).toUTC()
|
||||
}
|
||||
|
||||
function parseStop($item, date) {
|
||||
const timeString = $item('span.end-time').text()
|
||||
const dateString = `${date.format('YYYY-MM-DD')} ${timeString}`
|
||||
|
||||
return dayjs.tz(dateString, 'YYYY-MM-DD HH:mm', 'Europe/Athens')
|
||||
return DateTime.fromFormat(dateString, 'yyyy-MM-dd HH:mm', { zone: 'Europe/Athens' }).toUTC()
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
return $('#_channelprogram_WAR_OTETVportlet_programs > tr.visible-xs').toArray()
|
||||
return $('#_channelprogram_WAR_OTETVportlet_programs > tr.d-sm-table-row').toArray()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue