mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Update vidio.com.config.js
This commit is contained in:
parent
e7354cac82
commit
93bf97c306
1 changed files with 62 additions and 43 deletions
|
@ -4,7 +4,6 @@ const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
const timezone = require('dayjs/plugin/timezone')
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
require('dayjs/locale/id')
|
|
||||||
|
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
|
@ -16,53 +15,73 @@ module.exports = {
|
||||||
return `https://www.vidio.com/live/${channel.site_id}/schedules`
|
return `https://www.vidio.com/live/${channel.site_id}/schedules`
|
||||||
},
|
},
|
||||||
parser({ content, date }) {
|
parser({ content, date }) {
|
||||||
|
let PM = false
|
||||||
const programs = []
|
const programs = []
|
||||||
const dom = new JSDOM(content)
|
const items = parseItems(content, date)
|
||||||
|
|
||||||
const scheduleDate = dom.window.document
|
|
||||||
.querySelector('div.b-livestreaming-daily-schedule__date-label')
|
|
||||||
.textContent.split(',')
|
|
||||||
const currdate = dayjs(scheduleDate[1], 'DD MMMM YYYY', 'id')
|
|
||||||
const list = dom.window.document.querySelector(
|
|
||||||
`#schedule-content-${currdate.format(
|
|
||||||
'YYYYMMDD'
|
|
||||||
)} > .b-livestreaming-daily-schedule__scroll-container`
|
|
||||||
)
|
|
||||||
const items = list.querySelectorAll('div.b-livestreaming-daily-schedule__item')
|
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
const title = (
|
const title = parseTitle(item)
|
||||||
item.querySelector('div.b-livestreaming-daily-schedule__item-content-title') || {
|
const start = parseStart(item, date)
|
||||||
textContent: ''
|
let stop = parseStop(item, date)
|
||||||
}
|
if (!stop) return
|
||||||
).textContent
|
if (stop.hour() > 11) PM = true
|
||||||
const time = (
|
if (stop.hour() < 12 && PM) stop = stop.add(1, 'd')
|
||||||
item.querySelector('div.b-livestreaming-daily-schedule__item-content-caption') || {
|
|
||||||
textContent: ''
|
|
||||||
}
|
|
||||||
).textContent
|
|
||||||
if (title && time) {
|
|
||||||
let start = dayjs.tz(
|
|
||||||
currdate.format('YYYY-MM-DD ').concat(time.substring(0, 5)),
|
|
||||||
'YYYY-MM-DD HH:mm',
|
|
||||||
'Asia/Jakarta'
|
|
||||||
)
|
|
||||||
let stop = dayjs.tz(
|
|
||||||
currdate.format('YYYY-MM-DD ').concat(time.substring(8, 13)),
|
|
||||||
'YYYY-MM-DD HH:mm',
|
|
||||||
'Asia/Jakarta'
|
|
||||||
)
|
|
||||||
if (start.diff(stop, 'h') > 0) {
|
|
||||||
stop = stop.add(1, 'day')
|
|
||||||
}
|
|
||||||
|
|
||||||
programs.push({
|
programs.push({
|
||||||
title,
|
title,
|
||||||
start,
|
start,
|
||||||
stop
|
stop
|
||||||
})
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return programs
|
return programs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseStop(item, date) {
|
||||||
|
const time = (
|
||||||
|
item.querySelector('div.b-livestreaming-daily-schedule__item-content-caption') || {
|
||||||
|
textContent: ''
|
||||||
|
}
|
||||||
|
).textContent
|
||||||
|
|
||||||
|
return dayjs.tz(
|
||||||
|
date.format('YYYY-MM-DD ').concat(time.substring(8, 13)),
|
||||||
|
'YYYY-MM-DD HH:mm',
|
||||||
|
'Asia/Jakarta'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStart(item, date) {
|
||||||
|
const time = (
|
||||||
|
item.querySelector('div.b-livestreaming-daily-schedule__item-content-caption') || {
|
||||||
|
textContent: ''
|
||||||
|
}
|
||||||
|
).textContent
|
||||||
|
|
||||||
|
return dayjs.tz(
|
||||||
|
date.format('YYYY-MM-DD ').concat(time.substring(0, 5)),
|
||||||
|
'YYYY-MM-DD HH:mm',
|
||||||
|
'Asia/Jakarta'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseTitle(item) {
|
||||||
|
return (
|
||||||
|
item.querySelector('div.b-livestreaming-daily-schedule__item-content-title') || {
|
||||||
|
textContent: ''
|
||||||
|
}
|
||||||
|
).textContent
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content, date) {
|
||||||
|
const dom = new JSDOM(content)
|
||||||
|
const list = dom.window.document.querySelector(
|
||||||
|
`#schedule-content-${date.format(
|
||||||
|
'YYYYMMDD'
|
||||||
|
)} > .b-livestreaming-daily-schedule__scroll-container`
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!list) return []
|
||||||
|
|
||||||
|
return list.querySelectorAll('div.b-livestreaming-daily-schedule__item')
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue