mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-12 01:50:07 -04:00
Merge pull request #61 from iptv-org/update-hd-plus-de
Update hd-plus.de.config.js
This commit is contained in:
commit
29671884bc
1 changed files with 34 additions and 21 deletions
|
@ -2,12 +2,12 @@ const jsdom = require('jsdom')
|
||||||
const { JSDOM } = jsdom
|
const { JSDOM } = jsdom
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
|
||||||
const timezone = require('dayjs/plugin/timezone')
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
|
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
dayjs.extend(customParseFormat)
|
|
||||||
dayjs.extend(timezone)
|
dayjs.extend(timezone)
|
||||||
|
dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
lang: 'de',
|
lang: 'de',
|
||||||
|
@ -26,29 +26,42 @@ module.exports = {
|
||||||
|
|
||||||
return img ? img.src : null
|
return img ? img.src : null
|
||||||
},
|
},
|
||||||
parser({ content }) {
|
parser({ content, date }) {
|
||||||
const dom = new JSDOM(content)
|
const programs = []
|
||||||
const items = dom.window.document.querySelectorAll('table > tbody > tr')
|
const items = parseItems(content)
|
||||||
let programs = []
|
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
const title = (item.querySelector('td:nth-child(1) > a') || { textContent: '' }).textContent
|
const title = parseTitle(item)
|
||||||
const fullDate = (item.querySelector('td:nth-child(2)') || { textContent: '' }).textContent
|
let start = parseStart(item, date)
|
||||||
if (title && fullDate) {
|
const stop = parseStop(item, date)
|
||||||
const time = fullDate.split(' ').pop()
|
if (programs.length) {
|
||||||
const local = dayjs.utc(time, 'HH:mm').toString()
|
programs[programs.length - 1].stop = start
|
||||||
const start = dayjs.tz(local.toString(), 'Europe/Berlin').toString()
|
|
||||||
|
|
||||||
if (programs.length && !programs[programs.length - 1].stop) {
|
|
||||||
programs[programs.length - 1].stop = start
|
|
||||||
}
|
|
||||||
|
|
||||||
programs.push({
|
|
||||||
title,
|
|
||||||
start
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
programs.push({ title, start, stop })
|
||||||
})
|
})
|
||||||
|
|
||||||
return programs
|
return programs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseStop(item, date) {
|
||||||
|
return date.endOf('d')
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStart(item, date) {
|
||||||
|
let time = (item.querySelector('td:nth-child(2)') || { textContent: '' }).textContent
|
||||||
|
time = time.split(' ').pop()
|
||||||
|
time = `${date.format('MM/DD/YYYY')} ${time}`
|
||||||
|
|
||||||
|
return dayjs.tz(time, 'MM/DD/YYYY HH:mm', 'Europe/Berlin')
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseTitle(item) {
|
||||||
|
return (item.querySelector('td:nth-child(1) > a') || { textContent: '' }).textContent
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content) {
|
||||||
|
const dom = new JSDOM(content)
|
||||||
|
|
||||||
|
return dom.window.document.querySelectorAll('table > tbody > tr')
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue