Fixes sporttv.pt parser

This commit is contained in:
theofficialomega
2026-06-08 11:22:47 +02:00
parent 51e65ab11d
commit 7a60898301
5 changed files with 838 additions and 61727 deletions
+15 -15
View File
@@ -7,48 +7,48 @@ const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat)
dayjs.extend(utc)
const date = dayjs.utc('2024-12-23', 'YYYY-MM-DD').startOf('d')
const date = dayjs.utc('2026-06-08', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: 727,
xmltv_id: 'SportTV1.pt'
}
it('can generate valid url', () => {
expect(url).toBe('https://www.sporttv.pt/guia')
expect(url({ date, channel })).toBe(`https://www.sporttv.pt/api/channels/epg?dataInicio=${date.format('DD/MM/YYYY%20HH:mm')}&dataFim=${date.add(1, 'day').format('DD/MM/YYYY%20HH:mm')}&tipoMedia=thumbnail&idCanal=${channel.site_id}`)
})
it('can parse response', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'), 'utf-8')
const results = parser({ content, date, channel }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results.length).toBe(19)
expect(results.length).toBe(7)
expect(results[0]).toMatchObject({
start: '2024-12-23T01:00:00.000Z',
stop: '2024-12-23T01:30:00.000Z',
description: 'LIGA PORTUGAL BETCLIC',
start: '2026-06-08T00:59:54.000Z',
stop: '2026-06-08T03:00:21.000Z',
description: 'JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL',
category: 'FUTEBOL',
title: 'RESUMOS DA JORNADA 15',
image: 'https://www.sporttv.pt/default/0001/11/08cb25f0b9b427e0bb83179309074632410f536b.jpg'
title: 'CROÁCIA X ESLOVÉNIA',
image: 'https://www.sporttv.pt/default/0001/11/175ab04d3ec614f86ec6771823b7921f137d2c91.jpg'
})
expect(results[1]).toMatchObject({
start: '2024-12-23T01:30:00.000Z',
stop: '2024-12-23T02:00:00.000Z',
description: 'LIGA ITALIANA',
start: '2026-06-08T03:00:21.000Z',
stop: '2026-06-08T03:54:56.000Z',
description: 'LIGA ITALIANA 2025/2026 - HIGHLIGHTS - FUTEBOL',
category: 'FUTEBOL',
title: 'RESUMOS DA JORNADA 17',
title: 'RESUMO DA ÉPOCA',
image:
'https://www.sporttv.pt/cms_media/default/0001/11/56ab6bb72a00c8a9543eff35f90f57c07fb0ff87.jpg'
'https://www.sporttv.pt/default/0001/11/72f8a4f9569763b7dfdce68dbac3b33024e34b26.jpg'
})
})
it('can handle empty guide', () => {
const content = ''
const content = []
const result = parser({ content, date })
expect(result).toMatchObject([])
})