Update dstv.com.config.js

This commit is contained in:
Aleksandr Statciuk 2022-03-11 02:51:29 +03:00
parent 8483b6e9f5
commit e4446a0900

View file

@ -8,10 +8,11 @@ module.exports = {
site: 'dstv.com',
url: function ({ channel, date }) {
const [region] = channel.site_id.split('#')
const packageName = region === 'nga' ? 'DStv%20Premium' : ''
return `https://www.dstv.com/umbraco/api/TvGuide/GetProgrammes?d=${date.format(
'YYYY-MM-DD'
)}&country=${region}`
)}&package=${packageName}&country=${region}`
},
async parser({ content, channel }) {
let programs = []
@ -32,13 +33,15 @@ module.exports = {
},
async channels({ country }) {
const data = await axios
.get(`https://www.dstv.com/umbraco/api/TvGuide/GetChannels?country=${country}`)
.get(
`https://www.dstv.com/umbraco/api/TvGuide/GetProgrammes?d=2022-03-10&package=DStv%20Premium&country=${country}`
)
.then(r => r.data)
.catch(console.log)
return data.Channels.map(item => {
return {
site_id: `${country}#${item.Tag}`,
site_id: `${country}#${item.Number}`,
name: item.Name
}
})
@ -66,7 +69,7 @@ function parseItems(content, channel) {
const [_, channelId] = channel.site_id.split('#')
const data = JSON.parse(content)
if (!data || !Array.isArray(data.Channels)) return []
const channelData = data.Channels.find(c => c.Tag === channelId)
const channelData = data.Channels.find(c => c.Number === channelId)
if (!channelData || !Array.isArray(channelData.Programmes)) return []
return channelData.Programmes