From 59c8fa019ad503359202346b0c84285ccb3bf546 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 20 Apr 2022 16:27:13 +0300 Subject: [PATCH 1/7] Create melita.com.test.js --- sites/melita.com/melita.com.test.js | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 sites/melita.com/melita.com.test.js diff --git a/sites/melita.com/melita.com.test.js b/sites/melita.com/melita.com.test.js new file mode 100644 index 00000000..73f492ba --- /dev/null +++ b/sites/melita.com/melita.com.test.js @@ -0,0 +1,51 @@ +// npm run channels:parse -- --config=./sites/melita.com/melita.com.config.js --output=./sites/melita.com/melita.com_mt.channels.xml +// npx epg-grabber --config=sites/melita.com/melita.com.config.js --channels=sites/melita.com/melita.com_mt.channels.xml --output=guide.xml --days=2 + +const { parser, url } = require('./melita.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('2022-04-20', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '4d40a9f9-12fd-4f03-8072-61c637ff6995', + xmltv_id: 'TVM.mt' +} + +it('can generate valid url', () => { + expect(url({ channel, date })).toBe( + 'https://androme.melitacable.com/api/epg/v1/schedule/channel/4d40a9f9-12fd-4f03-8072-61c637ff6995/from/2022-04-20T00:00+00:00/until/2022-04-21T00:00+00:00' + ) +}) + +it('can parse response', () => { + const content = `{"schedules":[{"id":"138dabff-131a-42a0-9373-203545933dd0","published":{"start":"2022-04-20T06:25:00Z","end":"2022-04-20T06:45:00Z"},"program":"ae52299a-3c99-4d34-9932-e21d383f9800","live":false,"blackouts":[]}],"programs":[{"id":"ae52299a-3c99-4d34-9932-e21d383f9800","title":"How I Met Your Mother","shortSynopsis":"Symphony of Illumination - Robin gets some bad news and decides to keep it to herself. Marshall decorates the house.","posterImage":"https://androme.melitacable.com/media/images/epg/bc/07/p8953134_e_h10_ad.jpg","episode":12,"episodeTitle":"Symphony of Illumination","season":"fdd6e42c-97f9-4d7a-aaca-78b53378f960","genres":["3.5.7.3"],"tags":["comedy"],"adult":false}],"seasons":[{"id":"fdd6e42c-97f9-4d7a-aaca-78b53378f960","title":"How I Met Your Mother","adult":false,"season":7,"series":"858c535a-abbb-451b-807a-94196997ea2d"}],"series":[{"id":"858c535a-abbb-451b-807a-94196997ea2d","title":"How I Met Your Mother","adult":false}]}` + const result = parser({ content }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + start: '2022-04-20T06:25:00.000Z', + stop: '2022-04-20T06:45:00.000Z', + title: 'How I Met Your Mother', + description: + 'Symphony of Illumination - Robin gets some bad news and decides to keep it to herself. Marshall decorates the house.', + season: 7, + episode: 12, + icon: 'https://androme.melitacable.com/media/images/epg/bc/07/p8953134_e_h10_ad.jpg?form=epg-card-6', + category: ['comedy'] + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + content: `{}` + }) + expect(result).toMatchObject([]) +}) From e34ecad91fcdcb3445ca51d22d1d0fa8af278bb9 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 20 Apr 2022 16:27:16 +0300 Subject: [PATCH 2/7] Create melita.com.config.js --- sites/melita.com/melita.com.config.js | 87 +++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 sites/melita.com/melita.com.config.js diff --git a/sites/melita.com/melita.com.config.js b/sites/melita.com/melita.com.config.js new file mode 100644 index 00000000..6735cd36 --- /dev/null +++ b/sites/melita.com/melita.com.config.js @@ -0,0 +1,87 @@ +const axios = require('axios') +const dayjs = require('dayjs') + +module.exports = { + site: 'melita.com', + url: function ({ channel, date }) { + return `https://androme.melitacable.com/api/epg/v1/schedule/channel/${ + channel.site_id + }/from/${date.format('YYYY-MM-DDTHH:mmZ')}/until/${date + .add(1, 'd') + .format('YYYY-MM-DDTHH:mmZ')}` + }, + parser: function ({ content }) { + let programs = [] + const items = parseItems(content) + items.forEach(item => { + programs.push({ + title: item.title, + description: item.shortSynopsis, + icon: parseIcon(item), + category: item.tags, + season: item.season, + episode: item.episode, + start: parseStart(item), + stop: parseStop(item) + }) + }) + + return programs + }, + async channels() { + const channels = await axios + .get('https://androme.melitacable.com/api/epg/v2/channel') + .then(r => r.data) + .catch(console.log) + + return channels + .filter(i => !i.audioOnly && i.enabled) + .map(i => { + return { + name: i.name, + site_id: i.id + } + }) + } +} + +function parseStart(item) { + if (!item.published || !item.published.start) return null + + return dayjs(item.published.start) +} + +function parseStop(item) { + if (!item.published || !item.published.end) return null + + return dayjs(item.published.end) +} + +function parseIcon(item) { + return item.posterImage ? item.posterImage + '?form=epg-card-6' : null +} + +function parseItems(content) { + const data = JSON.parse(content) + if ( + !data || + !data.schedules || + !data.programs || + !data.seasons || + !data.series || + !Array.isArray(data.schedules) + ) + return [] + + return data.schedules + .map(i => { + const program = data.programs.find(p => p.id === i.program) || {} + if (!program.season) return null + const season = data.seasons.find(s => s.id === program.season) || {} + if (!season.series) return null + const series = data.series.find(s => s.id === season.series) + + return { ...i, ...program, ...season, ...series } + }) + .filter(i => i) +} From 40101abc1fa7eb9c5b40360a973c5f1ed3695319 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 20 Apr 2022 16:28:07 +0300 Subject: [PATCH 3/7] Create melita.com_mt.channels.xml --- sites/melita.com/melita.com_mt.channels.xml | 131 ++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 sites/melita.com/melita.com_mt.channels.xml diff --git a/sites/melita.com/melita.com_mt.channels.xml b/sites/melita.com/melita.com_mt.channels.xml new file mode 100644 index 00000000..e0f18226 --- /dev/null +++ b/sites/melita.com/melita.com_mt.channels.xml @@ -0,0 +1,131 @@ + + + + TVM HD + NET HD + ONE HD + TVMNEWS+ + Smash TV + ITV Shopping + f Living + Parliament Channel + Xejk + Rai Uno HD + Rai Due HD + Rai Tre HD + Rete 4 HD + Canale 5 HD + Italia 1 HD + Top Crime + Rai News + Rai Scuola + Rai Storia + Mediaset Italia + La 5 + Italia 2 + Iris + Mediaset Extra + Boing + TGCOM 24 + Rai Uno + Rai Due + Rai Tre + Euronews HD + CNN International + Bloomberg + CNBC + Al Jazeera English + Al Jazeera Arabic + France 24 in English + France 24 in French + Russia Today + CGTN + Sky News HD + BBC World News HD + TRT World HD + EWTN + TV 2000 + GOD TV + Daystar Network HD + BBC Entertainment + E! Entertainment HD + CBS Reality + Melita More + GREAT! Movies Action + Cielo + Canale Italia + FOX LIFE HD + FOX HD + AMC HD + TV Moda + Ginx TV + FTV HD + Luxe TV HD + Food Network HD + Discovery Channel + Discovery Science + TLC + National Geographic HD + Crime + Investigation + BBC Earth HD + Nat Geo Wild HD + HISTORY HD + Discovery Turbo Xtra HD + ID HD + HGTV HD + Travel HD + Discovery HD + Animal Planet HD + Disney Channel + Cartoon Network + Cartoonito + Boomerang + JimJam + Baby TV + Duck TV + Nick Junior Global + Disney Junior + Nickelodeon HD + CBeeBies HD + MTV + MTV 90s + MTV Hits + Club MTV + MTV 00s + MTV 80s + C Music TV + Radio TV + MTV Live HD + iConcerts HD + TRACE Urban HD + Mezzo HD + France 2 HD + TV5 Monde + Deutsche Welle HD + RTL II + TVE Internacional + BVN Europa + Channel One Russia + RTR Planeta + TRT Turk + Dubai One + LBC Europe + RTL + Eurosport 2 + Extreme Sports + Caccia e Pesca + Eurosport HD + TSN1 + TSN2 + TSN3 + TSN4 + TSN5 + TSN6 + TSN7 + TSN8 + Melita More HD + Melita More + Test 890 + Test 891 + + From ebcfc2e86211521d2c655f226caca846ddfeb4c3 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 21 Apr 2022 14:56:54 +0300 Subject: [PATCH 4/7] Update melita.com_mt.channels.xml --- sites/melita.com/melita.com_mt.channels.xml | 250 ++++++++++---------- 1 file changed, 124 insertions(+), 126 deletions(-) diff --git a/sites/melita.com/melita.com_mt.channels.xml b/sites/melita.com/melita.com_mt.channels.xml index e0f18226..01bc92c2 100644 --- a/sites/melita.com/melita.com_mt.channels.xml +++ b/sites/melita.com/melita.com_mt.channels.xml @@ -1,131 +1,129 @@ - TVM HD - NET HD - ONE HD - TVMNEWS+ - Smash TV - ITV Shopping - f Living - Parliament Channel - Xejk - Rai Uno HD - Rai Due HD - Rai Tre HD - Rete 4 HD - Canale 5 HD - Italia 1 HD - Top Crime - Rai News - Rai Scuola - Rai Storia - Mediaset Italia - La 5 - Italia 2 - Iris - Mediaset Extra - Boing - TGCOM 24 - Rai Uno - Rai Due - Rai Tre - Euronews HD - CNN International - Bloomberg - CNBC - Al Jazeera English - Al Jazeera Arabic - France 24 in English - France 24 in French - Russia Today - CGTN - Sky News HD - BBC World News HD - TRT World HD - EWTN - TV 2000 - GOD TV - Daystar Network HD - BBC Entertainment - E! Entertainment HD - CBS Reality - Melita More - GREAT! Movies Action - Cielo - Canale Italia - FOX LIFE HD - FOX HD - AMC HD - TV Moda - Ginx TV - FTV HD - Luxe TV HD - Food Network HD - Discovery Channel - Discovery Science - TLC - National Geographic HD - Crime + Investigation - BBC Earth HD - Nat Geo Wild HD - HISTORY HD - Discovery Turbo Xtra HD - ID HD - HGTV HD - Travel HD - Discovery HD - Animal Planet HD - Disney Channel - Cartoon Network - Cartoonito - Boomerang - JimJam - Baby TV - Duck TV - Nick Junior Global - Disney Junior - Nickelodeon HD - CBeeBies HD - MTV - MTV 90s - MTV Hits - Club MTV - MTV 00s - MTV 80s - C Music TV - Radio TV - MTV Live HD - iConcerts HD - TRACE Urban HD - Mezzo HD - France 2 HD - TV5 Monde - Deutsche Welle HD - RTL II - TVE Internacional - BVN Europa - Channel One Russia - RTR Planeta - TRT Turk - Dubai One - LBC Europe - RTL - Eurosport 2 - Extreme Sports - Caccia e Pesca - Eurosport HD - TSN1 - TSN2 - TSN3 - TSN4 - TSN5 - TSN6 - TSN7 - TSN8 - Melita More HD - Melita More - Test 890 - Test 891 + Al Jazeera Arabic + Al Jazeera English + AMC HD + Animal Planet HD + Baby TV + BBC Earth HD + BBC Entertainment + BBC World News HD + Bloomberg + Boing + Boomerang + BVN Europa + Caccia e Pesca + Canale 5 HD + Canale Italia + Cartoonito + Cartoon Network + CBeeBies HD + CBS Reality + CGTN + Channel One Russia + Cielo + TV Moda + Club MTV + C Music TV + CNBC + CNN International + Crime + Investigation + Daystar Network HD + Discovery HD + Discovery Channel + Discovery Science + Disney Channel + Disney Junior + Discovery Turbo Xtra HD + Dubai One + Duck TV + Deutsche Welle HD + E! Entertainment HD + Euronews HD + Eurosport HD + Eurosport 2 + EWTN + Extreme Sports + FTV HD + f Living + Food Network HD + FOX HD + FOX LIFE HD + France 2 HD + France 24 in English + France 24 in French + Ginx TV + GOD TV + GREAT! Movies Action + HGTV HD + HISTORY HD + ID HD + Iris + Italia 1 HD + Italia 2 + ITV Shopping + JimJam + La 5 + LBC Europe + Luxe TV HD + Mediaset Extra + Mediaset Italia + Melita More + Melita More + Melita More HD + Mezzo HD + MTV 00s + MTV 80s + MTV 90s + MTV + MTV Hits + MTV Live HD + National Geographic HD + Nat Geo Wild HD + NET HD + Nickelodeon HD + Nick Junior Global + ONE HD + Parliament Channel + Rai Uno + Rai Uno HD + Rai Due + Rai Due HD + Rai Tre + Rai Tre HD + Rai News + Rai Scuola + Rai Storia + Rete 4 HD + Radio TV + RTL + RTL II + Russia Today + RTR Planeta + Sky News HD + Smash TV + iConcerts HD + TGCOM 24 + TLC + Top Crime + TRACE Urban HD + Travel HD + TRT Turk + TRT World HD + TSN1 + TSN2 + TSN3 + TSN4 + TSN5 + TSN6 + TSN7 + TSN8 + TV 2000 + TV5 Monde + TVE Internacional + TVM HD + TVMNEWS+ + Xejk From 44e4ba80179b877db9741c7bc3c8dcbe551b81d5 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 21 Apr 2022 15:07:58 +0300 Subject: [PATCH 5/7] Update melita.com_mt.channels.xml --- sites/melita.com/melita.com_mt.channels.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sites/melita.com/melita.com_mt.channels.xml b/sites/melita.com/melita.com_mt.channels.xml index 01bc92c2..5fdd0636 100644 --- a/sites/melita.com/melita.com_mt.channels.xml +++ b/sites/melita.com/melita.com_mt.channels.xml @@ -30,8 +30,8 @@ CNN International Crime + Investigation Daystar Network HD - Discovery HD Discovery Channel + Discovery HD Discovery Science Disney Channel Disney Junior @@ -70,7 +70,6 @@ Mediaset Extra Mediaset Italia Melita More - Melita More Melita More HD Mezzo HD MTV 00s From d0c3a48ea5ee37cf58c783b72bb50f81c5108aef Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 21 Apr 2022 20:53:50 +0300 Subject: [PATCH 6/7] Update melita.com_mt.channels.xml --- sites/melita.com/melita.com_mt.channels.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sites/melita.com/melita.com_mt.channels.xml b/sites/melita.com/melita.com_mt.channels.xml index 5fdd0636..647a9e24 100644 --- a/sites/melita.com/melita.com_mt.channels.xml +++ b/sites/melita.com/melita.com_mt.channels.xml @@ -31,7 +31,7 @@ Crime + Investigation Daystar Network HD Discovery Channel - Discovery HD + Discovery HD Discovery Science Disney Channel Disney Junior @@ -57,7 +57,7 @@ GOD TV GREAT! Movies Action HGTV HD - HISTORY HD + HISTORY HD ID HD Iris Italia 1 HD From aec8075c0737131a2d614706773ca3795f027a4f Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Thu, 21 Apr 2022 20:54:27 +0300 Subject: [PATCH 7/7] Create melita.com.yml --- .github/workflows/melita.com.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/melita.com.yml diff --git a/.github/workflows/melita.com.yml b/.github/workflows/melita.com.yml new file mode 100644 index 00000000..d2bb08be --- /dev/null +++ b/.github/workflows/melita.com.yml @@ -0,0 +1,17 @@ +name: melita.com +on: + schedule: + - cron: '0 0 * * *' + 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 }}