From c5bab4ad1c395435f30eb4cf34e2cd1f91f1d322 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 18 Nov 2021 15:20:02 +0300 Subject: [PATCH 1/6] Create allente.se.test.js --- sites/allente.se/allente.se.test.js | 65 +++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 sites/allente.se/allente.se.test.js diff --git a/sites/allente.se/allente.se.test.js b/sites/allente.se/allente.se.test.js new file mode 100644 index 00000000..01ed9b19 --- /dev/null +++ b/sites/allente.se/allente.se.test.js @@ -0,0 +1,65 @@ +// node ./scripts/channels.js --config=./sites/allente.se/allente.se.config.js --output=./sites/allente.se/allente.se_se.channels.xml --set=country:se --set=lang:sv +// node ./scripts/channels.js --config=./sites/allente.se/allente.se.config.js --output=./sites/allente.se/allente.se_fi.channels.xml --set=country:fi --set=lang:fi +// node ./scripts/channels.js --config=./sites/allente.se/allente.se.config.js --output=./sites/allente.se/allente.se_no.channels.xml --set=country:no --set=lang:no +// node ./scripts/channels.js --config=./sites/allente.se/allente.se.config.js --output=./sites/allente.se/allente.se_dk.channels.xml --set=country:dk --set=lang:da +// npx epg-grabber --config=sites/allente.se/allente.se.config.js --channels=sites/allente.se/allente.se_se.channels.xml --output=.gh-pages/guides/se/allente.se.epg.xml --days=2 + +const { parser, url, logo } = require('./allente.se.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-11-17', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: 'se#0148', + xmltv_id: 'SVT1.se', + logo: 'https://images.ctfassets.net/989y85n5kcxs/5uT9g9pdQWRZeDPQXVI9g6/e02f550a32e259b9be8081e83dc64948/svt_1_logotyp_rgb_0.png' +} + +it('can generate valid url', () => { + expect(url({ date, channel })).toBe('https://cs-vcb.allente.se/epg/events?date=2021-11-17') +}) + +it('can generate valid url for different country', () => { + const dkChannel = { site_id: 'dk#0148' } + expect(url({ date, channel: dkChannel })).toBe( + 'https://cs-vcb.allente.dk/epg/events?date=2021-11-17' + ) +}) + +it('can generate valid logo url', () => { + expect(logo({ channel })).toBe( + 'https://images.ctfassets.net/989y85n5kcxs/5uT9g9pdQWRZeDPQXVI9g6/e02f550a32e259b9be8081e83dc64948/svt_1_logotyp_rgb_0.png' + ) +}) + +it('can parse response', () => { + const content = `{"channels":[{"id":"0148","icon":"//images.ctfassets.net/989y85n5kcxs/5uT9g9pdQWRZeDPQXVI9g6/e02f550a32e259b9be8081e83dc64948/svt_1_logotyp_rgb_0.png","name":"SVT1 HD (T)","events":[{"id":"0086202111170415","live":false,"time":"2021-11-17T04:15:00Z","title":"Go'kväll","details":{"title":"Go'kväll","image":"https://viasatps.api.comspace.se/PS/channeldate/image/viasat.ps/21/2021-11-16/se.cs.svt1.event.A_40938191100.jpg?size=2560x1440","description":"Svenskt magasin från 2021. Dockspelare och hundar. Intervju med dockspelarna Björn Carlberg och Petter Lennstrand, personerna bakom tv-favoriter som Allram Eest och Klotty. Nu är de aktuella med turné och en ny dockföreställning. Sofia Åhman ger nya inspirerande träningstips och hundinstruktören Helena Tilly svarar på tittarnas frågor om hundar. Reportageserien \\"Sju sorters kakor\\" fortsätter.","season":2021,"episode":121,"categories":["other"],"duration":"45"}}]}]}` + const result = parser({ content, channel }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + start: '2021-11-17T04:15:00.000Z', + stop: '2021-11-17T05:00:00.000Z', + title: `Go'kväll`, + category: ['other'], + description: `Svenskt magasin från 2021. Dockspelare och hundar. Intervju med dockspelarna Björn Carlberg och Petter Lennstrand, personerna bakom tv-favoriter som Allram Eest och Klotty. Nu är de aktuella med turné och en ny dockföreställning. Sofia Åhman ger nya inspirerande träningstips och hundinstruktören Helena Tilly svarar på tittarnas frågor om hundar. Reportageserien \"Sju sorters kakor\" fortsätter.`, + icon: 'https://viasatps.api.comspace.se/PS/channeldate/image/viasat.ps/21/2021-11-16/se.cs.svt1.event.A_40938191100.jpg?size=2560x1440' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: `{"date":"2001-11-17","categories":[],"channels":[]}` + }) + expect(result).toMatchObject([]) +}) From 906f53676fd32d17594bc85663b3170df0df9231 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 18 Nov 2021 15:20:16 +0300 Subject: [PATCH 2/6] Create allente.se.config.js --- sites/allente.se/allente.se.config.js | 60 +++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 sites/allente.se/allente.se.config.js diff --git a/sites/allente.se/allente.se.config.js b/sites/allente.se/allente.se.config.js new file mode 100644 index 00000000..33ee3c63 --- /dev/null +++ b/sites/allente.se/allente.se.config.js @@ -0,0 +1,60 @@ +const axios = require('axios') +const dayjs = require('dayjs') + +module.exports = { + site: 'allente.se', + url({ date, channel }) { + const [country] = channel.site_id.split('#') + + return `https://cs-vcb.allente.${country}/epg/events?date=${date.format('YYYY-MM-DD')}` + }, + request: { + timeout: 10000 + }, + logo({ channel }) { + return channel.logo + }, + parser({ content, channel }) { + let programs = [] + const items = parseItems(content, channel) + items.forEach(item => { + if (!item.details) return + const start = dayjs(item.time) + const stop = start.add(item.details.duration, 'm') + programs.push({ + title: item.title, + category: item.details.categories, + description: item.details.description, + icon: item.details.image, + start, + stop + }) + }) + + return programs + }, + async channels({ country, lang }) { + const data = await axios + .get(`https://cs-vcb.allente.${country}/epg/events?date=2021-11-17`) + .then(r => r.data) + .catch(console.log) + + return data.channels.map(item => { + return { + lang, + site_id: `${country}#${item.id}`, + name: item.name, + logo: `https:${item.icon}` + } + }) + } +} + +function parseItems(content, channel) { + const [_, channelId] = channel.site_id.split('#') + const data = JSON.parse(content) + if (!data || !Array.isArray(data.channels)) return [] + const channelData = data.channels.find(i => i.id === channelId) + + return channelData && Array.isArray(channelData.events) ? channelData.events : [] +} From 2730209b6176776599c0a08706c30e8a146f7266 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 18 Nov 2021 15:20:23 +0300 Subject: [PATCH 3/6] Create allente.se_dk.channels.xml --- sites/allente.se/allente.se_dk.channels.xml | 66 +++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 sites/allente.se/allente.se_dk.channels.xml diff --git a/sites/allente.se/allente.se_dk.channels.xml b/sites/allente.se/allente.se_dk.channels.xml new file mode 100644 index 00000000..663bdd0f --- /dev/null +++ b/sites/allente.se/allente.se_dk.channels.xml @@ -0,0 +1,66 @@ + + + + 6'eren + Aljazeera English + BBC World News Europe + Boomerang Nordic + Canal 9 + Cartoon Network Nordic + C More First + C More Hits + C More Series + C More Stars + CNBC Europe + CNN International Europe + Disney Channel Scandinavia + Disney Junior Scandinavia + DK 4 + DR 1 + DR 2 + DR Ramasjang + E! Europe + EuroNews English + Eurosport 2 Danmark + God TV Scandinavia + Kanal 4 + Kanal 5 + MTV 00s + MTV 80s + MTV Hits Europe + MTV Nordic + National Geographic Channel HD Europe + National Geographic Danmark + National Geographic Wild Europe + Nickelodeon Danmark + Nick Jr Scandinavia + Nicktoons Scandinavia + NRK1 + Paramount Network Danmark + SF-kanalen + Sky News International + SVT 1 + TV 2 + TV 2 Charlie + TV 2 Fri + TV 2 News + TV 2 Sport + TV 2 Zulu + TV 3 Danmark + TV 3 Max + TV 3 Puls + TV 3 Sport + TV 4 + V Film Action + V Film Family + V Film Hits + V Film Premiere + Viasat Explore + Viasat History HD + Viasat Nature + V Series + V Sport Golf + V Sport Ultra HD + Xee + + \ No newline at end of file From 4dcd9b355ac842378713908b694b3966a4284e3f Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 18 Nov 2021 15:20:26 +0300 Subject: [PATCH 4/6] Create allente.se_fi.channels.xml --- sites/allente.se/allente.se_fi.channels.xml | 41 +++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 sites/allente.se/allente.se_fi.channels.xml diff --git a/sites/allente.se/allente.se_fi.channels.xml b/sites/allente.se/allente.se_fi.channels.xml new file mode 100644 index 00000000..719c556b --- /dev/null +++ b/sites/allente.se/allente.se_fi.channels.xml @@ -0,0 +1,41 @@ + + + + Boomerang Nordic + Cartoon Network Nordic + CNBC Europe + CNN International Europe + Disney Channel Scandinavia + Disney Junior Scandinavia + E! Europe + MTV 00s + MTV Nordic + National Geographic Channel HD Europe + National Geographic Scandinavia + National Geographic Wild Europe + Nick Jr Scandinavia + TV 3 Sverige + TV 6 Sverige + V Film Action + V Film Family + V Film Hits + V Film Premiere + Viasat Explore + Viasat History HD + Viasat Nature + V Sport 1 Suomi + V Sport 1 Sverige + V Sport 2 Suomi + V Sport Football + V Sport Golf + V Sport Live 1 + V Sport Live 2 + V Sport Live 3 + V Sport Live 4 + V Sport Live 5 + V Sport + Suomi + V Sport Premium + V Sport Ultra HD + V Sport Vinter + + \ No newline at end of file From 92dcb689cde110f7cef39a637ccfc451ed59ba21 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 18 Nov 2021 15:20:29 +0300 Subject: [PATCH 5/6] Create allente.se_no.channels.xml --- sites/allente.se/allente.se_no.channels.xml | 76 +++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 sites/allente.se/allente.se_no.channels.xml diff --git a/sites/allente.se/allente.se_no.channels.xml b/sites/allente.se/allente.se_no.channels.xml new file mode 100644 index 00000000..12c25e9c --- /dev/null +++ b/sites/allente.se/allente.se_no.channels.xml @@ -0,0 +1,76 @@ + + + + Aljazeera English + BBC World News Europe + Cartoon Network Nordic + CNBC Europe + CNN International Europe + Discovery Channel Norge + Disney Channel Scandinavia + Disney Junior Scandinavia + DR 2 + E! Europe + EuroNews English + Eurosport 1 Norge + Eurosport Norge + FEM + Kunskapskanalen + Matkanalen + Max + MTV 00s + MTV 80s + MTV Hits Europe + MTV Nordic + National Geographic Channel HD Europe + National Geographic Norge + National Geographic Wild Europe + NFL Network + Nickelodeon Norge + Nick Jr Scandinavia + Nicktoons Scandinavia + NRK1 + NRK2 + NRK3 + Sky News International + SVT 1 + SVT 2 + SVT 24 + SVT Barn + TV 2 + TV 2 + TV 2 Livsstil + TV 2 Nyhetskanalen + TV 2 Sport 1 + TV 2 Sport 2 + TV 2 Sport Premium + TV 2 Zebra + TV 3 Danmark + TV 3 Norge + TV 3 Sverige + TV 6 Norge + TV 6 Sverige + TV Norge + V 4 + V Film Action + V Film Family + V Film Hits + V Film Premiere + Viasat Explore + Viasat History HD + Viasat Nature + Vox + V Series + V Sport 1 Norge + V Sport 2 + V Sport 3 + V Sport Golf + V Sport Live 1 + V Sport Live 2 + V Sport Live 3 + V Sport Live 4 + V Sport Live 5 + V Sport + + V Sport Ultra HD + + \ No newline at end of file From 925c5a7f18cac081f01ea13a1fcaedc14b17e3f3 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 18 Nov 2021 15:20:32 +0300 Subject: [PATCH 6/6] Create allente.se_se.channels.xml --- sites/allente.se/allente.se_se.channels.xml | 92 +++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 sites/allente.se/allente.se_se.channels.xml diff --git a/sites/allente.se/allente.se_se.channels.xml b/sites/allente.se/allente.se_se.channels.xml new file mode 100644 index 00000000..64a64a4c --- /dev/null +++ b/sites/allente.se/allente.se_se.channels.xml @@ -0,0 +1,92 @@ + + + + Aljazeera English + ATG Live + BBC World News Europe + Boomerang Nordic + Cartoon Network Nordic + C More First + C More Fotboll + C More Golf + C More Hits + C More Hockey + C More Live + C More Live 2 + C More Series + C More Stars + CNBC Europe + CNN International Europe + Discovery Channel Sverige + Disney Channel Scandinavia + Disney Junior Scandinavia + DR 1 + DR 2 + DR Ramasjang + E! Europe + EuroNews English + Eurosport 1 Sverige + Eurosport 2 Sverige + Godare + God TV Scandinavia + History Sverige + Horse & Country TV Sverige + Kanal 5 + Kanal 9 + Kanal 11 + Kunskapskanalen + MTV 00s + MTV Hits Europe + MTV Nordic + National Geographic Channel HD Europe + National Geographic Scandinavia + National Geographic Wild Europe + NFL Network + Nickelodeon Sverige + Nick Jr Scandinavia + Nicktoons Scandinavia + NRK1 + NRK2 + NRK3 + Paramount Network Sverige + SF-kanalen + Sjuan + Sky News International + Sportkanalen + SVT 1 + SVT 2 + SVT 24 + SVT Barn + TV 2 + TV 3 Sverige + TV 4 + TV 4 Fakta + TV 4 Film + TV 4 Guld + TV 6 Sverige + TV 8 Sverige + TV 10 + TV 12 + V Film Action + V Film Family + V Film Hits + V Film Premiere + Viasat Explore + Viasat History HD + Viasat Nature + V Series + V Sport 1 Sverige + V Sport Extra + V Sport Football + V Sport Golf + V Sport Live 1 + V Sport Live 2 + V Sport Live 3 + V Sport Live 4 + V Sport Live 5 + V Sport Motor + V Sport Premium + V Sport Ultra HD + V Sport Vinter + + \ No newline at end of file