mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Update zap.co.ao.config.js
This commit is contained in:
parent
09e08d4a1c
commit
894563e55b
1 changed files with 30 additions and 34 deletions
|
@ -1,53 +1,49 @@
|
||||||
const dayjs = require('dayjs')
|
const { DateTime } = require('luxon')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const axios = require('axios')
|
||||||
const timezone = require('dayjs/plugin/timezone')
|
|
||||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
|
||||||
|
|
||||||
dayjs.extend(utc)
|
|
||||||
dayjs.extend(timezone)
|
|
||||||
dayjs.extend(customParseFormat)
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
skip: true, // NOTE: Connection timeout
|
|
||||||
site: 'zap.co.ao',
|
site: 'zap.co.ao',
|
||||||
days: 2,
|
days: 2,
|
||||||
|
maxConnections: 200,
|
||||||
url: function ({ date, channel }) {
|
url: function ({ date, channel }) {
|
||||||
return `https://www.zap.co.ao/_api/channels/${date.format('YYYY-M-D')}/epg.json`
|
return `https://zapon.zapsi.net/ao/m/api/epg/events?date=${date.format('YYYYMMDD')}&channel=${
|
||||||
|
channel.site_id
|
||||||
|
}`
|
||||||
},
|
},
|
||||||
parser: function ({ content, channel, date }) {
|
parser: function ({ content }) {
|
||||||
const programs = []
|
const programs = []
|
||||||
const items = parseItems(content, channel)
|
const items = parseItems(content)
|
||||||
if (!items.length) return programs
|
if (!items.length) return programs
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
const prev = programs[programs.length - 1]
|
|
||||||
let start = parseStart(item, date)
|
|
||||||
if (prev && start.isBefore(prev.start)) {
|
|
||||||
start = start.add(1, 'd')
|
|
||||||
date = date.add(1, 'd')
|
|
||||||
}
|
|
||||||
const stop = start.add(item.duration, 's')
|
|
||||||
programs.push({
|
programs.push({
|
||||||
title: item.name,
|
title: item.programName,
|
||||||
description: item.sinopse,
|
description: item.programDescription,
|
||||||
start,
|
category: item.categoryName,
|
||||||
stop
|
start: DateTime.fromSeconds(item.utcBeginDate).toUTC(),
|
||||||
|
stop: DateTime.fromSeconds(item.utcEndDate).toUTC()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return programs
|
return programs
|
||||||
|
},
|
||||||
|
async channels() {
|
||||||
|
const channels = await axios
|
||||||
|
.get(`https://zapon.zapsi.net/ao/m/api/epg/channels`)
|
||||||
|
.then(r => r.data.data)
|
||||||
|
.catch(console.log)
|
||||||
|
|
||||||
|
return channels.map(item => {
|
||||||
|
return {
|
||||||
|
lang: 'pt',
|
||||||
|
site_id: item.id,
|
||||||
|
name: item.name
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItems(content, channel) {
|
function parseItems(content) {
|
||||||
const channels = JSON.parse(content)
|
const data = JSON.parse(content)
|
||||||
const data = channels.find(ch => ch.id == channel.site_id)
|
|
||||||
|
|
||||||
return data ? data.epg : []
|
return data.data || []
|
||||||
}
|
|
||||||
|
|
||||||
function parseStart(item, date) {
|
|
||||||
const [hours, minutes] = item.start_time.split('h')
|
|
||||||
const dateString = `${date.format('YYYY-MM-DD')} ${hours}:${minutes}`
|
|
||||||
|
|
||||||
return dayjs.tz(dateString, 'YYYY-MM-DD HH:mm', 'Africa/Luanda')
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue