From 4456326eb2a33adecce1b38141f548def8efd3ae Mon Sep 17 00:00:00 2001 From: Michele Castellaneta <43062263+mcastellaneta@users.noreply.github.com> Date: Tue, 3 May 2022 11:26:22 +0200 Subject: [PATCH 01/10] Create raiplay.it.config.js --- sites/raiplay.it/raiplay.it.config.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 sites/raiplay.it/raiplay.it.config.js diff --git a/sites/raiplay.it/raiplay.it.config.js b/sites/raiplay.it/raiplay.it.config.js new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/sites/raiplay.it/raiplay.it.config.js @@ -0,0 +1 @@ + From 20edfb2b8499585f7359505940bcbecae916624f Mon Sep 17 00:00:00 2001 From: Michele Castellaneta <43062263+mcastellaneta@users.noreply.github.com> Date: Tue, 3 May 2022 11:27:15 +0200 Subject: [PATCH 02/10] Create raiplay.it_it.channels.xml --- sites/raiplay.it/raiplay.it_it.channels.xml | 1 + 1 file changed, 1 insertion(+) create mode 100644 sites/raiplay.it/raiplay.it_it.channels.xml diff --git a/sites/raiplay.it/raiplay.it_it.channels.xml b/sites/raiplay.it/raiplay.it_it.channels.xml new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/sites/raiplay.it/raiplay.it_it.channels.xml @@ -0,0 +1 @@ + From 702a1b46278f87889f28b22fdb83b324e79f668c Mon Sep 17 00:00:00 2001 From: Michele Castellaneta <43062263+mcastellaneta@users.noreply.github.com> Date: Tue, 3 May 2022 11:38:50 +0200 Subject: [PATCH 03/10] Update raiplay.it_it.channels.xml Add channel naming --- sites/raiplay.it/raiplay.it_it.channels.xml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sites/raiplay.it/raiplay.it_it.channels.xml b/sites/raiplay.it/raiplay.it_it.channels.xml index 8b137891..590e1937 100644 --- a/sites/raiplay.it/raiplay.it_it.channels.xml +++ b/sites/raiplay.it/raiplay.it_it.channels.xml @@ -1 +1,19 @@ - + + + + Rai 1 + Rai 2 + Rai 3 + Rai 4 + Rai 5 + Rai Movie + Rai Premium + Rai Gulp + Rai Yoyo + Rai Storia + Rai Scuola + Rai News 24 + Rai Sport + HD + Rai Sport + + From 9b2d4531de8a9219defada4a7bbcac848c56f94c Mon Sep 17 00:00:00 2001 From: Michele Castellaneta <43062263+mcastellaneta@users.noreply.github.com> Date: Tue, 3 May 2022 12:35:48 +0200 Subject: [PATCH 04/10] Update raiplay.it.config.js --- sites/raiplay.it/raiplay.it.config.js | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/sites/raiplay.it/raiplay.it.config.js b/sites/raiplay.it/raiplay.it.config.js index 8b137891..cd8558ea 100644 --- a/sites/raiplay.it/raiplay.it.config.js +++ b/sites/raiplay.it/raiplay.it.config.js @@ -1 +1,49 @@ +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const customParseFormat = require('dayjs/plugin/customParseFormat') +dayjs.extend(utc) +dayjs.extend(customParseFormat) + +module.exports = { + site: 'raiplay.it', + url: function ({ date, channel }) { + return `https://www.raiplay.it/palinsesto/app/${channel.site_id}/${date.format('DD-MM-YYYY')}.json` + }, + parser: function ({ content, date }) { + const programs = [] + const data = JSON.parse(content) + if (!data.events) return programs + + data.events.forEach(item => { + if (item.name && item.hour && item.duration_in_minutes) { + const startDate = dayjs + .utc(item.hour, 'HH:mm') + .set('D', date.get('D')) + .set('M', date.get('M')) + .set('y', date.get('y')) + const start = startDate.toString() + const duration = parseInt(item.duration_in_minutes) + const stopDate = startDate.utcOffset(duration) + const stop = stopDate.toString() + + programs.push({ + title: item.name || item.program.name, + description: item.description, + season: item.season || null, + episode: item.episode || null, + start, + stop, + icon: parseIcon(item) + }) + } + }) + + return programs + } +} + +function parseIcon(item) { + return cover = item.image ? `https://www.raiplay.it${item.image}` : null + +} From 9f52b366f7e78372aca25fb838581f7eed744874 Mon Sep 17 00:00:00 2001 From: Michele Castellaneta <43062263+mcastellaneta@users.noreply.github.com> Date: Tue, 3 May 2022 12:39:35 +0200 Subject: [PATCH 05/10] Create raiplay.it --- .github/workflows/raiplay.it | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/raiplay.it diff --git a/.github/workflows/raiplay.it b/.github/workflows/raiplay.it new file mode 100644 index 00000000..8877d33f --- /dev/null +++ b/.github/workflows/raiplay.it @@ -0,0 +1,17 @@ +name: raiplay.it +on: + schedule: + - cron: '10 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 }} From 98736f4f5a9be06acd2d531ce12a8e2e7fffd70c Mon Sep 17 00:00:00 2001 From: Michele Castellaneta <43062263+mcastellaneta@users.noreply.github.com> Date: Tue, 3 May 2022 12:43:31 +0200 Subject: [PATCH 06/10] Create raiplay.it.yml --- .github/workflows/raiplay.it.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/raiplay.it.yml diff --git a/.github/workflows/raiplay.it.yml b/.github/workflows/raiplay.it.yml new file mode 100644 index 00000000..a40d3831 --- /dev/null +++ b/.github/workflows/raiplay.it.yml @@ -0,0 +1,17 @@ +name: raiplay.it +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 }} From 5ced54a84ca3f4f4d0434ce2902df3ae548373a5 Mon Sep 17 00:00:00 2001 From: Michele Castellaneta <43062263+mcastellaneta@users.noreply.github.com> Date: Tue, 3 May 2022 12:47:41 +0200 Subject: [PATCH 07/10] Delete raiplay.it --- .github/workflows/raiplay.it | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .github/workflows/raiplay.it diff --git a/.github/workflows/raiplay.it b/.github/workflows/raiplay.it deleted file mode 100644 index 8877d33f..00000000 --- a/.github/workflows/raiplay.it +++ /dev/null @@ -1,17 +0,0 @@ -name: raiplay.it -on: - schedule: - - cron: '10 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 }} From 64a79313f6b2dc10390610d5343f2f6a8a3aacbe Mon Sep 17 00:00:00 2001 From: Michele Castellaneta <43062263+mcastellaneta@users.noreply.github.com> Date: Tue, 3 May 2022 14:59:53 +0200 Subject: [PATCH 08/10] Create raiplay.it.test.js --- sites/raiplay.it/raiplay.it.test.js | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 sites/raiplay.it/raiplay.it.test.js diff --git a/sites/raiplay.it/raiplay.it.test.js b/sites/raiplay.it/raiplay.it.test.js new file mode 100644 index 00000000..e2996626 --- /dev/null +++ b/sites/raiplay.it/raiplay.it.test.js @@ -0,0 +1,49 @@ +// npx epg-grabber --config=sites/raiplay.it/raiplay.it.config.js --channels=sites/raiplay.it/raiplay.it_it.channels.xml --output=guide.xml --days=2 + +const { parser, url } = require('./raiplay.it.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-05-03', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: 'rai-1', + xmltv_id: 'Rai1.it' +} + +it('can generate valid url', () => { + expect(url({ channel, date })).toBe( + 'https://www.raiplay.it/palinsesto/app/rai-2/03-05-2022.json' + ) +}) + +it('can parse response', () => { + const content = `{ "id": "Page-e120a813-1b92-4057-a214-15943d95aa68", "title": "Pagina Palinsesto", "channel": "Rai 2", "date": "03-05-2022", "events": [ { "id": "ContentItem-2f81030d-803b-456a-9ea5-40233234fd9d", "name": "The Good Doctor S3E5 - La prima volta", "episode_title": "La prima volta", "episode": "5", "season": "3", "description": "Shaun affronta il suo primo intervento. Il caso si rivela complicato e, nonostante Shaun abbia un'idea geniale, sarà Andrews a portare a termine l'operazione.", "channel": "Rai 2", "date": "03/05/2022", "hour": "19:40", "duration": "00:50:00", "duration_in_minutes": "50 min", "path_id": "", "weblink": "", "event_weblink": "/dirette/rai2/The-Good-Doctor-S3E5---La-prima-volta-2f81030d-803b-456a-9ea5-40233234fd9d.html", "has_video": false, "image": "/dl/img/2020/03/09/1583748471860_dddddd.jpg", "playlist_id": "11430689", "program": { "name": "The Good Doctor", "path_id": "/programmi/thegooddoctor.json", "info_url": "/programmi/info/757edeac-6fff-4dea-afcd-0bcb39f9ea83.json", "weblink": "/programmi/thegooddoctor" } } ], "track_info": { "id": "", "domain": "raiplay", "platform": "[platform]", "media_type": "", "page_type": "", "editor": "raiplay", "year": "2019", "edit_year": "", "section": "guida tv", "sub_section": "rai 2", "content": "guida tv", "title": "", "channel": "", "date": "2019-09-08", "typology": "", "genres": [], "sub_genres": [], "program_title": "", "program_typology": "", "program_genres": [], "program_sub_genres": [], "edition": "", "season": "", "episode_number": "", "episode_title": "", "form": "", "listaDateMo": [], "dfp": {} }}` + const result = parser({ content }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + start: '2022-05-03T19:40:00.000Z', + stop: '2022-05-03T20:30:00.000Z', + title: 'The Good Doctor S3E5 - La prima volta', + description: + "Shaun affronta il suo primo intervento. Il caso si rivela complicato e, nonostante Shaun abbia un'idea geniale, sarà Andrews a portare a termine l'operazione.", + season: 5, + episode: 3, + icon: 'https://www.raiplay.it/dl/img/2020/03/09/1583748471860_dddddd.jpg' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + content: `{"events":[],"total":0}` + }) + expect(result).toMatchObject([]) +}) From a390bfced31d0522263c8d7cf31abebf496b377e Mon Sep 17 00:00:00 2001 From: Michele Castellaneta <43062263+mcastellaneta@users.noreply.github.com> Date: Tue, 3 May 2022 17:12:38 +0200 Subject: [PATCH 09/10] Update raiplay.it.config.js --- sites/raiplay.it/raiplay.it.config.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sites/raiplay.it/raiplay.it.config.js b/sites/raiplay.it/raiplay.it.config.js index cd8558ea..980b109e 100644 --- a/sites/raiplay.it/raiplay.it.config.js +++ b/sites/raiplay.it/raiplay.it.config.js @@ -22,10 +22,10 @@ module.exports = { .set('D', date.get('D')) .set('M', date.get('M')) .set('y', date.get('y')) - const start = startDate.toString() + const start = startDate.toJSON() const duration = parseInt(item.duration_in_minutes) - const stopDate = startDate.utcOffset(duration) - const stop = stopDate.toString() + const stopDate = startDate.add(duration,'m') + const stop = stopDate.toJSON() programs.push({ title: item.name || item.program.name, From 72da6a236ce05dd93b8c8e9930479d96f269610a Mon Sep 17 00:00:00 2001 From: Michele Castellaneta <43062263+mcastellaneta@users.noreply.github.com> Date: Tue, 3 May 2022 17:12:59 +0200 Subject: [PATCH 10/10] Update raiplay.it.test.js --- sites/raiplay.it/raiplay.it.test.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/sites/raiplay.it/raiplay.it.test.js b/sites/raiplay.it/raiplay.it.test.js index e2996626..c73d4622 100644 --- a/sites/raiplay.it/raiplay.it.test.js +++ b/sites/raiplay.it/raiplay.it.test.js @@ -7,10 +7,10 @@ const customParseFormat = require('dayjs/plugin/customParseFormat') dayjs.extend(customParseFormat) dayjs.extend(utc) -const date = dayjs.utc('2022-05-03', 'YYYY-MM-DD').startOf('d') +const date = dayjs.utc('2022-05-03', 'YYYY-MM-DD') const channel = { - site_id: 'rai-1', - xmltv_id: 'Rai1.it' + site_id: 'rai-2', + xmltv_id: 'Rai2.it' } it('can generate valid url', () => { @@ -21,9 +21,7 @@ it('can generate valid url', () => { it('can parse response', () => { const content = `{ "id": "Page-e120a813-1b92-4057-a214-15943d95aa68", "title": "Pagina Palinsesto", "channel": "Rai 2", "date": "03-05-2022", "events": [ { "id": "ContentItem-2f81030d-803b-456a-9ea5-40233234fd9d", "name": "The Good Doctor S3E5 - La prima volta", "episode_title": "La prima volta", "episode": "5", "season": "3", "description": "Shaun affronta il suo primo intervento. Il caso si rivela complicato e, nonostante Shaun abbia un'idea geniale, sarà Andrews a portare a termine l'operazione.", "channel": "Rai 2", "date": "03/05/2022", "hour": "19:40", "duration": "00:50:00", "duration_in_minutes": "50 min", "path_id": "", "weblink": "", "event_weblink": "/dirette/rai2/The-Good-Doctor-S3E5---La-prima-volta-2f81030d-803b-456a-9ea5-40233234fd9d.html", "has_video": false, "image": "/dl/img/2020/03/09/1583748471860_dddddd.jpg", "playlist_id": "11430689", "program": { "name": "The Good Doctor", "path_id": "/programmi/thegooddoctor.json", "info_url": "/programmi/info/757edeac-6fff-4dea-afcd-0bcb39f9ea83.json", "weblink": "/programmi/thegooddoctor" } } ], "track_info": { "id": "", "domain": "raiplay", "platform": "[platform]", "media_type": "", "page_type": "", "editor": "raiplay", "year": "2019", "edit_year": "", "section": "guida tv", "sub_section": "rai 2", "content": "guida tv", "title": "", "channel": "", "date": "2019-09-08", "typology": "", "genres": [], "sub_genres": [], "program_title": "", "program_typology": "", "program_genres": [], "program_sub_genres": [], "edition": "", "season": "", "episode_number": "", "episode_title": "", "form": "", "listaDateMo": [], "dfp": {} }}` - const result = parser({ content }).map(p => { - p.start = p.start.toJSON() - p.stop = p.stop.toJSON() + const result = parser({ content,date }).map(p => { return p }) @@ -34,8 +32,8 @@ it('can parse response', () => { title: 'The Good Doctor S3E5 - La prima volta', description: "Shaun affronta il suo primo intervento. Il caso si rivela complicato e, nonostante Shaun abbia un'idea geniale, sarà Andrews a portare a termine l'operazione.", - season: 5, - episode: 3, + season: "3", + episode: "5", icon: 'https://www.raiplay.it/dl/img/2020/03/09/1583748471860_dddddd.jpg' } ])