Added guide from znbc.co.zm
This commit is contained in:
9
sites/znbc.co.zm.channels.xml
Executable file
9
sites/znbc.co.zm.channels.xml
Executable file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="znbc.co.zm">
|
||||
<channels>
|
||||
<channel site_id="tv1" xmltv_id="TV1.zm">TV1</channel>
|
||||
<channel site_id="tv2" xmltv_id="TV2.zm">TV2</channel>
|
||||
<channel site_id="tv3" xmltv_id="TV3.zm">TV3</channel>
|
||||
<channel site_id="tv4" xmltv_id="TV4.zm">TV4</channel>
|
||||
</channels>
|
||||
</site>
|
||||
63
sites/znbc.co.zm.config.js
Normal file
63
sites/znbc.co.zm.config.js
Normal file
@@ -0,0 +1,63 @@
|
||||
const jsdom = require('jsdom')
|
||||
const { JSDOM } = jsdom
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
module.exports = {
|
||||
lang: 'en',
|
||||
site: 'znbc.co.zm',
|
||||
channels: 'znbc.co.zm.channels.xml',
|
||||
output: '.gh-pages/guides/znbc.co.zm.guide.xml',
|
||||
url({ channel }) {
|
||||
return `https://www.znbc.co.zm/${channel.site_id}/`
|
||||
},
|
||||
logo({ content }) {
|
||||
const dom = new JSDOM(content)
|
||||
const img = dom.window.document.querySelector(
|
||||
'.elementor-tabs-content-wrapper > .elementor-tab-content > table > tbody > tr:nth-child(1) > td > span > img'
|
||||
)
|
||||
|
||||
return img ? img.dataset.src : null
|
||||
},
|
||||
parser({ content, date }) {
|
||||
const day = date.day() // 0 => Sunday
|
||||
const programs = []
|
||||
const dom = new JSDOM(content)
|
||||
const tabs = dom.window.document.querySelectorAll(
|
||||
`.elementor-tabs-content-wrapper > div[id*='elementor-tab-content']`
|
||||
)
|
||||
const items = tabs[day].querySelectorAll(`table > tbody > tr`)
|
||||
|
||||
items.forEach(item => {
|
||||
const row = (item.querySelector('td > p') || { textContent: '' }).textContent
|
||||
const parts = row.split(' ')
|
||||
const time = parts.shift()
|
||||
const title = parts.filter(str => str && /\S/.test(str)).join(' ')
|
||||
|
||||
if (!time || !title) return false
|
||||
|
||||
const start = dayjs
|
||||
.utc(time, 'HH:mm')
|
||||
.set('D', date.get('D'))
|
||||
.set('M', date.get('M'))
|
||||
.set('y', date.get('y'))
|
||||
|
||||
if (!start.isValid()) return false
|
||||
|
||||
if (programs.length && !programs[programs.length - 1].stop) {
|
||||
programs[programs.length - 1].stop = start
|
||||
}
|
||||
|
||||
programs.push({
|
||||
title,
|
||||
start
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user