From 8830e4f5b05144267c7915e98e7b576ebf81924b Mon Sep 17 00:00:00 2001 From: RevGear Date: Thu, 22 Dec 2022 12:04:34 +0000 Subject: [PATCH 1/7] Add files via upload --- sites/abc.net.au/abc.net.au.config.js | 69 +++++++++++++++++++++ sites/abc.net.au/abc.net.au.test.js | 0 sites/abc.net.au/abc.net.au_au.channels.xml | 37 +++++++++++ 3 files changed, 106 insertions(+) create mode 100644 sites/abc.net.au/abc.net.au.config.js create mode 100644 sites/abc.net.au/abc.net.au.test.js create mode 100644 sites/abc.net.au/abc.net.au_au.channels.xml diff --git a/sites/abc.net.au/abc.net.au.config.js b/sites/abc.net.au/abc.net.au.config.js new file mode 100644 index 00000000..d353aecf --- /dev/null +++ b/sites/abc.net.au/abc.net.au.config.js @@ -0,0 +1,69 @@ +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: 'abc.net.au', + request: { + cache: { + ttl: 60 * 60 * 1000 // 1 hour + } + }, + url({ date }) { + return `https://epg.abctv.net.au/processed/Sydney_${date.format('YYYY-MM-DD')}.json` + }, + parser({ content, channel }) { + let programs = [] + const items = parseItems(content, channel) + items.forEach(item => { + programs.push({ + title: item.title, + sub_title: item.episode_title, + category: item.genres, + description: item.description, + season: parseSeason(item), + episode: parseEpisode(item), + rating: parseRating(item), + start: dayjs.utc(item.start_time), + stop: dayjs.utc(item.end_time) + }) + }) + + return programs + } +} + +function parseItems(content, channel) { + const data = JSON.parse(content) + if (!data) return [] + if (!Array.isArray(data.schedule)) return [] + + const channelData = data.schedule.filter(i => i.channel == channel.site_id) + return channelData.listing && Array.isArray(channelData.listing) ? channelData.listing : [] +} + +function parseSeason(item) { + return item.series_num || null +} +function parseEpisode(item) { + return item.episode_num || null +} +function parseTime(time) { + return dayjs.tz(time, 'YYYY-MM-DD HH:mm', 'Australia/Sydney') +} +function parseIcon(tem) { + return item.image_file ? `https://www.abc.net.au/tv/common/images/publicity/${item.image_file}` : null +} +function parseRating(item) { + return item.rating + ? { + system: 'ACB', + value: item.rating + } + : null + } \ No newline at end of file diff --git a/sites/abc.net.au/abc.net.au.test.js b/sites/abc.net.au/abc.net.au.test.js new file mode 100644 index 00000000..e69de29b diff --git a/sites/abc.net.au/abc.net.au_au.channels.xml b/sites/abc.net.au/abc.net.au_au.channels.xml new file mode 100644 index 00000000..2a0d6e16 --- /dev/null +++ b/sites/abc.net.au/abc.net.au_au.channels.xml @@ -0,0 +1,37 @@ + + + + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + ??? + + \ No newline at end of file From 2173835f379e1a91c1b51c7bc79ba3180ee20958 Mon Sep 17 00:00:00 2001 From: RevGear Date: Thu, 22 Dec 2022 13:29:14 +0000 Subject: [PATCH 2/7] Update abc.net.au_au.channels.xml Add channel list --- sites/abc.net.au/abc.net.au_au.channels.xml | 66 ++++++++++----------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/sites/abc.net.au/abc.net.au_au.channels.xml b/sites/abc.net.au/abc.net.au_au.channels.xml index 2a0d6e16..7988b2ec 100644 --- a/sites/abc.net.au/abc.net.au_au.channels.xml +++ b/sites/abc.net.au/abc.net.au_au.channels.xml @@ -1,37 +1,37 @@ - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? - ??? + ABC TV + ABC TV Plus + ABC ME + ABC Kids + + ABC News + Channel 10 + 10 Peach + Channel 7 + Channel 7 HD + 7mate + 7two + 7flix + Channel 9 + + 9 Life + 9 Rush + 9 Gem + 9 Go! + NITV + 10 Bold + Racing.com + SBS One + SBS World Movies + SBS Food + + SBS World Watch + 10 Shake + Spree TV + + TSVN + SBS Viceland - \ No newline at end of file + From f126cd812d05b5be542526dfb5b1e7f1d1e4b233 Mon Sep 17 00:00:00 2001 From: RevGear Date: Thu, 22 Dec 2022 14:15:16 +0000 Subject: [PATCH 3/7] Update abc.net.au.test.js test script --- sites/abc.net.au/abc.net.au.test.js | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/sites/abc.net.au/abc.net.au.test.js b/sites/abc.net.au/abc.net.au.test.js index e69de29b..80609caf 100644 --- a/sites/abc.net.au/abc.net.au.test.js +++ b/sites/abc.net.au/abc.net.au.test.js @@ -0,0 +1,52 @@ +// npx epg-grabber --config=sites/abc.net.au/abc.net.au.config.js --channels=sites/abc.net.au/abc.net.au_au.channels.xml --output=guide.xml --days=2 + +const { parser, url } = require('./abc.net.au.config.js') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +dayjs.extend(utc) + +const date = dayjs.utc('2022-12-22', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: 'ABC1', + xmltv_id: 'ABCTV.au' +} +it('can generate valid url', () => { + expect(url({ date })).toBe( + 'https://epg.abctv.net.au/processed/Sydney_2022-12-22.json + ) +}) + +it('can parse response', () => { + const content = `{"date":"2022-12-22","region":"Sydney","schedule":[{"channel":"ABC1","listing":[{"consumer_advice":"Adult Themes, Drug Use, Violence","rating":"M","show_id":912747,"repeat":true,"description":"When tragedy strikes close to home, it puts head teacher Noah Taylor on a collision course with the criminals responsible. Can the Lyell team help him stop the cycle of violence?","title":"Silent Witness","crid":"ZW2178A004S00","start_time":"2022-12-22T00:46:00","series-crid":"ZW2178A","live":false,"captioning":true,"show_type":"Episode","series_num":22,"episode_title":"Lift Up Your Hearts (part Two)","length":58,"onair_title":"Silent Witness","end_time":"2022-12-22T01:44:00","genres":["Entertainment"],"image_file":"ZW2178A004S00_460.jpg","prog_slug":"silent-witness","episode_num":4}]}]}` + + const result = parser({ content, channel }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + title: 'Silent Witness', + sub_title: 'Lift Up Your Hearts (part Two)', + description: `When tragedy strikes close to home, it puts head teacher Noah Taylor on a collision course with the criminals responsible. Can the Lyell team help him stop the cycle of violence?`, + category: 'Entertainment', + rating: 'M', + season: 22, + episode: 4, + icon: 'https://www.abc.net.au/tv/common/images/publicity/ZW2178A004S00_460.jpg', + start: '2022-12-21T13:46:00.000Z', + stop: '2022-12-21T14:44:00.000Z' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser( + { + content: `NoSuchKeyThe specified key does not exist.processed/Sydney_2023-01-17.json6MRHX5TJ12X39B3Y59rH6XRMrmkFywg8Kv58iqpI6O1fuOCuEbKa1HRRYa4buByXMBTvAhz8zuAK7X5D+ZN9ZuWxyGs=` + }, + channel + ) + expect(result).toMatchObject([]) +}) From c365d97cdef316d3a8d3ec10834803ce5f13ae3f Mon Sep 17 00:00:00 2001 From: RevGear <95308545+RevGear@users.noreply.github.com> Date: Thu, 22 Dec 2022 17:34:12 +0000 Subject: [PATCH 4/7] Update config / test --- sites/abc.net.au/abc.net.au.config.js | 21 +++++++++++++-------- sites/abc.net.au/abc.net.au.test.js | 8 +++++--- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/sites/abc.net.au/abc.net.au.config.js b/sites/abc.net.au/abc.net.au.config.js index d353aecf..21a98795 100644 --- a/sites/abc.net.au/abc.net.au.config.js +++ b/sites/abc.net.au/abc.net.au.config.js @@ -29,8 +29,9 @@ module.exports = { season: parseSeason(item), episode: parseEpisode(item), rating: parseRating(item), - start: dayjs.utc(item.start_time), - stop: dayjs.utc(item.end_time) + icon: parseIcon(item), + start: parseTime(item.start_time), + stop: parseTime(item.end_time) }) }) @@ -39,12 +40,16 @@ module.exports = { } function parseItems(content, channel) { - const data = JSON.parse(content) - if (!data) return [] - if (!Array.isArray(data.schedule)) return [] + try { + const data = JSON.parse(content) + if (!data) return [] + if (!Array.isArray(data.schedule)) return [] - const channelData = data.schedule.filter(i => i.channel == channel.site_id) - return channelData.listing && Array.isArray(channelData.listing) ? channelData.listing : [] + const channelData = data.schedule.find(i => i.channel == channel.site_id) + return channelData.listing && Array.isArray(channelData.listing) ? channelData.listing : [] + } catch (err) { + return [] + } } function parseSeason(item) { @@ -56,7 +61,7 @@ function parseEpisode(item) { function parseTime(time) { return dayjs.tz(time, 'YYYY-MM-DD HH:mm', 'Australia/Sydney') } -function parseIcon(tem) { +function parseIcon(item) { return item.image_file ? `https://www.abc.net.au/tv/common/images/publicity/${item.image_file}` : null } function parseRating(item) { diff --git a/sites/abc.net.au/abc.net.au.test.js b/sites/abc.net.au/abc.net.au.test.js index 80609caf..ce9b7164 100644 --- a/sites/abc.net.au/abc.net.au.test.js +++ b/sites/abc.net.au/abc.net.au.test.js @@ -12,7 +12,7 @@ const channel = { } it('can generate valid url', () => { expect(url({ date })).toBe( - 'https://epg.abctv.net.au/processed/Sydney_2022-12-22.json + 'https://epg.abctv.net.au/processed/Sydney_2022-12-22.json' ) }) @@ -30,8 +30,10 @@ it('can parse response', () => { title: 'Silent Witness', sub_title: 'Lift Up Your Hearts (part Two)', description: `When tragedy strikes close to home, it puts head teacher Noah Taylor on a collision course with the criminals responsible. Can the Lyell team help him stop the cycle of violence?`, - category: 'Entertainment', - rating: 'M', + category: ['Entertainment'], + rating: { + system: 'ACB', + value: 'M'}, season: 22, episode: 4, icon: 'https://www.abc.net.au/tv/common/images/publicity/ZW2178A004S00_460.jpg', From 6bca64e417a82466e7e0b21581f39c7756019d2c Mon Sep 17 00:00:00 2001 From: RevGear <95308545+RevGear@users.noreply.github.com> Date: Thu, 22 Dec 2022 17:39:57 +0000 Subject: [PATCH 5/7] Update abc.net.au_au.channels.xml --- sites/abc.net.au/abc.net.au_au.channels.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sites/abc.net.au/abc.net.au_au.channels.xml b/sites/abc.net.au/abc.net.au_au.channels.xml index 7988b2ec..504dacad 100644 --- a/sites/abc.net.au/abc.net.au_au.channels.xml +++ b/sites/abc.net.au/abc.net.au_au.channels.xml @@ -10,8 +10,8 @@ Channel 10 10 Peach Channel 7 - Channel 7 HD - 7mate + + 7mate 7two 7flix Channel 9 @@ -34,4 +34,4 @@ TSVN SBS Viceland - + From 460f550fefd4212c9a42c0bd5c5601138b5c00c9 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sat, 24 Dec 2022 02:19:14 +0300 Subject: [PATCH 6/7] Update abc.net.au_au.channels.xml Sort Lines --- sites/abc.net.au/abc.net.au_au.channels.xml | 64 ++++++++++----------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/sites/abc.net.au/abc.net.au_au.channels.xml b/sites/abc.net.au/abc.net.au_au.channels.xml index 504dacad..ab4dfc52 100644 --- a/sites/abc.net.au/abc.net.au_au.channels.xml +++ b/sites/abc.net.au/abc.net.au_au.channels.xml @@ -1,37 +1,37 @@ - ABC TV - ABC TV Plus - ABC ME - ABC Kids - - ABC News - Channel 10 - 10 Peach - Channel 7 - - 7mate - 7two - 7flix - Channel 9 - - 9 Life - 9 Rush - 9 Gem - 9 Go! - NITV - 10 Bold - Racing.com - SBS One - SBS World Movies - SBS Food - - SBS World Watch - 10 Shake - Spree TV - - TSVN - SBS Viceland + 10 Bold + 10 Peach + 10 Shake + 7flix + 7mate + 7two + 9 Gem + 9 Go! + 9 Life + 9 Rush + ABC Kids + ABC ME + ABC News + ABC TV + ABC TV Plus + Channel 10 + Channel 7 + Channel 9 + NITV + Racing.com + SBS One + SBS Food + SBS Viceland + SBS World Movies + SBS World Watch + Spree TV + TSVN + + + + + From 2a1449936dca9bb83bf000dab1d10bdef964920b Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sat, 24 Dec 2022 02:19:27 +0300 Subject: [PATCH 7/7] Create abc.net.au.yml --- .github/workflows/abc.net.au.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/abc.net.au.yml diff --git a/.github/workflows/abc.net.au.yml b/.github/workflows/abc.net.au.yml new file mode 100644 index 00000000..4ebe1b9b --- /dev/null +++ b/.github/workflows/abc.net.au.yml @@ -0,0 +1,17 @@ +name: abc.net.au +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 }}