diff --git a/.github/workflows/auto-update.yml b/.github/workflows/auto-update.yml index a14948a0..cc701b73 100644 --- a/.github/workflows/auto-update.yml +++ b/.github/workflows/auto-update.yml @@ -4,6 +4,21 @@ on: schedule: - cron: '0 0 * * *' 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: runs-on: ubuntu-latest steps: diff --git a/README.md b/README.md index a5e1df9e..3e4dd833 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ To load a program guide, all you need to do is copy the link to one of the guide πŸ‡ΊπŸ‡¦ Ukrainehttps://iptv-org.github.io/epg/guides/tvgid.ua.guide.xml πŸ‡¬πŸ‡§ United Kingdomhttps://iptv-org.github.io/epg/guides/ontvtonight.com.guide.xml πŸ‡ΊπŸ‡Έ United Stateshttps://iptv-org.github.io/epg/guides/tvtv.us.guide.xml + πŸ‡ΏπŸ‡² Zambiahttps://iptv-org.github.io/epg/guides/znbc.co.zm.guide.xml diff --git a/sites/znbc.co.zm.channels.xml b/sites/znbc.co.zm.channels.xml new file mode 100755 index 00000000..6fc6bc3e --- /dev/null +++ b/sites/znbc.co.zm.channels.xml @@ -0,0 +1,9 @@ + + + + TV1 + TV2 + TV3 + TV4 + + \ No newline at end of file diff --git a/sites/znbc.co.zm.config.js b/sites/znbc.co.zm.config.js new file mode 100644 index 00000000..dbc2ceff --- /dev/null +++ b/sites/znbc.co.zm.config.js @@ -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 + } +}