Added guide from znbc.co.zm

This commit is contained in:
freearhey 2021-04-24 13:39:46 +03:00
parent f542ca8c63
commit ce88787d45
4 changed files with 88 additions and 0 deletions

View file

@ -4,6 +4,21 @@ on:
schedule: schedule:
- cron: '0 0 * * *' - cron: '0 0 * * *'
jobs: jobs:
znbc_co_zm:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.1
- name: Install Dependencies
run: npm install
- name: Run EPG Grabber
run: npx epg-grabber --config=sites/znbc.co.zm.config.js
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@4.1.1
with:
branch: gh-pages
folder: .gh-pages
clean: false
hd-plus_de: hd-plus_de:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

View file

@ -43,6 +43,7 @@ To load a program guide, all you need to do is copy the link to one of the guide
<tr><td align="left" nowrap>🇺🇦 Ukraine</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/tvgid.ua.guide.xml</code></td></tr> <tr><td align="left" nowrap>🇺🇦 Ukraine</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/tvgid.ua.guide.xml</code></td></tr>
<tr><td align="left" nowrap>🇬🇧 United Kingdom</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/ontvtonight.com.guide.xml</code></td></tr> <tr><td align="left" nowrap>🇬🇧 United Kingdom</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/ontvtonight.com.guide.xml</code></td></tr>
<tr><td align="left" nowrap>🇺🇸 United States</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/tvtv.us.guide.xml</code></td></tr> <tr><td align="left" nowrap>🇺🇸 United States</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/tvtv.us.guide.xml</code></td></tr>
<tr><td align="left" nowrap>🇿🇲 Zambia</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/znbc.co.zm.guide.xml</code></td></tr>
</tbody> </tbody>
</table> </table>

9
sites/znbc.co.zm.channels.xml Executable file
View 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>

View 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
}
}