mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Merge pull request #256 from iptv-org/add-tvarenasport-hr
Add guide from tvarenasport.hr
This commit is contained in:
commit
a78802e971
5 changed files with 114 additions and 3 deletions
|
@ -6,7 +6,7 @@ const { json2xml } = require('./utils')
|
||||||
const program = new Command()
|
const program = new Command()
|
||||||
program
|
program
|
||||||
.requiredOption('-c, --config <config>', 'Config file')
|
.requiredOption('-c, --config <config>', 'Config file')
|
||||||
.option('-s, --set [args...]', 'Set custom arguments')
|
.option('-s, --set [args...]', 'Set custom arguments', [])
|
||||||
.option('-o, --output <output>', 'Output file')
|
.option('-o, --output <output>', 'Output file')
|
||||||
.parse(process.argv)
|
.parse(process.argv)
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,9 @@ module.exports = {
|
||||||
const items = parseItems(content, channel)
|
const items = parseItems(content, channel)
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
programs.push({
|
programs.push({
|
||||||
title: item.title,
|
title: item.title.trim(),
|
||||||
category: item.league,
|
category: item.league,
|
||||||
description: item.sport,
|
description: item.sport.trim(),
|
||||||
start: dayjs(item.start),
|
start: dayjs(item.start),
|
||||||
stop: dayjs(item.end)
|
stop: dayjs(item.end)
|
||||||
})
|
})
|
||||||
|
|
49
sites/tvarenasport.hr/tvarenasport.hr.config.js
Normal file
49
sites/tvarenasport.hr/tvarenasport.hr.config.js
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
const axios = require('axios')
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'tvarenasport.hr',
|
||||||
|
url: function ({ channel, date }) {
|
||||||
|
return `https://www.tvarenasport.hr/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.trim(),
|
||||||
|
category: item.sport,
|
||||||
|
description: item.league.trim(),
|
||||||
|
start: dayjs(item.start),
|
||||||
|
stop: dayjs(item.end)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return programs
|
||||||
|
},
|
||||||
|
async channels({ country, lang }) {
|
||||||
|
const data = await axios
|
||||||
|
.get(`https://www.tvarenasport.hr/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: 'hr',
|
||||||
|
site_id: id,
|
||||||
|
name: item.name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return channels
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content, channel) {
|
||||||
|
const data = JSON.parse(content)
|
||||||
|
if (!data || !Array.isArray(data.items)) return []
|
||||||
|
|
||||||
|
return data.items.filter(i => i.group === channel.site_id)
|
||||||
|
}
|
47
sites/tvarenasport.hr/tvarenasport.hr.test.js
Normal file
47
sites/tvarenasport.hr/tvarenasport.hr.test.js
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
// node ./scripts/channels.js --config=./sites/tvarenasport.hr/tvarenasport.hr.config.js --output=./sites/tvarenasport.hr/tvarenasport.hr_hr.channels.xml
|
||||||
|
// npx epg-grabber --config=sites/tvarenasport.hr/tvarenasport.hr.config.js --channels=sites/tvarenasport.hr/tvarenasport.hr_hr.channels.xml --output=.gh-pages/guides/hr/tvarenasport.hr.epg.xml --days=2
|
||||||
|
|
||||||
|
const { parser, url } = require('./tvarenasport.hr.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: '380',
|
||||||
|
xmltv_id: 'ArenaSport1Hrvatska.rs'
|
||||||
|
}
|
||||||
|
|
||||||
|
it('can generate valid url', () => {
|
||||||
|
expect(url({ channel, date })).toBe('https://www.tvarenasport.hr/api/schedule?date=17-11-2021')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can parse response', () => {
|
||||||
|
const content = `{"items":[{"id":6104,"title":"NAJAVA PROGRAMA","start":"2021-11-16T23:00:00Z","end":"2021-11-17T23:00:00Z","sport":"Najava programa","league":"NAJAVA PROGRAMA","group":"1294","isLive":false,"doNotMiss":false,"domain":"cro"},{"id":6000,"title":" DIJON - UNICAJA","start":"2021-11-16T23:30:00Z","end":"2021-11-17T01:00:00Z","sport":"Košarka","league":" LIGA PRVAKA","group":"380","isLive":false,"doNotMiss":false,"domain":"cro"}]}`
|
||||||
|
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:00:00.000Z',
|
||||||
|
title: 'DIJON - UNICAJA',
|
||||||
|
category: 'Košarka',
|
||||||
|
description: 'LIGA PRVAKA'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can handle empty guide', () => {
|
||||||
|
const result = parser({
|
||||||
|
date,
|
||||||
|
channel,
|
||||||
|
content: `{"channels":[]}`
|
||||||
|
})
|
||||||
|
expect(result).toMatchObject([])
|
||||||
|
})
|
15
sites/tvarenasport.hr/tvarenasport.hr_hr.channels.xml
Normal file
15
sites/tvarenasport.hr/tvarenasport.hr_hr.channels.xml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<site site="tvarenasport.hr">
|
||||||
|
<channels>
|
||||||
|
<channel lang="hr" xmltv_id="ArenaSport1Hrvatska.rs" site_id="380">Arena Sport 1 Hrvatska</channel>
|
||||||
|
<channel lang="hr" xmltv_id="ArenaSport2Hrvatska.rs" site_id="381">Arena Sport 2 Hrvatska</channel>
|
||||||
|
<channel lang="hr" xmltv_id="ArenaSport3Hrvatska.rs" site_id="382">Arena Sport 3 Hrvatska</channel>
|
||||||
|
<channel lang="hr" xmltv_id="ArenaSport4Hrvatska.rs" site_id="383">Arena Sport 4 Hrvatska</channel>
|
||||||
|
<channel lang="hr" xmltv_id="ArenaSport5Hrvatska.rs" site_id="384">Arena Sport 5 Hrvatska</channel>
|
||||||
|
<channel lang="hr" xmltv_id="ArenaSport6Hrvatska.rs" site_id="1175">Arena Sport 6 Hrvatska</channel>
|
||||||
|
<channel lang="hr" xmltv_id="ArenaSport7Hrvatska.rs" site_id="1291">Arena Sport 7 Hrvatska</channel>
|
||||||
|
<channel lang="hr" xmltv_id="ArenaSport8Hrvatska.rs" site_id="1292">Arena Sport 8 Hrvatska</channel>
|
||||||
|
<channel lang="hr" xmltv_id="ArenaSport9Hrvatska.rs" site_id="1293">Arena Sport 9 Hrvatska</channel>
|
||||||
|
<channel lang="hr" xmltv_id="ArenaSport10Hrvatska.rs" site_id="1294">Arena Sport 10 Hrvatska</channel>
|
||||||
|
</channels>
|
||||||
|
</site>
|
Loading…
Add table
Add a link
Reference in a new issue