mirror of
https://github.com/iptv-org/epg
synced 2026-04-10 04:42:55 -04:00
Merge pull request #3045 from daniloroxette/add-tvufop-source
Add app.tvufop.com.br source for TV UFOP
This commit is contained in:
1
SITES.md
1
SITES.md
@@ -14,6 +14,7 @@
|
||||
<tr><td><a href="sites/antennaeurope.gr">antennaeurope.gr</a></td><td align="right">1</td><td align="right">1</td><td align="center">🟢</td><td></td></tr>
|
||||
<tr><td><a href="sites/antennapacific.gr">antennapacific.gr</a></td><td align="right">1</td><td align="right">1</td><td align="center">🟢</td><td></td></tr>
|
||||
<tr><td><a href="sites/antennasatellite.gr">antennasatellite.gr</a></td><td align="right">1</td><td align="right">1</td><td align="center">🟢</td><td></td></tr>
|
||||
<tr><td><a href="sites/app.tvufop.com.br">app.tvufop.com.br</a></td><td align="right">1</td><td align="right">1</td><td align="center">🟢</td><td></td></tr>
|
||||
<tr><td><a href="sites/arianatelevision.com">arianatelevision.com</a></td><td align="right">1</td><td align="right">1</td><td align="center">🟢</td><td></td></tr>
|
||||
<tr><td><a href="sites/arirang.com">arirang.com</a></td><td align="right">3</td><td align="right">3</td><td align="center">🟢</td><td></td></tr>
|
||||
<tr><td><a href="sites/artonline.tv">artonline.tv</a></td><td align="right">5</td><td align="right">5</td><td align="center">🟢</td><td></td></tr>
|
||||
|
||||
7
sites/app.tvufop.com.br/app.tvufop.com.br.channels.xml
Normal file
7
sites/app.tvufop.com.br/app.tvufop.com.br.channels.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<channels>
|
||||
|
||||
<channel site="app.tvufop.com.br" lang="pt" xmltv_id="TVUFOP.br@HD" site_id="TVUFOP.br@HD">TV UFOP</channel>
|
||||
|
||||
</channels>
|
||||
167
sites/app.tvufop.com.br/app.tvufop.com.br.config.js
Normal file
167
sites/app.tvufop.com.br/app.tvufop.com.br.config.js
Normal file
@@ -0,0 +1,167 @@
|
||||
const { File } = require('node:buffer')
|
||||
|
||||
|
||||
if (typeof global.File === 'undefined') {
|
||||
|
||||
global.File = File
|
||||
|
||||
}
|
||||
|
||||
|
||||
const cheerio = require('cheerio')
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
||||
site: 'app.tvufop.com.br',
|
||||
|
||||
days: 7,
|
||||
|
||||
url() {
|
||||
|
||||
return 'https://app.tvufop.com.br/epg/epg_tvufop_web.xml'
|
||||
|
||||
},
|
||||
|
||||
parser({ content, channel, date }) {
|
||||
|
||||
const $ = cheerio.load(content || '', { xmlMode: true, decodeEntities: false })
|
||||
|
||||
const programs = []
|
||||
|
||||
|
||||
const dayStart = date.startOf('d').toDate()
|
||||
|
||||
const dayEnd = date.add(1, 'd').startOf('d').toDate()
|
||||
|
||||
|
||||
$(`programme[channel="${channel.site_id}"]`).each((_, el) => {
|
||||
|
||||
const $el = $(el)
|
||||
|
||||
|
||||
const start = parseXmltvDate($el.attr('start'))
|
||||
|
||||
const stop = parseXmltvDate($el.attr('stop'))
|
||||
|
||||
|
||||
if (!start || !stop) return
|
||||
|
||||
if (start >= dayEnd || stop <= dayStart) return
|
||||
|
||||
|
||||
const title = textOf($el, 'title')
|
||||
|
||||
if (!title) return
|
||||
|
||||
|
||||
const item = {
|
||||
|
||||
title,
|
||||
|
||||
start,
|
||||
|
||||
stop
|
||||
|
||||
}
|
||||
|
||||
|
||||
const description = textOf($el, 'desc')
|
||||
|
||||
if (description) item.description = description
|
||||
|
||||
|
||||
const icon = $el.find('icon').attr('src')
|
||||
|
||||
if (icon) item.icon = icon
|
||||
|
||||
|
||||
const rating = $el.find('rating > value').first().text().trim()
|
||||
|
||||
if (rating) item.rating = rating
|
||||
|
||||
|
||||
programs.push(item)
|
||||
|
||||
})
|
||||
|
||||
|
||||
return programs
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function textOf($el, tagName) {
|
||||
|
||||
return $el.find(tagName).first().text().trim()
|
||||
|
||||
}
|
||||
|
||||
|
||||
function parseXmltvDate(value) {
|
||||
|
||||
if (!value) return null
|
||||
|
||||
|
||||
const m = value.trim().match(
|
||||
|
||||
/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})\s+([+-])(\d{2})(\d{2})$/
|
||||
|
||||
)
|
||||
|
||||
|
||||
if (!m) return null
|
||||
|
||||
|
||||
const [
|
||||
|
||||
,
|
||||
|
||||
year,
|
||||
|
||||
month,
|
||||
|
||||
day,
|
||||
|
||||
hour,
|
||||
|
||||
minute,
|
||||
|
||||
second,
|
||||
|
||||
sign,
|
||||
|
||||
tzHour,
|
||||
|
||||
tzMinute
|
||||
|
||||
] = m
|
||||
|
||||
|
||||
const utcMs = Date.UTC(
|
||||
|
||||
Number(year),
|
||||
|
||||
Number(month) - 1,
|
||||
|
||||
Number(day),
|
||||
|
||||
Number(hour),
|
||||
|
||||
Number(minute),
|
||||
|
||||
Number(second)
|
||||
|
||||
)
|
||||
|
||||
|
||||
const offsetMinutes =
|
||||
|
||||
(Number(tzHour) * 60 + Number(tzMinute)) * (sign === '+' ? 1 : -1)
|
||||
|
||||
|
||||
return new Date(utcMs - offsetMinutes * 60 * 1000)
|
||||
|
||||
}
|
||||
97
sites/app.tvufop.com.br/app.tvufop.com.br.test.js
Normal file
97
sites/app.tvufop.com.br/app.tvufop.com.br.test.js
Normal file
@@ -0,0 +1,97 @@
|
||||
|
||||
const { parser, url } = require('./app.tvufop.com.br.config.js')
|
||||
|
||||
const dayjs = require('dayjs')
|
||||
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
|
||||
|
||||
const date = dayjs.utc('2026-03-28', 'YYYY-MM-DD').startOf('d')
|
||||
|
||||
const channel = {
|
||||
|
||||
site_id: 'TVUFOP.br@HD',
|
||||
|
||||
xmltv_id: 'TVUFOP.br@HD',
|
||||
|
||||
lang: 'pt'
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
it('can generate valid url', () => {
|
||||
|
||||
expect(url({ channel, date })).toBe('https://app.tvufop.com.br/epg/epg_tvufop_web.xml')
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
it('can parse response', () => {
|
||||
|
||||
const content = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<tv>
|
||||
|
||||
<channel id="TVUFOP.br@HD">
|
||||
|
||||
<display-name lang="pt-BR">TV UFOP</display-name>
|
||||
|
||||
</channel>
|
||||
|
||||
<programme start="20260328000001 -0300" stop="20260328001322 -0300" channel="TVUFOP.br@HD">
|
||||
|
||||
<title lang="pt-BR">(FUTURA) CANAL DA HISTÓRIA - CARMEN MIRANDA</title>
|
||||
|
||||
<desc lang="pt-BR">Clara e Neto usam uma máquina do tempo.</desc>
|
||||
|
||||
<icon src="https://app.tvufop.com.br/epg/CANAL.jpg" />
|
||||
|
||||
<rating system="DJCTQ"><value>Livre</value></rating>
|
||||
|
||||
</programme>
|
||||
|
||||
</tv>`
|
||||
|
||||
|
||||
|
||||
const results = parser({ content, channel, date })
|
||||
|
||||
|
||||
|
||||
expect(results.length).toBe(1)
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
|
||||
title: '(FUTURA) CANAL DA HISTÓRIA - CARMEN MIRANDA',
|
||||
|
||||
description: 'Clara e Neto usam uma máquina do tempo.',
|
||||
|
||||
icon: 'https://app.tvufop.com.br/epg/CANAL.jpg',
|
||||
|
||||
rating: 'Livre'
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
|
||||
const results = parser({ content: '', channel, date })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
|
||||
})
|
||||
|
||||
17
sites/app.tvufop.com.br/readme.md
Normal file
17
sites/app.tvufop.com.br/readme.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# app.tvufop.com.br
|
||||
|
||||
XMLTV source for TV UFOP:
|
||||
|
||||
https://app.tvufop.com.br/epg/epg_tvufop_web.xml
|
||||
|
||||
### Download the guide
|
||||
|
||||
Run:
|
||||
|
||||
npm run grab --- --site=app.tvufop.com.br
|
||||
|
||||
### Test
|
||||
|
||||
Run:
|
||||
|
||||
npm test --- app.tvufop.com.br
|
||||
Reference in New Issue
Block a user