From b1a298a10c67255ff07a72c7ee6fb6565867249e Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 4 Oct 2022 14:46:50 +0300 Subject: [PATCH 1/4] Create mysky.com.ph.test.js --- sites/mysky.com.ph/mysky.com.ph.test.js | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 sites/mysky.com.ph/mysky.com.ph.test.js diff --git a/sites/mysky.com.ph/mysky.com.ph.test.js b/sites/mysky.com.ph/mysky.com.ph.test.js new file mode 100644 index 00000000..fe9109ad --- /dev/null +++ b/sites/mysky.com.ph/mysky.com.ph.test.js @@ -0,0 +1,46 @@ +// npx epg-grabber --config=sites/mysky.com.ph/mysky.com.ph.config.js --channels=sites/mysky.com.ph/mysky.com.ph_ph.channels.xml --output=guide.xml --days=2 +// npm run channels:parse -- --config=./sites/mysky.com.ph/mysky.com.ph.config.js --output=./sites/mysky.com.ph/mysky.com.ph_ph.channels.xml + +const { parser, url } = require('./mysky.com.ph.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-10-04', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '8', + xmltv_id: 'KapamilyaChannel.ph' +} + +it('can generate valid url', () => { + expect(url).toBe('https://skyepg.mysky.com.ph/Main/getEventsbyType') +}) + +it('can parse response', () => { + const content = `{"events":[{"name":"TV PATROL","location":"8","start":"2022/10/04 19:00","end":"2022/10/04 20:00","userData":{"description":"Description example"}},{"name":"DARNA","location":"8","start":"2022/10/05 20:00","end":"2022/10/05 20:45","userData":{"description":""}},{"name":"Zoe Bakes S1","location":"22","start":"2022/10/04 20:30","end":"2022/10/04 21:00","userData":{"description":"Zo Franois Dad is a beekeeper. So for his birthday, she bakes him a special beehiveshaped cake."}}]}` + 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-10-04T11:00:00.000Z', + stop: '2022-10-04T12:00:00.000Z', + title: 'TV PATROL', + description: 'Description example' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + content: ``, + channel, + date + }) + expect(result).toMatchObject([]) +}) From 398124bfa258bcd180277c3df5f3b14192d323a8 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 4 Oct 2022 14:46:54 +0300 Subject: [PATCH 2/4] Create mysky.com.ph.config.js --- sites/mysky.com.ph/mysky.com.ph.config.js | 61 +++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 sites/mysky.com.ph/mysky.com.ph.config.js diff --git a/sites/mysky.com.ph/mysky.com.ph.config.js b/sites/mysky.com.ph/mysky.com.ph.config.js new file mode 100644 index 00000000..ecc6c46c --- /dev/null +++ b/sites/mysky.com.ph/mysky.com.ph.config.js @@ -0,0 +1,61 @@ +const axios = require('axios') +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: 'mysky.com.ph', + url: 'https://skyepg.mysky.com.ph/Main/getEventsbyType', + request: { + cache: { + ttl: 60 * 60 * 1000 // 1 hour + } + }, + parser: function ({ content, channel, date }) { + let programs = [] + const items = parseItems(content, channel, date) + items.forEach(item => { + programs.push({ + title: item.name, + description: item.userData.description, + start: parseStart(item), + stop: parseStop(item) + }) + }) + + return programs + }, + async channels() { + const items = await axios + .get(`https://skyepg.mysky.com.ph/Main/getEventsbyType`) + .then(r => r.data.location) + .catch(console.log) + + return items.map(item => ({ + site_id: item.id, + name: item.name + })) + } +} + +function parseStart(item) { + return dayjs.tz(item.start, 'YYYY/MM/DD HH:mm', 'Asia/Manila') +} + +function parseStop(item) { + return dayjs.tz(item.end, 'YYYY/MM/DD HH:mm', 'Asia/Manila') +} + +function parseItems(content, channel, date) { + if (!content) return [] + const data = JSON.parse(content) + if (!data || !Array.isArray(data.events)) return [] + const d = date.format('YYYY/MM/DD') + + return data.events.filter(i => i.location == channel.site_id && i.start.includes(d)) +} From a53865295a125f7ff4d2d8a9f8982c7409f06fe2 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 4 Oct 2022 14:48:29 +0300 Subject: [PATCH 3/4] Create mysky.com.ph_ph.channels.xml --- .../mysky.com.ph/mysky.com.ph_ph.channels.xml | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 sites/mysky.com.ph/mysky.com.ph_ph.channels.xml diff --git a/sites/mysky.com.ph/mysky.com.ph_ph.channels.xml b/sites/mysky.com.ph/mysky.com.ph_ph.channels.xml new file mode 100644 index 00000000..2256dd71 --- /dev/null +++ b/sites/mysky.com.ph/mysky.com.ph_ph.channels.xml @@ -0,0 +1,135 @@ + + + + ANC + ANC HD + ASIAN FOOD NETWORK + BABY TV + CELESTIAL CLASSIC MOVIES + CINEMO! + JEEPNEY TV + KAPAMILYA CHANNEL + KBS WORLD + KIX + KNOWLEDGE CHANNEL + K-PLUS + METRO CHANNEL SD + MEZZO LIVE HD + MTV 90s + MYX + NHK WORLD JAPAN + ONE SPORTS + PBO + ROCK ENTERTAINMENT + ROCK EXTREME + SOLAR SPORTS + SPOTV + SPOTV 2 + STAR BHARAT + TapAction Flix + TAP EDGE + TAP MOVIES + TAP TV + TECH STORM + THRILL + TV5 + TVBS ASIA + TVBS NEWS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a3c0dd9c3446f6fec89d21bb3696143aab7c5a89 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 4 Oct 2022 14:48:35 +0300 Subject: [PATCH 4/4] Create mysky.com.ph.yml --- .github/workflows/mysky.com.ph.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/mysky.com.ph.yml diff --git a/.github/workflows/mysky.com.ph.yml b/.github/workflows/mysky.com.ph.yml new file mode 100644 index 00000000..958a48dd --- /dev/null +++ b/.github/workflows/mysky.com.ph.yml @@ -0,0 +1,17 @@ +name: mysky.com.ph +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 }}