mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create tvarenasport.hr.config.js
This commit is contained in:
parent
b8af82abb9
commit
386c22d773
1 changed files with 49 additions and 0 deletions
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)
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue