mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 09:30:06 -04:00
Add guide for rtmklik.rtm.gov.my
This commit is contained in:
parent
9d15377b85
commit
692b1dd1ab
3 changed files with 103 additions and 0 deletions
46
sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.config.js
Normal file
46
sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.config.js
Normal 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')
|
||||
}
|
||||
|
||||
|
44
sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.test.js
Normal file
44
sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.test.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
const { parser, url } = require('./rtmklik.rtm.gov.my.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2022-09-04', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '2',
|
||||
xmltv_id: 'TV2.my'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ date, channel })).toBe('https://rtm.glueapi.io/v3/epg/2/ChannelSchedule?dateStart=2022-09-04&dateEnd=2022-09-04&timezone=0')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = `{"id":2,"channel":"TV2","channelId":"2","image":"/live_channel/tv2_Trans.png","idAuthor":9,"type":"TV","timezone":8,"dateCreated":"2022-07-08T01:22:33.233","dateModified":"2022-07-21T21:58:39.77","itemCount":30,"prev":"https://rtm-admin.glueapi.io/v3/epg/2/ChannelSchedule?dateStart=2022-09-03&dateEnd=2022-09-03","next":"https://rtm-admin.glueapi.io/v3/epg/2/ChannelSchedule?dateStart=2022-09-05&dateEnd=2022-09-05","schedule":[{"idEPGProgramSchedule":109303,"dateTimeStart":"2022-09-04T19:00:00","dateTimeEnd":"2022-09-04T20:00:00","scheduleProgramTitle":"Hope Of Life","scheduleProgramDescription":"Kisah kehidupan 3 pakar bedah yang berbeza status dan latar belakang, namun mereka komited dengan kerjaya mereka sebagai doktor. Lakonan : Johnson Low, Elvis Chin, Mayjune Tan, Kelvin Liew, Jacky Kam dan Katrina Ho.","scheduleEpisodeNumber":0,"scheduleSeries":0,"duration":3600,"idEPGProgram":3603,"programTitle":"Hope Of Life","description":"Kisah kehidupan 3 pakar bedah yang berbeza status dan latar belakang, namun mereka komited dengan kerjaya mereka sebagai doktor. Lakonan : Johnson Low, Elvis Chin, Mayjune Tan, Kelvin Liew, Jacky Kam dan Katrina Ho.","episodeNumber":0,"series":0,"repeat":"Never","dateModified":"2022-08-29T02:14:56.647","dateCreated":"0001-01-01T00:00:00"}]}`
|
||||
|
||||
const result = parser({ content, channel, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-09-04T19:00:00.000Z',
|
||||
stop: '2022-09-04T20:00:00.000Z',
|
||||
title: 'Hope Of Life',
|
||||
description: 'Kisah kehidupan 3 pakar bedah yang berbeza status dan latar belakang, namun mereka komited dengan kerjaya mereka sebagai doktor. Lakonan : Johnson Low, Elvis Chin, Mayjune Tan, Kelvin Liew, Jacky Kam dan Katrina Ho.'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: `{"id":2,"channel":"TV2","channelId":"2","schedule":[]}`
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
13
sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my_my_channels.xml
Normal file
13
sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my_my_channels.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="rtmklik.rtm.gov.my">
|
||||
<channels>
|
||||
<channel lang="my" xmltv_id="TV1.my" site_id="1">TV1</channel>
|
||||
<channel lang="my" xmltv_id="TV2.my" site_id="2">TV2</channel>
|
||||
<channel lang="my" xmltv_id="RTMTVOkey.my" site_id="3">RTM TV Okey</channel>
|
||||
<channel lang="my" xmltv_id="SukanRTM.my" site_id="4">Sukan RTM</channel>
|
||||
<channel lang="my" xmltv_id="BeritaRTM.my" site_id="7">Berita RTM</channel>
|
||||
<channel lang="my" xmltv_id="TV6.my" site_id="8">TV6</channel>
|
||||
<!-- <channel lang="my" xmltv_id="[-TBA-]" site_id="9">RTM Parlimen Dewan Rakyat</channel> -->
|
||||
<!-- <channel lang="my" xmltv_id="[-TBA-]" site_id="10">RTM Parlimen Dewan Negara</channel> -->
|
||||
</channels>
|
||||
</site>
|
Loading…
Add table
Add a link
Reference in a new issue