Merge pull request #101 from iptv-org/add-arianaafgtv-com

Add guide from arianaafgtv.com
This commit is contained in:
Shadix A 2021-09-23 19:45:01 +03:00 committed by GitHub
commit 9e928c1b87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 96 additions and 1 deletions

View file

@ -13,6 +13,7 @@ jobs:
site:
[
andorradifusio.ad,
arianaafgtv.com,
arianatelevision.com,
astro.com.my,
comteco.com.bo,

View file

@ -18,7 +18,8 @@ To load a program guide, all you need to do is copy the link to one of the guide
<tr><th align="left">Country</th><th align="left">EPG</th></tr>
</thead>
<tbody>
<tr><td align="left" nowrap>🇦🇫 Afghanistan</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/arianatelevision.com.guide.xml</code></td></tr>
<tr><td align="left" rowspan="2" valign="top" nowrap>🇦🇫 Afghanistan</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/arianaafgtv.com.guide.xml</code></td></tr>
<tr><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/arianatelevision.com.guide.xml</code></td></tr>
<tr><td align="left" nowrap>🇩🇿 Algeria</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/elcinema.com.guide.xml</code></td></tr>
<tr><td align="left" nowrap>🇦🇱 Albania</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/tvprofil.com.guide.xml</code></td></tr>
<tr><td align="left" nowrap>🇦🇩 Andorra</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/andorradifusio.ad.guide.xml</code></td></tr>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<site site="arianaafgtv.com">
<channels>
<channel site_id="#" xmltv_id="ArianaAfghanistanInternationalTV.af">Ariana Afghanistan International TV</channel>
</channels>
</site>

View file

@ -0,0 +1,87 @@
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 = {
lang: 'en',
days: 7,
site: 'arianaafgtv.com',
channels: 'arianaafgtv.com.channels.xml',
output: '.gh-pages/guides/arianaafgtv.com.guide.xml',
url() {
return `https://www.arianaafgtv.com/index.html`
},
parser({ content, date }) {
const programs = []
const items = parseItems(content, date)
items.forEach(item => {
const title = item.title
const start = parseStart(item, date)
const stop = parseStop(item, date)
programs.push({
title,
start,
stop
})
})
return programs
}
}
function parseStop(item, date) {
const time = `${date.format('MM/DD/YYYY')} ${item.end.toUpperCase()}`
return dayjs.tz(time, 'MM/DD/YYYY hh:mm A', 'Asia/Kabul')
}
function parseStart(item, date) {
const time = `${date.format('MM/DD/YYYY')} ${item.start.toUpperCase()}`
return dayjs.tz(time, 'MM/DD/YYYY hh:mm A', 'Asia/Kabul')
}
function parseItems(content, date) {
const $ = cheerio.load(content)
const dayOfWeek = date.format('dddd')
const column = $('.H4')
.filter((i, el) => {
return $(el).text() === dayOfWeek
})
.first()
.parent()
const rows = column
.find('.Paragraph')
.map((i, el) => {
return $(el).html()
})
.toArray()
.map(r => (r === '&nbsp;' ? '|' : r))
.join(' ')
.split('|')
const items = []
rows.forEach(row => {
row = row.trim()
if (row) {
const found = row.match(/(\d+(|:\d+)(a|p)m-\d+(|:\d+)(a|p)m)/gi)
if (!found) return
const time = found[0]
let start = time.match(/(\d+(|:\d+)(a|p)m)-/i)[1]
start = dayjs(start.toUpperCase(), ['hh:mmA', 'h:mmA', 'hA']).format('hh:mm A')
let end = time.match(/-(\d+(|:\d+)(a|p)m)/i)[1]
end = dayjs(end.toUpperCase(), ['hh:mmA', 'h:mmA', 'hA']).format('hh:mm A')
const title = row.replace(time, '').replace('&nbsp;', '').trim()
items.push({ start, end, title })
}
})
return items
}