mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
68 lines
1.9 KiB
JavaScript
68 lines
1.9 KiB
JavaScript
const jsdom = require('jsdom')
|
|
const { JSDOM } = jsdom
|
|
const dayjs = require('dayjs')
|
|
const utc = require('dayjs/plugin/utc')
|
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
|
const timezone = require('dayjs/plugin/timezone')
|
|
require('dayjs/locale/id')
|
|
|
|
dayjs.extend(utc)
|
|
dayjs.extend(customParseFormat)
|
|
dayjs.extend(timezone)
|
|
|
|
module.exports = {
|
|
site: 'vidio.com',
|
|
url({ channel }) {
|
|
return `https://www.vidio.com/live/${channel.site_id}/schedules`
|
|
},
|
|
parser({ content, date }) {
|
|
const programs = []
|
|
const dom = new JSDOM(content)
|
|
|
|
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 => {
|
|
const title = (
|
|
item.querySelector('div.b-livestreaming-daily-schedule__item-content-title') || {
|
|
textContent: ''
|
|
}
|
|
).textContent
|
|
const time = (
|
|
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({
|
|
title,
|
|
start,
|
|
stop
|
|
})
|
|
}
|
|
})
|
|
|
|
return programs
|
|
}
|
|
}
|