mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 17:40:07 -04:00
Update astro.com.my.config.js
This commit is contained in:
parent
995d7950a1
commit
585e7ef434
1 changed files with 22 additions and 15 deletions
|
@ -7,25 +7,32 @@ module.exports = {
|
||||||
url: function ({ channel }) {
|
url: function ({ channel }) {
|
||||||
return `https://contenthub-api.eco.astro.com.my/channel/${channel.site_id}.json`
|
return `https://contenthub-api.eco.astro.com.my/channel/${channel.site_id}.json`
|
||||||
},
|
},
|
||||||
parser: function ({ content }) {
|
parser: function ({ content, date }) {
|
||||||
const programs = []
|
const programs = []
|
||||||
|
const items = parseItems(content, date)
|
||||||
|
items.forEach(item => {
|
||||||
|
const start = dayjs.utc(item.datetimeInUtc)
|
||||||
|
const duration = parseDuration(item.duration)
|
||||||
|
const stop = start.add(duration, 's')
|
||||||
|
programs.push({
|
||||||
|
title: item.title,
|
||||||
|
start: start,
|
||||||
|
stop: stop
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return programs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content, date) {
|
||||||
|
try {
|
||||||
const data = JSON.parse(content)
|
const data = JSON.parse(content)
|
||||||
const schedules = data.response.schedule
|
const schedules = data.response.schedule
|
||||||
|
|
||||||
for(let items of Object.values(schedules)){
|
return schedules[date.format('YYYY-MM-DD')] || []
|
||||||
items.forEach(item => {
|
} catch (e) {
|
||||||
const start = dayjs.utc(item.datetimeInUtc)
|
return []
|
||||||
const duration = parseDuration(item.duration)
|
|
||||||
const stop = start.add(duration, 's')
|
|
||||||
programs.push({
|
|
||||||
title: item.title,
|
|
||||||
start: start,
|
|
||||||
stop: stop
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
return programs
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue