mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Update andorradifusio.ad.config.js
This commit is contained in:
parent
ed1d9c4b52
commit
44810b8922
1 changed files with 9 additions and 16 deletions
|
@ -1,13 +1,5 @@
|
||||||
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')
|
|
||||||
require('dayjs/locale/ca')
|
|
||||||
|
|
||||||
dayjs.extend(utc)
|
|
||||||
dayjs.extend(timezone)
|
|
||||||
dayjs.extend(customParseFormat)
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'andorradifusio.ad',
|
site: 'andorradifusio.ad',
|
||||||
|
@ -22,13 +14,13 @@ module.exports = {
|
||||||
const prev = programs[programs.length - 1]
|
const prev = programs[programs.length - 1]
|
||||||
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: item.title,
|
title: item.title,
|
||||||
start,
|
start,
|
||||||
|
@ -43,16 +35,17 @@ module.exports = {
|
||||||
function parseStart(item, date) {
|
function parseStart(item, date) {
|
||||||
const dateString = `${date.format('MM/DD/YYYY')} ${item.time}`
|
const dateString = `${date.format('MM/DD/YYYY')} ${item.time}`
|
||||||
|
|
||||||
return dayjs.tz(dateString, 'MM/DD/YYYY HH:mm', 'Europe/Madrid')
|
return DateTime.fromFormat(dateString, 'MM/dd/yyyy HH:mm', { zone: 'Europe/Madrid' }).toUTC()
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItems(content, date) {
|
function parseItems(content, date) {
|
||||||
const $ = cheerio.load(content)
|
const $ = cheerio.load(content)
|
||||||
const dayOfWeek = dayjs(date).locale('ca').format('dddd').toLowerCase()
|
const day = DateTime.fromMillis(date.valueOf()).setLocale('ca').toFormat('dd LLLL').toLowerCase()
|
||||||
const column = $('.programacio-dia > h3')
|
const column = $('.programacio-dia > h3 > .dia')
|
||||||
.filter((i, el) => $(el).text().startsWith(dayOfWeek))
|
.filter((i, el) => $(el).text() === day.slice(0, 6) + '.')
|
||||||
.first()
|
.first()
|
||||||
.parent()
|
.parent()
|
||||||
|
.parent()
|
||||||
const items = []
|
const items = []
|
||||||
const titles = column.find(`p`).toArray()
|
const titles = column.find(`p`).toArray()
|
||||||
column.find(`h4`).each((i, time) => {
|
column.find(`h4`).each((i, time) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue