mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 09:30:06 -04:00
Create mtel.ba.config.js
This commit is contained in:
parent
98a5c8baa3
commit
3f6e3d9603
1 changed files with 63 additions and 0 deletions
63
sites/mtel.ba/mtel.ba.config.js
Normal file
63
sites/mtel.ba/mtel.ba.config.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
const dayjs = require('dayjs')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
|
||||
dayjs.extend(timezone)
|
||||
|
||||
module.exports = {
|
||||
site: 'mtel.ba',
|
||||
url: function ({ channel, date }) {
|
||||
const [position] = channel.site_id.split('#')
|
||||
|
||||
return `https://mtel.ba/oec/epg/program?date=${date.format('YYYY-MM-DD')}&position=${position}`
|
||||
},
|
||||
request: {
|
||||
timeout: 15000,
|
||||
headers: {
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
}
|
||||
},
|
||||
logo({ content, channel }) {
|
||||
const data = parseContent(content, channel)
|
||||
|
||||
return data ? data.image : null
|
||||
},
|
||||
parser: function ({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
if (item.title === 'Nema informacija o programu') return
|
||||
programs.push({
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
category: item.category,
|
||||
icon: item.image,
|
||||
start: parseStart(item).toJSON(),
|
||||
stop: parseStop(item).toJSON()
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.tz(item.full_start, 'Europe/Sarajevo')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.tz(item.full_end, 'Europe/Sarajevo')
|
||||
}
|
||||
|
||||
function parseContent(content, channel) {
|
||||
const [_, channelId] = channel.site_id.split('#')
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !Array.isArray(data.channels)) return null
|
||||
|
||||
return data.channels.find(i => i.id === channelId)
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
const data = parseContent(content, channel)
|
||||
|
||||
return data ? data.items : []
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue