mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create dtv8.net.config.js
This commit is contained in:
parent
d877f4405b
commit
3100db9226
1 changed files with 90 additions and 0 deletions
90
sites/dtv8.net/dtv8.net.config.js
Normal file
90
sites/dtv8.net/dtv8.net.config.js
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
const cheerio = require('cheerio')
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
|
|
||||||
|
dayjs.extend(utc)
|
||||||
|
dayjs.extend(timezone)
|
||||||
|
dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'dtv8.net',
|
||||||
|
days: 2,
|
||||||
|
url({ date }) {
|
||||||
|
const day = date.format('dddd')
|
||||||
|
|
||||||
|
return `https://dtv8.net/tv-listings/${day.toLowerCase()}/`
|
||||||
|
},
|
||||||
|
parser({ content, date }) {
|
||||||
|
let programs = []
|
||||||
|
|
||||||
|
const items = parseItems(content)
|
||||||
|
items.forEach(item => {
|
||||||
|
const $item = cheerio.load(item)
|
||||||
|
let prev = programs[programs.length - 1]
|
||||||
|
let start = parseStart($item, date)
|
||||||
|
if (prev) {
|
||||||
|
if (start < prev.start) {
|
||||||
|
start = start.add(1, 'd')
|
||||||
|
date = date.add(1, 'd')
|
||||||
|
}
|
||||||
|
prev.stop = start
|
||||||
|
}
|
||||||
|
const stop = start.add(30, 'm')
|
||||||
|
|
||||||
|
programs.push({
|
||||||
|
title: parseTitle($item),
|
||||||
|
description: parseDescription($item),
|
||||||
|
image: parseImage($item),
|
||||||
|
start,
|
||||||
|
stop
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return programs
|
||||||
|
},
|
||||||
|
channels() {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseTitle($item) {
|
||||||
|
return $item(
|
||||||
|
'td:nth-child(2) > strong:nth-child(1),td:nth-child(2) > span > strong,td:nth-child(2) > span > b'
|
||||||
|
).text()
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseDescription($item) {
|
||||||
|
return (
|
||||||
|
$item(
|
||||||
|
'td:nth-child(2) > strong:nth-child(3) > span,td:nth-child(2) > p:nth-child(3) > strong > span'
|
||||||
|
).text() || null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseImage($item) {
|
||||||
|
return $item('td:nth-child(1) > img.size-full').attr('src') || null
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStart($item, date) {
|
||||||
|
const time = $item('td:nth-child(1)').text()
|
||||||
|
|
||||||
|
return dayjs.tz(
|
||||||
|
`${date.format('YYYY-MM-DD')} ${time}`,
|
||||||
|
'YYYY-MM-DD HH:mm [hrs.]',
|
||||||
|
'America/Guyana'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content) {
|
||||||
|
const $ = cheerio.load(content)
|
||||||
|
|
||||||
|
return $('table tr')
|
||||||
|
.filter((i, el) => {
|
||||||
|
const firstColumn = $(el).find('td').text()
|
||||||
|
|
||||||
|
return Boolean(firstColumn) && !firstColumn.includes('Time')
|
||||||
|
})
|
||||||
|
.toArray()
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue