mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Update dstv.com.config.js
This commit is contained in:
parent
ee16691185
commit
c64a36b58c
1 changed files with 20 additions and 14 deletions
|
@ -8,21 +8,23 @@ dayjs.extend(utc)
|
||||||
dayjs.extend(timezone)
|
dayjs.extend(timezone)
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
|
const API_ENDPOINT = 'https://www.dstv.com/umbraco/api/TvGuide'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'dstv.com',
|
site: 'dstv.com',
|
||||||
request: {
|
request: {
|
||||||
cache: {
|
cache: {
|
||||||
ttl: 6 * 60 * 60 * 1000, // 6h
|
ttl: 3 * 60 * 60 * 1000, // 3h
|
||||||
interpretHeader: false
|
interpretHeader: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
url: function ({ channel, date }) {
|
url: function ({ channel, date }) {
|
||||||
const [region] = channel.site_id.split('#')
|
const [region] = channel.site_id.split('#')
|
||||||
const packageName = region === 'nga' ? 'DStv%20Premium' : ''
|
const packageName = region === 'nga' ? '&package=DStv%20Premium' : ''
|
||||||
|
|
||||||
return `https://www.dstv.com/umbraco/api/TvGuide/GetProgrammes?d=${date.format(
|
return `${API_ENDPOINT}/GetProgrammes?d=${date.format(
|
||||||
'YYYY-MM-DD'
|
'YYYY-MM-DD'
|
||||||
)}&package=${packageName}&country=${region}`
|
)}${packageName}&country=${region}`
|
||||||
},
|
},
|
||||||
async parser({ content, channel, cached }) {
|
async parser({ content, channel, cached }) {
|
||||||
let programs = []
|
let programs = []
|
||||||
|
@ -34,8 +36,8 @@ module.exports = {
|
||||||
description: parseDescription(details),
|
description: parseDescription(details),
|
||||||
icon: parseIcon(details),
|
icon: parseIcon(details),
|
||||||
category: parseCategory(details),
|
category: parseCategory(details),
|
||||||
start: parseTime(item.StartTime),
|
start: parseTime(item.StartTime, channel),
|
||||||
stop: parseTime(item.EndTime)
|
stop: parseTime(item.EndTime, channel)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,9 +45,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
async channels({ country }) {
|
async channels({ country }) {
|
||||||
const data = await axios
|
const data = await axios
|
||||||
.get(
|
.get(`${API_ENDPOINT}/GetProgrammes?d=2022-03-10&package=DStv%20Premium&country=${country}`)
|
||||||
`https://www.dstv.com/umbraco/api/TvGuide/GetProgrammes?d=2022-03-10&package=DStv%20Premium&country=${country}`
|
|
||||||
)
|
|
||||||
.then(r => r.data)
|
.then(r => r.data)
|
||||||
.catch(console.log)
|
.catch(console.log)
|
||||||
|
|
||||||
|
@ -58,6 +58,16 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseTime(time, channel) {
|
||||||
|
const [region] = channel.site_id.split('#')
|
||||||
|
const tz = {
|
||||||
|
zaf: 'Africa/Johannesburg',
|
||||||
|
nga: 'Africa/Lagos'
|
||||||
|
}
|
||||||
|
|
||||||
|
return dayjs.tz(time, 'YYYY-MM-DDTHH:mm:ss', tz[region])
|
||||||
|
}
|
||||||
|
|
||||||
function parseDescription(details) {
|
function parseDescription(details) {
|
||||||
return details ? details.Synopsis : null
|
return details ? details.Synopsis : null
|
||||||
}
|
}
|
||||||
|
@ -71,7 +81,7 @@ function parseCategory(details) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadProgramDetails(item) {
|
async function loadProgramDetails(item) {
|
||||||
const url = `https://www.dstv.com/umbraco/api/TvGuide/GetProgramme?id=${item.Id}`
|
const url = `${API_ENDPOINT}/GetProgramme?id=${item.Id}`
|
||||||
|
|
||||||
return axios
|
return axios
|
||||||
.get(url)
|
.get(url)
|
||||||
|
@ -79,10 +89,6 @@ async function loadProgramDetails(item) {
|
||||||
.catch(console.error)
|
.catch(console.error)
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseTime(time) {
|
|
||||||
return dayjs.utc(time, 'YYYY-MM-DDTHH:mm:ss')
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseItems(content, channel) {
|
function parseItems(content, channel) {
|
||||||
const [_, channelId] = channel.site_id.split('#')
|
const [_, channelId] = channel.site_id.split('#')
|
||||||
const data = JSON.parse(content)
|
const data = JSON.parse(content)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue