From f3ab1341462d62a901ac8e29abeb21f06deb95fa Mon Sep 17 00:00:00 2001 From: aarubui Date: Tue, 14 Dec 2021 17:39:22 +1100 Subject: [PATCH 1/2] Create sky.com.config.js --- sites/sky.com/sky.com.config.js | 35 +++++++++++ sites/sky.com/sky.com.test.js | 59 ++++++++++++++++++ sites/sky.com/sky.com_uk.channels.xml | 89 +++++++++++++++++++++++++++ 3 files changed, 183 insertions(+) create mode 100644 sites/sky.com/sky.com.config.js create mode 100644 sites/sky.com/sky.com.test.js create mode 100644 sites/sky.com/sky.com_uk.channels.xml diff --git a/sites/sky.com/sky.com.config.js b/sites/sky.com/sky.com.config.js new file mode 100644 index 00000000..4d7ed161 --- /dev/null +++ b/sites/sky.com/sky.com.config.js @@ -0,0 +1,35 @@ +const dayjs = require('dayjs') + +module.exports = { + site: 'sky.com', + url: function ({ date, channel }) { + return `https://epgservices.sky.com/5.2.2/api/2.0/channel/json/${channel.site_id}/${date.unix()}/86400/4` + }, + logo: function ({ channel }) { + return `https://d2n0069hmnqmmx.cloudfront.net/epgdata/1.0/newchanlogos/400/160/skychb${channel.site_id}.png` + }, + parser: function ({ content, date, channel }) { + const programs = [] + const items = parseItems(content, channel) + + items.forEach(item => { + programs.push({ + title: item.t, + description: item.d, + start: dayjs.unix(item.s), + stop: dayjs.unix(item.s + item.m[1]), + icon: item.img + ? `http://epgstatic.sky.com/epgdata/1.0/paimage/46/1/${item.img}` + : null + }) + }) + + return programs + } +} + +function parseItems(content, channel) { + const data = JSON.parse(content) + + return data && data.listings ? data.listings[channel.site_id] : [] +} diff --git a/sites/sky.com/sky.com.test.js b/sites/sky.com/sky.com.test.js new file mode 100644 index 00000000..96b7e572 --- /dev/null +++ b/sites/sky.com/sky.com.test.js @@ -0,0 +1,59 @@ +// npx epg-grabber --config=sites/sky.com/sky.com.config.js --channels=sites/sky.com/sky.com_uk.channels.xml --output=.gh-pages/guides/au/sky.com.epg.xml --days=2 + +const { parser, url, logo } = require('./sky.com.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('2021-12-15', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '2002', + xmltv_id: 'BBCOneLondon.uk' +} +const content = `{"listings":{"2002":[{"s":1639446600,"t":"Question of Sport","audioDescription":false,"m":[27170,1800,1,1,"--"],"rr":"S","subtitleHearing":true,"sid":53228,"d":"14/36. In this Christmas special, Paddy, Sam and Ugo are joined by Anton Du Beke, Shaun Wallace, Big Zuu and Jules Breach. Also in HD. [S]","img":"lisa/5.2.2/linear/channel/7f80ef03-3d8a-4f73-bf7d-6b03f410c7a8/2002"},{"s":1639448400,"t":"Weather for the Week Ahead","audioDescription":false,"m":[27171,300,1,1,"--"],"rr":"S","subtitleHearing":true,"sid":64799,"d":"Detailed weather forecast. Also in HD. [S]","img":"lisa/5.2.2/linear/channel/8fcf08b7-4081-499a-bf63-d100908e2d75/2002"}]}}` + +it('can generate valid url', () => { + expect(url({ channel, date })).toBe( + 'https://epgservices.sky.com/5.2.2/api/2.0/channel/json/2002/1639526400/86400/4' + ) +}) + +it('can generate valid logo url', () => { + expect(logo({ channel })).toBe( + 'https://d2n0069hmnqmmx.cloudfront.net/epgdata/1.0/newchanlogos/400/160/skychb2002.png' + ) +}) + +it('can parse response', () => { + const result = parser({ content, channel, date }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + start: '2021-12-14T01:50:00.000Z', + stop: '2021-12-14T02:20:00.000Z', + title: 'Question of Sport', + icon: 'http://epgstatic.sky.com/epgdata/1.0/paimage/46/1/lisa/5.2.2/linear/channel/7f80ef03-3d8a-4f73-bf7d-6b03f410c7a8/2002', + }, + { + start: '2021-12-14T02:20:00.000Z', + stop: '2021-12-14T02:25:00.000Z', + title: 'Weather for the Week Ahead', + icon: 'http://epgstatic.sky.com/epgdata/1.0/paimage/46/1/lisa/5.2.2/linear/channel/8fcf08b7-4081-499a-bf63-d100908e2d75/2002', + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: `{"listings":{"2002":[]}}` + }) + expect(result).toMatchObject([]) +}) diff --git a/sites/sky.com/sky.com_uk.channels.xml b/sites/sky.com/sky.com_uk.channels.xml new file mode 100644 index 00000000..71c73fde --- /dev/null +++ b/sites/sky.com/sky.com_uk.channels.xml @@ -0,0 +1,89 @@ + + + + 4Music + 4seven + 5SELECT + 5STAR + 5 USA + 92 News + Ahlulbayt TV + Akaal Channel + Al Jazeera HD + BBC Four + BBC NEWS + BBC One HD + BBC One Lon + BBC One Scot + BBC Parliament + BBC RB 1 + BBC Two + BLAZE + Box Hits + Brit Asia TV + CBBC + CBeebies + CBS Drama + CBS Justice + CBS Reality + Challenge + Channel 5 + Channel 5+1 + CITV + Create&CraftHD + Cruise1st.tv + Dave ja vu + Dave + DMAX + Drama + Drama+1 + E4 + E4+1 + Eman Channel + Film4 + Film4+1 + Food Network + Forces TV + FreeSports HD + Gems TV + HGTV + horror channel + Ideal Extra + Ideal World HD + ITV2 + ITV2+1 + ITV3 + ITV3+1 + ITV4 + ITV4+1 + ITVBe + ITV + JewelleryMaker + Kanshi TV + London Live + More4 + NOW 80s + Paramount + PBS America + Pick + POP + Quest Red + Quest Red+1 + QVC Beauty + QVC Style + Racing TV + Really + RT + Sangat + Sky Arts + Smithsonian + Spotlight TV + TalkingPictures + TBN UK + Tiny Pop + TJC + Together + YESTERDAY + YESTERDAY+1 + + From edba8dc9e51eea5c569f2ec10e5a4de3aa778f37 Mon Sep 17 00:00:00 2001 From: aarubui Date: Thu, 16 Dec 2021 08:09:13 +1100 Subject: [PATCH 2/2] Update sky.com_uk.channels.xml --- sites/sky.com/sky.com_uk.channels.xml | 116 +++++++++++++------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/sites/sky.com/sky.com_uk.channels.xml b/sites/sky.com/sky.com_uk.channels.xml index 71c73fde..6248a5f2 100644 --- a/sites/sky.com/sky.com_uk.channels.xml +++ b/sites/sky.com/sky.com_uk.channels.xml @@ -2,88 +2,88 @@ 4Music - 4seven - 5SELECT - 5STAR + 4Seven + 5 Select + 5 Star 5 USA 92 News Ahlulbayt TV - Akaal Channel - Al Jazeera HD + Akaal Channel UK + Aljazeera English BBC Four - BBC NEWS - BBC One HD - BBC One Lon - BBC One Scot + BBC News + BBC One + BBC One London + BBC One Scotland BBC Parliament - BBC RB 1 + BBC Red Button 1 BBC Two - BLAZE + Blaze UK Box Hits Brit Asia TV CBBC - CBeebies - CBS Drama - CBS Justice - CBS Reality - Challenge + CBeebies UK + CBS Drama UK + CBS Justice UK + CBS Reality UK + Challenge UK Channel 5 - Channel 5+1 + Channel 5 +1 CITV - Create&CraftHD - Cruise1st.tv + Create and Craft + Cruise 1st TV Dave ja vu - Dave - DMAX - Drama - Drama+1 - E4 - E4+1 + Dave UK + DMAX UK + Drama UK + Drama UK +1 + E4 UK + E4 UK +1 Eman Channel - Film4 - Film4+1 - Food Network + Film 4 UK + Film 4 UK +1 + Food Network UK Forces TV - FreeSports HD + FreeSports Gems TV - HGTV - horror channel + HGTV UK + Horror Channel UK Ideal Extra - Ideal World HD - ITV2 - ITV2+1 - ITV3 - ITV3+1 - ITV4 - ITV4+1 - ITVBe - ITV - JewelleryMaker + Ideal World + ITV 2 + ITV 2 +1 + ITV 3 + ITV 3 +1 + ITV 4 + ITV 4 +1 + ITV Be + ITV London + Jewellery Maker Kanshi TV London Live - More4 - NOW 80s - Paramount + More 4 UK + Now 80's + Paramount Network UK PBS America - Pick - POP - Quest Red - Quest Red+1 + Pick UK + Pop + Quest Red UK + Quest Red UK +1 QVC Beauty - QVC Style + QVC Style UK Racing TV - Really - RT - Sangat - Sky Arts - Smithsonian + Really UK + RT UK + Sangat TV + Sky Arts UK + Smithsonian Channel UK Spotlight TV - TalkingPictures + Talking Pictures TV TBN UK Tiny Pop TJC - Together - YESTERDAY - YESTERDAY+1 + Together TV + Yesterday + Yesterday +1