From 692b1dd1ab4468e5c004f858019522eaba362f6b Mon Sep 17 00:00:00 2001
From: RevGear <95308545+RevGear@users.noreply.github.com>
Date: Sun, 11 Sep 2022 09:36:24 +0100
Subject: [PATCH 1/4] Add guide for rtmklik.rtm.gov.my
---
.../rtmklik.rtm.gov.my.config.js | 46 +++++++++++++++++++
.../rtmklik.rtm.gov.my.test.js | 44 ++++++++++++++++++
.../rtmklik.rtm.gov.my_my_channels.xml | 13 ++++++
3 files changed, 103 insertions(+)
create mode 100644 sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.config.js
create mode 100644 sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.test.js
create mode 100644 sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my_my_channels.xml
diff --git a/sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.config.js b/sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.config.js
new file mode 100644
index 00000000..85517001
--- /dev/null
+++ b/sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.config.js
@@ -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')
+}
+
+
diff --git a/sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.test.js b/sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.test.js
new file mode 100644
index 00000000..b8e4e1d5
--- /dev/null
+++ b/sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.test.js
@@ -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([])
+ })
\ No newline at end of file
diff --git a/sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my_my_channels.xml b/sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my_my_channels.xml
new file mode 100644
index 00000000..5ee98228
--- /dev/null
+++ b/sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my_my_channels.xml
@@ -0,0 +1,13 @@
+
+
+
+ TV1
+ TV2
+ RTM TV Okey
+ Sukan RTM
+ Berita RTM
+ TV6
+
+
+
+
\ No newline at end of file
From 59fb0cd560a5a1a576bc7b77c2360b15dcad8e2a Mon Sep 17 00:00:00 2001
From: Aleksandr Statciuk
Date: Sun, 11 Sep 2022 19:59:28 +0300
Subject: [PATCH 2/4] Fixes filename
---
....gov.my_my_channels.xml => rtmklik.rtm.gov.my_my.channels.xml} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename sites/rtmklik.rtm.gov.my/{rtmklik.rtm.gov.my_my_channels.xml => rtmklik.rtm.gov.my_my.channels.xml} (100%)
diff --git a/sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my_my_channels.xml b/sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my_my.channels.xml
similarity index 100%
rename from sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my_my_channels.xml
rename to sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my_my.channels.xml
From aeda504d61272407b36482dd08cceb2813af6f7f Mon Sep 17 00:00:00 2001
From: Aleksandr Statciuk
Date: Sun, 11 Sep 2022 20:00:09 +0300
Subject: [PATCH 3/4] Added test command
---
.../rtmklik.rtm.gov.my.test.js | 49 ++++++++++---------
1 file changed, 27 insertions(+), 22 deletions(-)
diff --git a/sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.test.js b/sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.test.js
index b8e4e1d5..878e9782 100644
--- a/sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.test.js
+++ b/sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.test.js
@@ -1,3 +1,5 @@
+// npx epg-grabber --config=sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my.config.js --channels=sites/rtmklik.rtm.gov.my/rtmklik.rtm.gov.my_my.channels.xml --output=guide.xml --days=2
+
const { parser, url } = require('./rtmklik.rtm.gov.my.config.js')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
@@ -12,33 +14,36 @@ const channel = {
}
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')
+ 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 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
- })
+ 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.'
- }
- ])
+ 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([])
- })
\ No newline at end of file
+ const result = parser({
+ date,
+ channel,
+ content: `{"id":2,"channel":"TV2","channelId":"2","schedule":[]}`
+ })
+ expect(result).toMatchObject([])
+})
From 38c47339c9317221edc094b7ff088e28a43372ba Mon Sep 17 00:00:00 2001
From: Aleksandr Statciuk
Date: Sun, 11 Sep 2022 20:00:14 +0300
Subject: [PATCH 4/4] Create rtmklik.rtm.gov.my.yml
---
.github/workflows/rtmklik.rtm.gov.my.yml | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 .github/workflows/rtmklik.rtm.gov.my.yml
diff --git a/.github/workflows/rtmklik.rtm.gov.my.yml b/.github/workflows/rtmklik.rtm.gov.my.yml
new file mode 100644
index 00000000..5708a16f
--- /dev/null
+++ b/.github/workflows/rtmklik.rtm.gov.my.yml
@@ -0,0 +1,17 @@
+name: rtmklik.rtm.gov.my
+on:
+ schedule:
+ - cron: '0 3 * * *'
+ workflow_dispatch:
+ workflow_run:
+ workflows: [_trigger]
+ types:
+ - completed
+jobs:
+ load:
+ uses: ./.github/workflows/_load.yml
+ with:
+ site: ${{github.workflow}}
+ secrets:
+ APP_ID: ${{ secrets.APP_ID }}
+ APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}