Add guide for rtmklik.rtm.gov.my

This commit is contained in:
RevGear
2022-09-11 09:36:24 +01:00
parent 9d15377b85
commit 692b1dd1ab
3 changed files with 103 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const timezone = require('dayjs/plugin/timezone')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(utc)
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`
// 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)
})
})
return programs
}
}
function parseItems(content) {
const data = JSON.parse(content)
return data.schedule ? data.schedule : []
}
function parseTime(time) {
return dayjs.utc(time, 'YYYY-MM-DDTHH:mm:ss')
}