mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
revamp
it should work now
This commit is contained in:
parent
1c7a1c989c
commit
c91733e143
1 changed files with 23 additions and 22 deletions
|
@ -21,26 +21,26 @@ module.exports = {
|
|||
parser({ content, date }) {
|
||||
const programs = []
|
||||
const dom = new JSDOM(content)
|
||||
if (dom.window.document.querySelector('div.livestreaming-empty-state')) return programs
|
||||
|
||||
const currdate = dayjs(
|
||||
dom.window.document.querySelector('div.b-livestreaming-daily-schedule__date-label').textContent,
|
||||
'DDDD, DD MMMM YYYY', 'id')
|
||||
const items = dom.window.document.querySelectorAll('div.b-livestreaming-daily-schedule__item')
|
||||
dom.window.document.querySelector('div.b-livestreaming-daily-schedule__date-label').textContent)
|
||||
const lists = dom.window.document.querySelectorAll('div.b-livestreaming-daily-schedule__content')
|
||||
lists.forEach(list => {
|
||||
const listdate = currdate.add(
|
||||
JSON.parse(list.querySelector('div.b-livestreaming-schedule__ahoy-impression').getAttribute('data-ahoy-props') || {}).schedule_day, 'day')
|
||||
|
||||
const items = list.querySelectorAll('div.b-livestreaming-daily-schedule__item')
|
||||
items.forEach(item => {
|
||||
const title = (item.querySelector('div.b-livestreaming-daily-schedule__item-content-title') || { textContent: '' }).textContent
|
||||
const time = (item.querySelector('b-livestreaming-daily-schedule__item-content-caption') || { textContent: '' }).textContent
|
||||
const it_date = currdate.add(JSON.parse(item.getAttribute('data-ahoy-props') || '{}').schedule_day, 'day')
|
||||
|
||||
const time = (item.querySelector('div.b-livestreaming-daily-schedule__item-content-caption') || { textContent: '' }).textContent
|
||||
if (title && time) {
|
||||
let start = dayjs(it_date.format('YYYY-MM-DD ').concat(time.substring(0,5)), 'YYYY-MM-DD HH:mm')
|
||||
let stop = dayjs(it_date.format('YYYY-MM-DD ').concat(time.substring(8,13)), 'YYYY-MM-DD HH:mm')
|
||||
if start.diff(stop, 'h') < 0 {
|
||||
let start = dayjs(listdate.format('YYYY-MM-DD ').concat(time.substring(0,5)), 'YYYY-MM-DD HH:mm')
|
||||
let stop = dayjs(listdate.format('YYYY-MM-DD ').concat(time.substring(8,13)), 'YYYY-MM-DD HH:mm')
|
||||
if (start.diff(stop, 'h') < 0) {
|
||||
stop = stop.add(1, 'day')
|
||||
}
|
||||
|
||||
if (it_date.diff(date.format('YYYY-MM-DD'), 'd') === 0) {
|
||||
if (listdate.diff(date.format('YYYY-MM-DD'), 'd') === 0) {
|
||||
programs.push({
|
||||
title,
|
||||
start,
|
||||
|
@ -49,6 +49,7 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue