diff --git a/.github/workflows/auto-update.yml b/.github/workflows/auto-update.yml index fa4d4c4e..0d8a6f9b 100644 --- a/.github/workflows/auto-update.yml +++ b/.github/workflows/auto-update.yml @@ -4,6 +4,23 @@ on: schedule: - cron: '0 0 * * *' jobs: + andorradifusio_ad: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Install Dependencies + run: npm install + - name: Run EPG Grabber + run: npx epg-grabber --config=sites/andorradifusio.ad.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 znbc_co_zm: runs-on: ubuntu-latest steps: diff --git a/README.md b/README.md index 3e4dd833..cea3ec42 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ To load a program guide, all you need to do is copy the link to one of the guide 🇦🇱 Albaniahttps://iptv-org.github.io/epg/guides/albepg.com.guide.xml + 🇦🇩 Andorrahttps://iptv-org.github.io/epg/guides/andorradifusio.ad.guide.xml 🇦🇷 Argentinahttps://iptv-org.github.io/epg/guides/mi.tv.guide.xml 🇦🇺 Australiahttps://iptv-org.github.io/epg/guides/ontvtonight.com.guide.xml 🇧🇾 Belarushttps://iptv-org.github.io/epg/guides/tv.yandex.ru.guide.xml diff --git a/sites/andorradifusio.ad.channels.xml b/sites/andorradifusio.ad.channels.xml new file mode 100755 index 00000000..99481bf1 --- /dev/null +++ b/sites/andorradifusio.ad.channels.xml @@ -0,0 +1,6 @@ + + + + ATV + + \ No newline at end of file diff --git a/sites/andorradifusio.ad.config.js b/sites/andorradifusio.ad.config.js new file mode 100644 index 00000000..476da9f6 --- /dev/null +++ b/sites/andorradifusio.ad.config.js @@ -0,0 +1,51 @@ +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: 'ca', + site: 'andorradifusio.ad', + channels: 'andorradifusio.ad.channels.xml', + output: '.gh-pages/guides/andorradifusio.ad.guide.xml', + url({ channel }) { + return `https://www.andorradifusio.ad/programacio/${channel.site_id}` + }, + parser({ content, date }) { + const day = date.day() - 1 + const programs = [] + const dom = new JSDOM(content) + const cols = dom.window.document.querySelectorAll('.programacio-dia') + const colNum = day < 0 ? 6 : day + const times = cols[colNum].querySelectorAll(`h4`) + const titles = cols[colNum].querySelectorAll(`p`) + + times.forEach((time, i) => { + const title = titles[i] ? titles[i].textContent : null + if (!time || !title) return false + + const start = dayjs + .utc(time.textContent, '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 + } +}