Make code prettier
This commit is contained in:
@@ -8,39 +8,37 @@ dayjs.extend(timezone)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
module.exports = {
|
||||
site: 'rtmklik.rtm.gov.my',
|
||||
url: function ({ date, channel }) {
|
||||
return `https://rtm.glueapi.io/v3/epg/${channel.site_id}/ChannelSchedule?dateStart=${date.format(
|
||||
'YYYY-MM-DD'
|
||||
)}&dateEnd=${date.format(
|
||||
'YYYY-MM-DD'
|
||||
)}&timezone=0`
|
||||
site: 'rtmklik.rtm.gov.my',
|
||||
url: function ({ date, channel }) {
|
||||
return `https://rtm.glueapi.io/v3/epg/${
|
||||
channel.site_id
|
||||
}/ChannelSchedule?dateStart=${date.format('YYYY-MM-DD')}&dateEnd=${date.format(
|
||||
'YYYY-MM-DD'
|
||||
)}&timezone=0`
|
||||
// return `https://rtm.glueapi.io/v3/epg/99/ChannelSchedule?dateStart=${date.format('YYYY-MM-DD')}&dateEnd=${date.format('YYYY-MM-DD')}&timezone=0`
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
if (!items.length) return programs
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.programTitle,
|
||||
description: item.description,
|
||||
start: parseTime(item.dateTimeStart),
|
||||
stop: parseTime(item.dateTimeEnd)
|
||||
})
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
if (!items.length) return programs
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.programTitle,
|
||||
description: item.description,
|
||||
start: parseTime(item.dateTimeStart),
|
||||
stop: parseTime(item.dateTimeEnd)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const data = JSON.parse(content)
|
||||
return data.schedule ? data.schedule : []
|
||||
const data = JSON.parse(content)
|
||||
return data.schedule ? data.schedule : []
|
||||
}
|
||||
|
||||
function parseTime(time) {
|
||||
return dayjs.utc(time, 'YYYY-MM-DDTHH:mm:ss')
|
||||
return dayjs.utc(time, 'YYYY-MM-DDTHH:mm:ss')
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user