mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Merge pull request #255 from iptv-org/add-tvarenasport-com
Add guide from tvarenasport.com
This commit is contained in:
commit
50ad899884
6 changed files with 152 additions and 0 deletions
61
sites/tvarenasport.com/tvarenasport.com.config.js
Normal file
61
sites/tvarenasport.com/tvarenasport.com.config.js
Normal file
|
@ -0,0 +1,61 @@
|
|||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
|
||||
const domains = {
|
||||
rs: '',
|
||||
mk: '/mk',
|
||||
me: '/me',
|
||||
ba: '/ba'
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
site: 'tvarenasport.com',
|
||||
url: function ({ channel, date }) {
|
||||
const [country] = channel.site_id.split('#')
|
||||
|
||||
return `https://www.tvarenasport.com${domains[country]}/api/schedule?date=${date.format(
|
||||
'DD-MM-YYYY'
|
||||
)}`
|
||||
},
|
||||
parser: function ({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
category: item.league,
|
||||
description: item.sport,
|
||||
start: dayjs(item.start),
|
||||
stop: dayjs(item.end)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels({ country, lang }) {
|
||||
const data = await axios
|
||||
.get(`https://www.tvarenasport.com${domains[country]}/api/schedule`)
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
const channels = []
|
||||
for (let id in data.channels) {
|
||||
const item = data.channels[id]
|
||||
channels.push({
|
||||
lang: 'sr',
|
||||
site_id: `${country}#${id}`,
|
||||
name: item.name
|
||||
})
|
||||
}
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
const [_, channelId] = channel.site_id.split('#')
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !Array.isArray(data.items)) return []
|
||||
|
||||
return data.items.filter(i => i.group === channelId)
|
||||
}
|
47
sites/tvarenasport.com/tvarenasport.com.test.js
Normal file
47
sites/tvarenasport.com/tvarenasport.com.test.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
// node ./scripts/channels.js --config=./sites/tvarenasport.com/tvarenasport.com.config.js --output=./sites/tvarenasport.com/tvarenasport.com_rs.channels.xml --set=country:rs
|
||||
// npx epg-grabber --config=sites/tvarenasport.com/tvarenasport.com.config.js --channels=sites/tvarenasport.com/tvarenasport.com_rs.channels.xml --output=.gh-pages/guides/rs/tvarenasport.com.epg.xml --days=2
|
||||
|
||||
const { parser, url } = require('./tvarenasport.com.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2021-11-17', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'rs#380',
|
||||
xmltv_id: 'ArenaSport1.rs'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe('https://www.tvarenasport.com/api/schedule?date=17-11-2021')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = `{"items":[{"id":2857,"title":"Crvena zvezda mts - Partizan NIS","start":"2021-11-16T23:30:00Z","end":"2021-11-17T01:30:00Z","sport":"ABA LIGA","league":"Ko\u0161arka","group":"380","isLive":false,"doNotMiss":false,"domain":"srb"},{"id":3155,"title":"Sao Paulo - Flamengo","start":"2021-11-17T00:00:00Z","end":"2021-11-17T02:00:00Z","sport":"BRAZILSKA LIGA","league":"Fudbal","group":"381","isLive":false,"doNotMiss":false,"domain":"srb"}]}`
|
||||
const result = parser({ channel, content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-16T23:30:00.000Z',
|
||||
stop: '2021-11-17T01:30:00.000Z',
|
||||
title: 'Crvena zvezda mts - Partizan NIS',
|
||||
category: 'Ko\u0161arka',
|
||||
description: 'ABA LIGA'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: `{"channels":[]}`
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
9
sites/tvarenasport.com/tvarenasport.com_ba.channels.xml
Normal file
9
sites/tvarenasport.com/tvarenasport.com_ba.channels.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="tvarenasport.com">
|
||||
<channels>
|
||||
<channel lang="sr" xmltv_id="ArenaSport1.rs" site_id="ba#380">Arena Sport 1</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport2.rs" site_id="ba#381">Arena Sport 2</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport3.rs" site_id="ba#382">Arena Sport 3</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport4.rs" site_id="ba#383">Arena Sport 4</channel>
|
||||
</channels>
|
||||
</site>
|
9
sites/tvarenasport.com/tvarenasport.com_me.channels.xml
Normal file
9
sites/tvarenasport.com/tvarenasport.com_me.channels.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="tvarenasport.com">
|
||||
<channels>
|
||||
<channel lang="sr" xmltv_id="ArenaSport2.rs" site_id="me#381">Arena Sport 2</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport3.rs" site_id="me#382">Arena Sport 3</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport4.rs" site_id="me#383">Arena Sport 4</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport5.rs" site_id="me#384">Arena Sport 5</channel>
|
||||
</channels>
|
||||
</site>
|
9
sites/tvarenasport.com/tvarenasport.com_mk.channels.xml
Normal file
9
sites/tvarenasport.com/tvarenasport.com_mk.channels.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="tvarenasport.com">
|
||||
<channels>
|
||||
<channel lang="sr" xmltv_id="ArenaSport2.rs" site_id="mk#381">Arena Sport 2</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport3.rs" site_id="mk#382">Arena Sport 3</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport4.rs" site_id="mk#383">Arena Sport 4</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport5.rs" site_id="mk#384">Arena Sport 5</channel>
|
||||
</channels>
|
||||
</site>
|
17
sites/tvarenasport.com/tvarenasport.com_rs.channels.xml
Normal file
17
sites/tvarenasport.com/tvarenasport.com_rs.channels.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="tvarenasport.com">
|
||||
<channels>
|
||||
<channel lang="sr" xmltv_id="ArenaPremium1.rs" site_id="rs#5710">Arena Premium 1</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaPremium2.rs" site_id="rs#5711">Arena Premium 2</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaPremium3.rs" site_id="rs#5712">Arena Premium 3</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport1.rs" site_id="rs#380">Arena Sport 1</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport2.rs" site_id="rs#381">Arena Sport 2</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport3.rs" site_id="rs#382">Arena Sport 3</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport4.rs" site_id="rs#383">Arena Sport 4</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport5.rs" site_id="rs#384">Arena Sport 5</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport6.rs" site_id="rs#5594">Arena Sport 6</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport7.rs" site_id="rs#5595">Arena Sport 7</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport8.rs" site_id="rs#5596">Arena Sport 8</channel>
|
||||
<channel lang="sr" xmltv_id="ArenaSport1x2.rs" site_id="rs#5347">Arena Sport 1x2</channel>
|
||||
</channels>
|
||||
</site>
|
Loading…
Add table
Add a link
Reference in a new issue