Merge pull request #3169 from iptv-org/be-sporttv-fix

PT: fixes sporttv.pt parser
This commit is contained in:
PopeyeTheSai10r
2026-06-21 07:24:18 -07:00
committed by GitHub
5 changed files with 838 additions and 61727 deletions
File diff suppressed because one or more lines are too long
+780
View File
@@ -0,0 +1,780 @@
[
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "PORTUGAL X COSTA DO MARFIM",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 1803000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "Long Summary",
"agregador2": {
"id": 0,
"nome": "TORNEIO MAURICE REVELLO - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "TORNEIO MAURICE REVELLO - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2600136_0012",
"imagem": "https://www.sporttv.pt/default/0001/11/48b37458f268d3f45f360e978fe5c4763844fea8.jpg",
"id": 10686082649,
"data": 1780820420000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10686082649
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "BRASIL X EGITO",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 7150000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "Recorded",
"agregador2": {
"id": 0,
"nome": "JOGOS DE PREPARAÇÃO DO BRASIL - MUNDIAL - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "JOGOS DE PREPARAÇÃO DO BRASIL - MUNDIAL - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2600244_0005",
"imagem": "https://www.sporttv.pt/default/0001/11/5e2029855364ab3f41c7c7c49b9a2e8c191da94f.jpg",
"id": 10686065565,
"data": 1780822223000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10686065565
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "PORTUGAL X CHILE",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 7219000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "Recorded",
"agregador2": {
"id": 0,
"nome": "JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2500195_0043",
"imagem": "https://www.sporttv.pt/default/0001/11/72f8a4f9569763b7dfdce68dbac3b33024e34b26.jpg",
"id": 10686065528,
"data": 1780829373000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10686065528
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "CONGO X COLÔMBIA",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 7792000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "DIRETO",
"agregador2": {
"id": 0,
"nome": "TORNEIO MAURICE REVELLO - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "TORNEIO MAURICE REVELLO - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2600136_0013",
"imagem": "https://www.sporttv.pt/default/0001/11/17bc4d0b90262ea72eb449ed766a74a781b9cf77.jpg",
"id": 10685051610,
"data": 1780836592000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10685051610
},
{
"agregador1": {
"id": 0,
"nome": "INFORMAÇÃO"
},
"descricao": "ANA CAPETA",
"modalidade": {
"nomeModalidade": "INFORMAÇÃO",
"codigo": "informacao"
},
"duracao": 1815000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "Magazine",
"agregador2": {
"id": 0,
"nome": "JOGAR EM CASA - INFORMAÇÃO"
},
"evento": {
"id": 0,
"nome": "JOGAR EM CASA - INFORMAÇÃO",
"premium": false
},
"exclusivo": false,
"idPrograma": "2600255_0007",
"imagem": "https://www.sporttv.pt/default/0001/11/edf8687060c1ad8d4ca183a3c8212bad2c86cc4b.jpg",
"id": 10686081999,
"data": 1780844384000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10686081999
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "MAGAZINE",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 3001000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "Magazine",
"agregador2": {
"id": 0,
"nome": "UEFA CHAMPIONS LEAGUE 2025/26 - MAGAZINES - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "UEFA CHAMPIONS LEAGUE 2025/26 - MAGAZINES - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2500244-0036",
"imagem": "https://www.sporttv.pt/default/0001/11/3cf573ea63a14414f54130d6abef69c3f48583b3.jpg",
"id": 10685142649,
"data": 1780846199000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10685142649
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "DINAMARCA X UCRÂNIA",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 7705000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "DIRETO",
"agregador2": {
"id": 0,
"nome": "JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2500195_0049",
"imagem": "https://www.sporttv.pt/default/0001/11/5e2029855364ab3f41c7c7c49b9a2e8c191da94f.jpg",
"id": 10685542949,
"data": 1780849240000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10685542949
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "FESTA DA TAÇA DE PORTUGAL",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 1236000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "Magazine",
"agregador2": {
"id": 0,
"nome": "VAMOS À BOLA - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "VAMOS À BOLA - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2500320-0037",
"imagem": "https://www.sporttv.pt/default/0001/11/efe2500bfa8d059171855f7c206b574c08fab9b2.jpg",
"id": 10686335604,
"data": 1780856945000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10686335604
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "GRÉCIA X ITÁLIA",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 7850000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "DIRETO",
"agregador2": {
"id": 0,
"nome": "JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2500195_0050",
"imagem": "https://www.sporttv.pt/default/0001/11/a3b89370f54cd3018ef988f4c2d1b66f14d3af48.jpg",
"id": 10685543059,
"data": 1780858181000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10685543059
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "RESUMO DA ÉPOCA",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 3350000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "Magazine",
"agregador2": {
"id": 0,
"nome": "LIGA ITALIANA 2025/2026 - HIGHLIGHTS - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "LIGA ITALIANA 2025/2026 - HIGHLIGHTS - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2500027_0042",
"imagem": "https://www.sporttv.pt/default/0001/11/10d2e0689af7ac311778f315bc6592abc38e4016.jpg",
"id": 10686335365,
"data": 1780866031000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10686335365
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "RUI PATRÍCIO - MUNDIAL 2018, RÚSSIA",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 1424000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "Magazine",
"agregador2": {
"id": 0,
"nome": "QUINAS DA MEMÓRIA - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "QUINAS DA MEMÓRIA - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2600283_0007",
"imagem": "https://www.sporttv.pt/default/0001/11/48b37458f268d3f45f360e978fe5c4763844fea8.jpg",
"id": 10686335502,
"data": 1780869381000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10686335502
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "PORTUGAL X CHILE",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 1780000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "Long Summary",
"agregador2": {
"id": 0,
"nome": "JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2500195_0043",
"imagem": "https://www.sporttv.pt/default/0001/11/72f8a4f9569763b7dfdce68dbac3b33024e34b26.jpg",
"id": 10686335425,
"data": 1780870805000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10686335425
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "COLÔMBIA X JORDANIA",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 7809000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "DIRETO",
"agregador2": {
"id": 0,
"nome": "JOGOS DE PREPARAÇÃO - JOGOS COLÔMBIA - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "JOGOS DE PREPARAÇÃO - JOGOS COLÔMBIA - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2600319_0002",
"imagem": "https://www.sporttv.pt/default/0001/11/5e2029855364ab3f41c7c7c49b9a2e8c191da94f.jpg",
"id": 10685895933,
"data": 1780872585000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10685895933
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "CROÁCIA X ESLOVÉNIA",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 7227000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "Recorded",
"agregador2": {
"id": 0,
"nome": "JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2500195_0051",
"imagem": "https://www.sporttv.pt/default/0001/11/175ab04d3ec614f86ec6771823b7921f137d2c91.jpg",
"id": 10686091222,
"data": 1780880394000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10686091222
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "RESUMO DA ÉPOCA",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 3275000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "Magazine",
"agregador2": {
"id": 0,
"nome": "LIGA ITALIANA 2025/2026 - HIGHLIGHTS - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "LIGA ITALIANA 2025/2026 - HIGHLIGHTS - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2500027_0042",
"imagem": "https://www.sporttv.pt/default/0001/11/72f8a4f9569763b7dfdce68dbac3b33024e34b26.jpg",
"id": 10685140452,
"data": 1780887621000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10685140452
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "MAGAZINE",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 2820000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "Magazine",
"agregador2": {
"id": 0,
"nome": "UEFA CHAMPIONS LEAGUE 2025/26 - MAGAZINES - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "UEFA CHAMPIONS LEAGUE 2025/26 - MAGAZINES - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2500244-0036",
"imagem": "https://www.sporttv.pt/default/0001/11/72f8a4f9569763b7dfdce68dbac3b33024e34b26.jpg",
"id": 10686091200,
"data": 1780890896000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10686091200
},
{
"agregador1": {
"id": 0,
"nome": ""
},
"descricao": "SEM TRANSMISSÃO",
"modalidade": {
"nomeModalidade": "",
"codigo": ""
},
"duracao": 184000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "",
"agregador2": {
"id": 0,
"nome": "SEM TRANSMISSÃO"
},
"evento": {
"id": 0,
"nome": "SEM TRANSMISSÃO",
"premium": false
},
"exclusivo": false,
"imagem": "https://www.sporttv.pt/default/0001/11/b72954d32115e8d78472b8385fb5760ca711e058.png",
"id": 337800,
"data": 1780893716000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 337800
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "GRÉCIA X ITÁLIA",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 7200000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "Recorded",
"agregador2": {
"id": 0,
"nome": "JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2500195_0050",
"imagem": "https://www.sporttv.pt/default/0001/11/da0ea85292c53ffab55e4c18624a73b2bd1bc0bb.jpg",
"id": 10686091738,
"data": 1780893900000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10686091738
},
{
"agregador1": {
"id": 0,
"nome": ""
},
"descricao": "SEM TRANSMISSÃO",
"modalidade": {
"nomeModalidade": "",
"codigo": ""
},
"duracao": 2700000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "",
"agregador2": {
"id": 0,
"nome": "SEM TRANSMISSÃO"
},
"evento": {
"id": 0,
"nome": "SEM TRANSMISSÃO",
"premium": false
},
"exclusivo": false,
"imagem": "https://www.sporttv.pt/default/0001/11/b72954d32115e8d78472b8385fb5760ca711e058.png",
"id": 339058,
"data": 1780898400000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 339058
},
{
"agregador1": {
"id": 0,
"nome": "FUTEBOL"
},
"descricao": "CROÁCIA X ESLOVÉNIA",
"modalidade": {
"nomeModalidade": "FUTEBOL",
"codigo": "futebol"
},
"duracao": 7500000,
"paraDestaque": false,
"canal": {
"id": 727,
"nome": "SPORT.TV1",
"category": "",
"premium": false
},
"tipoEmissao": "Recorded",
"agregador2": {
"id": 0,
"nome": "JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL"
},
"evento": {
"id": 0,
"nome": "JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL",
"premium": false
},
"exclusivo": false,
"idPrograma": "2500195_0051",
"imagem": "https://www.sporttv.pt/default/0001/11/efe2500bfa8d059171855f7c206b574c08fab9b2.jpg",
"id": 10686091758,
"data": 1780901100000,
"grandeEvento": {
"id": 0,
"nome": ""
},
"id_epg": 10686091758
}
]
+8 -9
View File
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<channels> <channels>
<channel site="sporttv.pt" site_id="7386" lang="pt" xmltv_id="NBATVInternational.us@SD">NBA TV</channel> <channel site="sporttv.pt" site_id="727" lang="pt" logo="https://www.sporttv.pt/cms_media/default/0001/13/7b1d37ebaabd616607f87e73b6b28461c4dc28a0.svg" xmltv_id="SportTV1.pt@SD">SPORT.TV1</channel>
<channel site="sporttv.pt" site_id="727" lang="pt" xmltv_id="SportTV1.pt@SD">Sport TV 1</channel> <channel site="sporttv.pt" site_id="728" lang="pt" logo="https://www.sporttv.pt/cms_media/default/0001/13/2adbed9d1e4d832b81c9b39c47d4d558ec5ecc5f.svg" xmltv_id="SportTV2.pt@SD">SPORT.TV2</channel>
<channel site="sporttv.pt" site_id="728" lang="pt" xmltv_id="SportTV2.pt@SD">Sport TV 2</channel> <channel site="sporttv.pt" site_id="729" lang="pt" logo="https://www.sporttv.pt/cms_media/default/0001/13/04cd76176390f40940a06c24f372c4780850fc44.svg" xmltv_id="SportTV3.pt@SD">SPORT.TV3</channel>
<channel site="sporttv.pt" site_id="729" lang="pt" xmltv_id="SportTV3.pt@SD">Sport TV 3</channel> <channel site="sporttv.pt" site_id="5406" lang="pt" logo="https://www.sporttv.pt/cms_media/default/0001/13/7f55db09622018d2e76770eb032adfd2c2178a22.svg" xmltv_id="SportTV4.pt@SD">SPORT.TV4</channel>
<channel site="sporttv.pt" site_id="5406" lang="pt" xmltv_id="SportTV4.pt@SD">Sport TV 4</channel> <channel site="sporttv.pt" site_id="5422" lang="pt" logo="https://www.sporttv.pt/cms_media/default/0001/13/97cc61803f3ac434522800376e34332117fdd19f.svg" xmltv_id="SportTV5.pt@SD">SPORT.TV5</channel>
<channel site="sporttv.pt" site_id="5422" lang="pt" xmltv_id="SportTV5.pt@SD">Sport TV 5</channel> <channel site="sporttv.pt" site_id="7577" lang="pt" logo="https://www.sporttv.pt/cms_media/default/0001/13/99242f707846ecc2d8222f3f3b03bfe3b17a169f.svg" xmltv_id="SportTV6.pt@SD">SPORT.TV6</channel>
<channel site="sporttv.pt" site_id="7577" lang="pt" xmltv_id="SportTV6.pt@SD">Sport TV 6</channel> <channel site="sporttv.pt" site_id="7600" lang="pt" logo="https://www.sporttv.pt/cms_media/default/0001/13/88c0c128f1a26b73c1452ff66e19e88f2db549c6.svg" xmltv_id="SportTV7.pt@SD">SPORT.TV7</channel>
<channel site="sporttv.pt" site_id="7600" lang="pt" xmltv_id="SportTV7.pt@SD">Sport TV 7</channel> <channel site="sporttv.pt" site_id="7133" lang="pt" logo="https://www.sporttv.pt/cms_media/default/0001/13/5031847ef791d8fb3ebfaddd4e5e62c7e35ed180.svg" xmltv_id="SportTVPlus.pt@SD">SPORT.TV+</channel>
<channel site="sporttv.pt" site_id="7133" lang="pt" xmltv_id="SportTVPlus.pt@SD">Sport TV+</channel>
</channels> </channels>
+34 -27
View File
@@ -1,11 +1,21 @@
const dayjs = require('dayjs') const dayjs = require('dayjs')
const cheerio = require('cheerio') const axios = require('axios')
module.exports = { module.exports = {
site: 'sporttv.pt', site: 'sporttv.pt',
days: 2, days: 2,
request: {
url: 'https://www.sporttv.pt/guia', headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36',
'X-Client-Platform': 'web',
'X-Device-Platform': 'web'
}
},
url({ date, channel }) {
const startDate = date.format('DD/MM/YYYY%20HH:mm')
const endDate = date.add(1, 'day').format('DD/MM/YYYY%20HH:mm')
return `https://www.sporttv.pt/api/channels/epg?dataInicio=${startDate}&dataFim=${endDate}&tipoMedia=thumbnail&idCanal=${channel.site_id}`
},
parser({ content, date, channel }) { parser({ content, date, channel }) {
let programs = [] let programs = []
const items = parseItems(content, channel, date) const items = parseItems(content, channel, date)
@@ -24,20 +34,32 @@ module.exports = {
}) })
return programs return programs
},
async channels() {
let access = axios.get('https://www.sporttv.pt/api/channels/live', { headers: this.request.headers })
let { data } = await access
data = data.filter(item => item.id !== 0)
return data.map(item_1 => ({
site_id: item_1.id,
name: item_1.nome,
logo: item_1.logo_url
}))
} }
} }
function parseItems(content, channel, date) { function parseItems(content, channel, date) {
const $ = cheerio.load(content) if (!content) return []
const nuxtData = $('#__NUXT_DATA__').html() let json_data
if (!nuxtData) return [] try {
const parsed = JSON.parse(nuxtData) json_data = JSON.parse(content)
const dataIndex = parsed[1].data // eslint-disable-next-line @typescript-eslint/no-unused-vars
const epgIndex = Object.values(parsed[dataIndex])[3] // 1611 } catch (e) {
const epg = parsed[epgIndex].map(i => parsed[i]).map(obj => dataMapper(obj, parsed)) return []
if (!Array.isArray(epg)) return [] }
if (!Array.isArray(json_data)) return []
return epg return json_data
.filter( .filter(
item => item.canal.id === parseInt(channel.site_id) && date.isSame(dayjs(item.data), 'd') item => item.canal.id === parseInt(channel.site_id) && date.isSame(dayjs(item.data), 'd')
) )
@@ -47,18 +69,3 @@ function parseItems(content, channel, date) {
return 0 return 0
}) })
} }
function dataMapper(object, parsed) {
let output = {}
for (let key in object) {
const value = parsed[object[key]]
if (typeof value === 'object') {
output[key] = dataMapper(value, parsed)
} else {
output[key] = value
}
}
return output
}
+15 -15
View File
@@ -7,48 +7,48 @@ const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat) dayjs.extend(customParseFormat)
dayjs.extend(utc) 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 = { const channel = {
site_id: 727, site_id: 727,
xmltv_id: 'SportTV1.pt' xmltv_id: 'SportTV1.pt'
} }
it('can generate valid url', () => { 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', () => { 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 => { const results = parser({ content, date, channel }).map(p => {
p.start = p.start.toJSON() p.start = p.start.toJSON()
p.stop = p.stop.toJSON() p.stop = p.stop.toJSON()
return p return p
}) })
expect(results.length).toBe(19) expect(results.length).toBe(7)
expect(results[0]).toMatchObject({ expect(results[0]).toMatchObject({
start: '2024-12-23T01:00:00.000Z', start: '2026-06-08T00:59:54.000Z',
stop: '2024-12-23T01:30:00.000Z', stop: '2026-06-08T03:00:21.000Z',
description: 'LIGA PORTUGAL BETCLIC', description: 'JOGOS PREPARAÇÃO MUNDIAL - FUTEBOL',
category: 'FUTEBOL', category: 'FUTEBOL',
title: 'RESUMOS DA JORNADA 15', title: 'CROÁCIA X ESLOVÉNIA',
image: 'https://www.sporttv.pt/default/0001/11/08cb25f0b9b427e0bb83179309074632410f536b.jpg' image: 'https://www.sporttv.pt/default/0001/11/175ab04d3ec614f86ec6771823b7921f137d2c91.jpg'
}) })
expect(results[1]).toMatchObject({ expect(results[1]).toMatchObject({
start: '2024-12-23T01:30:00.000Z', start: '2026-06-08T03:00:21.000Z',
stop: '2024-12-23T02:00:00.000Z', stop: '2026-06-08T03:54:56.000Z',
description: 'LIGA ITALIANA', description: 'LIGA ITALIANA 2025/2026 - HIGHLIGHTS - FUTEBOL',
category: 'FUTEBOL', category: 'FUTEBOL',
title: 'RESUMOS DA JORNADA 17', title: 'RESUMO DA ÉPOCA',
image: 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', () => { it('can handle empty guide', () => {
const content = '' const content = []
const result = parser({ content, date }) const result = parser({ content, date })
expect(result).toMatchObject([]) expect(result).toMatchObject([])
}) })