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', site: 'dstv.com',
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' : ''
return `https://www.dstv.com/umbraco/api/TvGuide/GetProgrammes?d=${date.format( return `https://www.dstv.com/umbraco/api/TvGuide/GetProgrammes?d=${date.format(
'YYYY-MM-DD' 'YYYY-MM-DD'
)}&country=${region}` )}&package=${packageName}&country=${region}`
}, },
async parser({ content, channel }) { async parser({ content, channel }) {
let programs = [] let programs = []
@ -32,13 +33,15 @@ module.exports = {
}, },
async channels({ country }) { async channels({ country }) {
const data = await axios 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) .then(r => r.data)
.catch(console.log) .catch(console.log)
return data.Channels.map(item => { return data.Channels.map(item => {
return { return {
site_id: `${country}#${item.Tag}`, site_id: `${country}#${item.Number}`,
name: item.Name name: item.Name
} }
}) })
@ -66,7 +69,7 @@ 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)
if (!data || !Array.isArray(data.Channels)) return [] 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 [] if (!channelData || !Array.isArray(channelData.Programmes)) return []
return channelData.Programmes return channelData.Programmes