From aca2a84a755ca51a452aa086600659661f04eec2 Mon Sep 17 00:00:00 2001 From: RevGear <95308545+RevGear@users.noreply.github.com> Date: Fri, 20 Jan 2023 17:49:39 +0000 Subject: [PATCH 1/3] Add guide for sky.co.nz --- sites/sky.co.nz/__data__/content.json | 140 +++++++++++++++++++++++++ sites/sky.co.nz/sky.co.nz.channels.xml | 117 +++++++++++++++++++++ sites/sky.co.nz/sky.co.nz.config.js | 53 ++++++++++ sites/sky.co.nz/sky.co.nz.test.js | 60 +++++++++++ 4 files changed, 370 insertions(+) create mode 100644 sites/sky.co.nz/__data__/content.json create mode 100644 sites/sky.co.nz/sky.co.nz.channels.xml create mode 100644 sites/sky.co.nz/sky.co.nz.config.js create mode 100644 sites/sky.co.nz/sky.co.nz.test.js diff --git a/sites/sky.co.nz/__data__/content.json b/sites/sky.co.nz/__data__/content.json new file mode 100644 index 00000000..c721cffc --- /dev/null +++ b/sites/sky.co.nz/__data__/content.json @@ -0,0 +1,140 @@ +{ + "total" : 15, + "returned" : 15, + "events" : [ { + "id" : "048382396", + "title" : "Sing 2", + "synopsis" : "Animated: Buster Moon and his friends must persuade the world's most reclusive rock star to help launch their most dazzling extravaganza yet. Voices Of: Matthew McConaughey, Reese Witherspoon (2021)", + "channelNumber" : 36, + "start" : "1674258060000", + "end" : "1674264480000", + "genres" : [ "Animated" ], + "rating" : "PG" + }, { + "id" : "048389721", + "title" : "Barbie And The Magic Of Pegasus", + "synopsis" : "Animated: An incident with an evil warlock sends Princess Annika on a mission to Cloud Kingdom with her new friend, a flying horse named Brietta. Voices Of: Kelly Sheridan, Lalainia Lindbjerg (2005)", + "channelNumber" : 36, + "start" : "1674264480000", + "end" : "1674269760000", + "genres" : [ "Animated" ], + "rating" : "G" + }, { + "id" : "048382714", + "title" : "A Starstruck Christmas", + "synopsis" : "Drama: With her beloved theatre on the verge of closure, Ridley gets some Hollywood help to ensure this year's rendition of A Christmas Carol is a success. Stars: Jamie Perez, Thomas McDonell (2021)", + "channelNumber" : 36, + "start" : "1674269760000", + "end" : "1674274980000", + "genres" : [ "Drama" ], + "rating" : "PG" + }, { + "id" : "048283877", + "title" : "The Bad Guys", + "synopsis" : "Animated: A crackerjack criminal crew of animal outlaws are about to attempt their most challenging con yet - becoming model citizens. Voices Of: Sam Rockwell, Zazie Beetz (2021)", + "channelNumber" : 36, + "start" : "1674274980000", + "end" : "1674280800000", + "genres" : [ "Animated" ], + "rating" : "PG-V" + }, { + "id" : "048273364", + "title" : "The Smurfs 2", + "synopsis" : "Family: Gargamel kidnaps Smurfette because she knows a spell that can turn his newest creations - creatures called the Naughties - into real Smurfs. Stars: Neil Patrick Harris, Hank Azaria (2013)", + "channelNumber" : 36, + "start" : "1674280800000", + "end" : "1674286920000", + "genres" : [ "Family" ], + "rating" : "G" + }, { + "id" : "048284595", + "title" : "Harry Potter and the Goblet of Fire", + "synopsis" : "Adventure: Harry is selected to represent Hogwarts at a legendary and dangerous wizardry competition between three schools of magic. Stars: Daniel Radcliffe, Rupert Grint (2005)", + "channelNumber" : 36, + "start" : "1674286920000", + "end" : "1674295980000", + "genres" : [ "Action/Adventure" ], + "rating" : "M-V" + }, { + "id" : "048382358", + "title" : "Gulliver Returns", + "synopsis" : "Animated: Gulliver is invited to return to Lilliput. With enemies at their gates, Lilliput's citizens were not expecting a regularly sized Gulliver! Voices Of: Wayne Grayson, Billy Bod Thompson (2021)", + "channelNumber" : 36, + "start" : "1674295980000", + "end" : "1674301260000", + "genres" : [ "Animated" ], + "rating" : "G" + }, { + "id" : "048348956", + "title" : "A-X-L", + "synopsis" : "Adventure: A top-secret, robotic dog with advanced artificial intelligence is found by a young boy in the desert. The two go on to develop a special friendship. Stars: Alex Neustaedter, Becky G (2018)", + "channelNumber" : 36, + "start" : "1674301260000", + "end" : "1674307020000", + "genres" : [ "Family" ], + "rating" : "PG-LV" + }, { + "id" : "048349054", + "title" : "The Lego Movie", + "synopsis" : "Animated: An ordinary LEGO minifigure is recruited to help stop an evil tyrant from gluing the universe together. Voices Of: Will Arnett, Elizabeth Banks (2014)", + "channelNumber" : 36, + "start" : "1674307020000", + "end" : "1674312840000", + "genres" : [ "Animated" ], + "rating" : "PG-V" + }, { + "id" : "048386420", + "title" : "Power Rangers", + "synopsis" : "Adventure: Five ordinary teenagers are accidentally imbued with ancient powers, which they must use to save the planet from a vengeful and powerful evil. Stars: Dacre Montgomery, Naomi Scott (2017)", + "channelNumber" : 36, + "start" : "1674312840000", + "end" : "1674320040000", + "genres" : [ "Action/Adventure" ], + "rating" : "M-V" + }, { + "id" : "048390609", + "title" : "Harry Potter and the Goblet of Fire", + "synopsis" : "Adventure: Harry is selected to represent Hogwarts at a legendary and dangerous wizardry competition between three schools of magic. Stars: Daniel Radcliffe, Rupert Grint (2005)", + "channelNumber" : 36, + "start" : "1674320040000", + "end" : "1674329100000", + "genres" : [ "Action/Adventure" ], + "rating" : "M-V" + }, { + "id" : "048390611", + "title" : "Barbie: The Pearl Princess", + "synopsis" : "Animated: A mermaid with magical pearl powers is excited to attend a royal ball. However, a group of villains are scheming to take over the kingdom. Voices Of: Kelly Sheridan, Katie Crown (2014)", + "channelNumber" : 36, + "start" : "1674329100000", + "end" : "1674333420000", + "genres" : [ "Animated" ], + "rating" : "G" + }, { + "id" : "048389739", + "title" : "Planet 51", + "synopsis" : "Animated: An astronaut lands on Planet 51. The little green people who live there believe the astronaut aims to start an alien invasion! Voices Of: Dwayne Johnson, Jessica Biel (2009)", + "channelNumber" : 36, + "start" : "1674333420000", + "end" : "1674338700000", + "genres" : [ "Animated" ], + "rating" : "PG-V" + }, { + "id" : "048295351", + "title" : "Goosebumps ", + "synopsis" : "Family: Every monster from the Goosebumps series comes alive and are released into a small town. R.L Stine and a group of kids team up to save the day. Stars: Jack Black, Dylan Minnette (2015)", + "channelNumber" : 36, + "start" : "1674338700000", + "end" : "1674344700000", + "genres" : [ "Family" ], + "rating" : "PG-C" + }, { + "id" : "048349032", + "title" : "Smurfs: The Lost Village", + "synopsis" : "Animated: Smurfette, Brainy, Clumsy, and Hefty set off on a wild adventure to find the truth behind the legend of the lost village. Stars: Demi Lovato, Jack McBrayer (2017)", + "channelNumber" : 36, + "start" : "1674344700000", + "end" : "1674349920000", + "genres" : [ "Animated" ], + "rating" : "G" + } ] +} \ No newline at end of file diff --git a/sites/sky.co.nz/sky.co.nz.channels.xml b/sites/sky.co.nz/sky.co.nz.channels.xml new file mode 100644 index 00000000..8218e0a9 --- /dev/null +++ b/sites/sky.co.nz/sky.co.nz.channels.xml @@ -0,0 +1,117 @@ + + + + Al Jazeera + Animal Planet + BBC Earth + BBC World News + BRAVO + BRAVO +1 + Cartoon Network + CBeebies + CGTN + CGTN Documentary + CNBC + CNN International + Colors + Comedy Central + Country TV + Crime + Investigation + Daystar TV Network + Discovery Channel + Discovery Turbo + DUKE + DUKE +1 + eden + eden +1 + ESPN + ESPN2 + Face TV + Firstlight + Fox News + HGTV + History + Hope Channel + Investigation Discovery + JONES! + JONES! too + Living Channel + Maori Television + MTV + MTV Hits + National Geographic + Nick + nick jr. + Nick Music + One + One +1 + Parliament TV + Prime TV + Prime +1 + Rialto + Rush + SBN + Shine TV + Sky 5 + SKY Arena + SKY ARTS + SKY Box Office + SKY Box Office 041 + SKY Box Office 042 + SKY Box Office 043 + SKY BOX SETS + SKY Movies Action + SKY Movies Classic + SKY Movies Collection + SKY Movies Comedy + SKY Movies Family + SKY Movies Greats + SKY Movies Premiere + SKY NEWS + SKY Sport 1 + SKY Sport 2 + SKY Sport 3 + SKY Sport 4 + SKY Sport 5 + SKY Sport 6 + SKY Sport 7 + SKY Sport 8 + SKY Sport 9 + + + SKY Sport Select + SoHo + Star Gold + Star Plus Hindi + TAB Trackside 1 + TAB Trackside 2 + Te Reo + The Filipino Channel + The Shopping Channel + Three + Three +1 + TLC + TV2 + TV2 +1 + UKTV + UniversalTV + Vibe + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sites/sky.co.nz/sky.co.nz.config.js b/sites/sky.co.nz/sky.co.nz.config.js new file mode 100644 index 00000000..3255e4f8 --- /dev/null +++ b/sites/sky.co.nz/sky.co.nz.config.js @@ -0,0 +1,53 @@ +const axios = require('axios') +const dayjs = require('dayjs') + +module.exports = { + site: 'sky.co.nz', + days: 2, + url({ date, channel }) { + return `https://web-epg.sky.co.nz/prod/epgs/v1?channelNumber=${channel.site_id}&start=${date.valueOf()}&end=${date.add(1, 'day').valueOf()}&limit=20000` + }, + parser({ content, channel }) { + let programs = [] + const items = parseItems(content) + items.forEach(item => { + programs.push({ + title: item.title, + description: item.synopsis, + category: item.genres, + rating: parseRating(item), + start: dayjs(parseInt(item.start)), + stop: dayjs(parseInt(item.end)) + }) + }) + + return programs + }, + async channels() { + const data = await axios + .get(`https://skywebconfig.msl-prod.skycloud.co.nz/sky/json/channels.prod.json`) + .then(r => r.data) + .catch(console.log) + + return data.channels.map(item => { + return { + lang: 'en', + site_id: parseInt(item.number).toString(), + name: item.name + } + }) + } +} + +function parseItems(content) { + const data = JSON.parse(content) + return (data && data.events) && Array.isArray(data.events) ? data.events : [] +} + +function parseRating(item) { + if (!item.rating) return null + return { + system: 'OFLC', + value: item.rating + } +} \ No newline at end of file diff --git a/sites/sky.co.nz/sky.co.nz.test.js b/sites/sky.co.nz/sky.co.nz.test.js new file mode 100644 index 00000000..39893634 --- /dev/null +++ b/sites/sky.co.nz/sky.co.nz.test.js @@ -0,0 +1,60 @@ +// npx epg-grabber --config=sites/sky.co.nz/sky.co.nz.config.js --channels=sites/sky.co.nz/sky.co.nz.channels.xml --output=guide.xml --days=2 + +const { parser, url } = require('./sky.co.nz.config.js') +const fs = require('fs') +const path = require('path') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +dayjs.extend(utc) + +const date = dayjs.utc('2023-01-21', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '36', + xmltv_id: 'SkyMoviesFamily.nz' +} +it('can generate valid url', () => { + expect(url({ date, channel })).toBe( + 'https://web-epg.sky.co.nz/prod/epgs/v1?channelNumber=36&start=1674259200000&end=1674345600000&limit=20000' + ) +}) + +it('can parse response', () => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json')) + const result = parser({ content }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result[0]).toMatchObject({ + title: 'Sing 2', + description: `Animated: Buster Moon and his friends must persuade the world's most reclusive rock star to help launch their most dazzling extravaganza yet. Voices Of: Matthew McConaughey, Reese Witherspoon (2021)`, + category: ['Animated'], + rating: { system: 'OFLC', value: 'PG' }, + start: '2023-01-20T23:41:00.000Z', + stop: '2023-01-21T01:28:00.000Z' + }) + + expect(result[5]).toMatchObject({ + title: 'Harry Potter and the Goblet of Fire', + description: `Adventure: Harry is selected to represent Hogwarts at a legendary and dangerous wizardry competition between three schools of magic. Stars: Daniel Radcliffe, Rupert Grint (2005)`, + category: ['Action/Adventure'], + rating: { system: 'OFLC', value: 'M-V' }, + start: '2023-01-21T07:42:00.000Z', + stop: '2023-01-21T10:13:00.000Z' + }) +}) + +it('can handle empty guide', () => { + const result = parser( + { + content: `{ + "code": "DATE_FORMAT_ERROR", + "description": "DateFormat error", + "message": "Unparseable date: x" + }` + }, + channel + ) + expect(result).toMatchObject([]) +}) \ No newline at end of file From 47ebf69491c9b07b68dfa75da7fca8545dc888d5 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 20 Jan 2023 23:28:08 +0300 Subject: [PATCH 2/3] Update sky.co.nz.config.js --- sites/sky.co.nz/sky.co.nz.config.js | 86 +++++++++++++++-------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/sites/sky.co.nz/sky.co.nz.config.js b/sites/sky.co.nz/sky.co.nz.config.js index 3255e4f8..b364bad4 100644 --- a/sites/sky.co.nz/sky.co.nz.config.js +++ b/sites/sky.co.nz/sky.co.nz.config.js @@ -2,52 +2,54 @@ const axios = require('axios') const dayjs = require('dayjs') module.exports = { - site: 'sky.co.nz', - days: 2, - url({ date, channel }) { - return `https://web-epg.sky.co.nz/prod/epgs/v1?channelNumber=${channel.site_id}&start=${date.valueOf()}&end=${date.add(1, 'day').valueOf()}&limit=20000` - }, - parser({ content, channel }) { - let programs = [] - const items = parseItems(content) - items.forEach(item => { - programs.push({ - title: item.title, - description: item.synopsis, - category: item.genres, - rating: parseRating(item), - start: dayjs(parseInt(item.start)), - stop: dayjs(parseInt(item.end)) - }) - }) - - return programs - }, - async channels() { - const data = await axios - .get(`https://skywebconfig.msl-prod.skycloud.co.nz/sky/json/channels.prod.json`) - .then(r => r.data) - .catch(console.log) - - return data.channels.map(item => { - return { - lang: 'en', - site_id: parseInt(item.number).toString(), - name: item.name - } + site: 'sky.co.nz', + days: 2, + url({ date, channel }) { + return `https://web-epg.sky.co.nz/prod/epgs/v1?channelNumber=${ + channel.site_id + }&start=${date.valueOf()}&end=${date.add(1, 'day').valueOf()}&limit=20000` + }, + parser({ content, channel }) { + let programs = [] + const items = parseItems(content) + items.forEach(item => { + programs.push({ + title: item.title, + description: item.synopsis, + category: item.genres, + rating: parseRating(item), + start: dayjs(parseInt(item.start)), + stop: dayjs(parseInt(item.end)) }) - } + }) + + return programs + }, + async channels() { + const data = await axios + .get(`https://skywebconfig.msl-prod.skycloud.co.nz/sky/json/channels.prod.json`) + .then(r => r.data) + .catch(console.log) + + return data.channels.map(item => { + return { + lang: 'en', + site_id: parseInt(item.number).toString(), + name: item.name + } + }) + } } function parseItems(content) { - const data = JSON.parse(content) - return (data && data.events) && Array.isArray(data.events) ? data.events : [] + const data = JSON.parse(content) + return data && data.events && Array.isArray(data.events) ? data.events : [] } function parseRating(item) { - if (!item.rating) return null - return { - system: 'OFLC', - value: item.rating - } -} \ No newline at end of file + if (!item.rating) return null + return { + system: 'OFLC', + value: item.rating + } +} From 22ed048a1432410301b5c79b17f3be9be79906a5 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 20 Jan 2023 23:28:11 +0300 Subject: [PATCH 3/3] Create sky.co.nz.yml --- .github/workflows/sky.co.nz.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/sky.co.nz.yml diff --git a/.github/workflows/sky.co.nz.yml b/.github/workflows/sky.co.nz.yml new file mode 100644 index 00000000..544d851a --- /dev/null +++ b/.github/workflows/sky.co.nz.yml @@ -0,0 +1,17 @@ +name: sky.co.nz +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 }}