From 6e8f2e2c25999713408ffa6379df9aead0d97bbd Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 17 Nov 2021 00:07:48 +0300 Subject: [PATCH 1/6] Update maxtv.hrvatskitelekom.hr_hr.channels.xml --- .../maxtv.hrvatskitelekom.hr_hr.channels.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr_hr.channels.xml b/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr_hr.channels.xml index d13bf7c9..1e1df152 100644 --- a/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr_hr.channels.xml +++ b/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr_hr.channels.xml @@ -121,6 +121,7 @@ Rai 3 Rai Scuola RTL 2 Hrvatska + RTL Adria Hrvatska RTL Crime Hrvatska RTL Deutschland RTL Hrvatska @@ -139,6 +140,9 @@ Sport Klub 1 Hrvatska Sport Klub 2 Srbija Sport Klub 3 + Sport Klub 4 + Sport Klub 5 + Sport Klub 6 Sport Klub Esports Sport Klub Golf Sport Klub Start From 4cbbbdfc694c52ebdc61de4baf6dcad227a4e775 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 17 Nov 2021 00:19:34 +0300 Subject: [PATCH 2/6] Create maxtv.hrvatskitelekom.hr.test.js --- .../maxtv.hrvatskitelekom.hr.test.js | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.test.js diff --git a/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.test.js b/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.test.js new file mode 100644 index 00000000..3c8485ea --- /dev/null +++ b/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.test.js @@ -0,0 +1,59 @@ +// npx epg-grabber --config=sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.config.js --channels=sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr_hr.channels.xml --output=.gh-pages/guides/hr/maxtv.hrvatskitelekom.hr.epg.xml --days=2 + +const { parser, url, request, logo } = require('./maxtv.hrvatskitelekom.hr.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-16', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '316', + xmltv_id: '24KitchenHrvatska.us' +} +const content = `{"status":{"code":200,"message":"OK","authType":"Unauthenticated","ottSessionToken":null},"data":[{"channelId":"316","title":"24Kitchen","logo":"http://ottepg5.nexttv.ht.hr:33200/EPG/jsp/images/universal/film/logo/fileEntity/20161109/000200/XTV100002173/493d03f8-0f08-4932-8371-e5b57d96f17d.png","chanNumber":500,"hasCatchup":false,"ottChannel":true,"userSubscribed":false,"shows":[{"showId":"17298142","title":"Najčudniji svjetski restorani","startTime":1636952400,"endTime":1636952700,"category":"Kulinarski","hasReminder":false,"hasRecording":false,"hasSeriesRecording":false,"userOttPlayable":false,"userLocked":false,"isPPV":false,"buyPrice":""}]}]}` + +it('can generate valid url', () => { + expect(url).toBe('https://player.maxtvtogo.tportal.hr:8082/OTT4Proxy/proxy/epg/shows') +}) + +it('can generate valid request data', () => { + expect(request.data({ channel, date })).toMatchObject({ + channelList: ['316'], + startDate: 1637020800, + endDate: 1637107200 + }) +}) + +it('can get logo url', () => { + expect(logo({ channel, content })).toBe( + 'http://ottepg5.nexttv.ht.hr:33200/EPG/jsp/images/universal/film/logo/fileEntity/20161109/000200/XTV100002173/493d03f8-0f08-4932-8371-e5b57d96f17d.png' + ) +}) + +it('can parse response', () => { + const result = parser({ channel, content }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + start: '2021-11-15T05:00:00.000Z', + stop: '2021-11-15T05:05:00.000Z', + title: 'Najčudniji svjetski restorani', + category: 'Kulinarski' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: `{"status":{"code":200,"message":"OK","authType":"Unauthenticated","ottSessionToken":null},"data":[]}` + }) + expect(result).toMatchObject([]) +}) From 59c9e2a4259d5301c2668e21012604a6b6e060b7 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 17 Nov 2021 00:19:41 +0300 Subject: [PATCH 3/6] Update maxtv.hrvatskitelekom.hr.config.js --- .../maxtv.hrvatskitelekom.hr.config.js | 54 ++++++++++--------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.config.js b/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.config.js index a66f8090..e7b17990 100644 --- a/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.config.js +++ b/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.config.js @@ -7,37 +7,43 @@ module.exports = { data: function ({ channel, date }) { return { channelList: [channel.site_id], - startDate: date.startOf('d').unix(), - endDate: date.endOf('d').unix() + startDate: date.unix(), + endDate: date.add(1, 'd').unix() } } }, - url: function ({ date, channel }) { - return `https://player.maxtvtogo.tportal.hr:8082/OTT4Proxy/proxy/epg/shows` - }, - logo: function ({ content }) { - const json = JSON.parse(content) - return json.data ? json.data[0].logo : null - }, - parser: function ({ content }) { - const programs = [] - const json = JSON.parse(content) - if (!json.data) return programs + url: 'https://player.maxtvtogo.tportal.hr:8082/OTT4Proxy/proxy/epg/shows', + logo: function ({ content, channel }) { + const data = parseContent(content, channel) - const items = json.data[0].shows + return data ? data.logo : null + }, + parser: function ({ content, channel }) { + const programs = [] + const items = parseItems(content, channel) items.forEach(item => { - if (item.title && item.startTime && item.endTime) { - const start = dayjs.unix(item.startTime) - const stop = dayjs.unix(item.endTime) - programs.push({ - title: item.title, - category: item.category, - start: start.toString(), - stop: stop.toString() - }) - } + if (item.showId === -1) return + programs.push({ + title: item.title, + category: item.category, + start: dayjs.unix(item.startTime), + stop: dayjs.unix(item.endTime) + }) }) return programs } } + +function parseContent(content, channel) { + const json = JSON.parse(content) + if (!Array.isArray(json.data)) return null + + return json.data.find(i => i.channelId == channel.site_id) +} + +function parseItems(content, channel) { + const data = parseContent(content, channel) + + return data && Array.isArray(data.shows) ? data.shows : [] +} From 9e6e44bb4212e595da8b0a0a0d20456c33157847 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 17 Nov 2021 00:21:33 +0300 Subject: [PATCH 4/6] Update maxtv.hrvatskitelekom.hr.test.js --- sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.test.js b/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.test.js index 3c8485ea..f9840281 100644 --- a/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.test.js +++ b/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.test.js @@ -12,7 +12,7 @@ const channel = { site_id: '316', xmltv_id: '24KitchenHrvatska.us' } -const content = `{"status":{"code":200,"message":"OK","authType":"Unauthenticated","ottSessionToken":null},"data":[{"channelId":"316","title":"24Kitchen","logo":"http://ottepg5.nexttv.ht.hr:33200/EPG/jsp/images/universal/film/logo/fileEntity/20161109/000200/XTV100002173/493d03f8-0f08-4932-8371-e5b57d96f17d.png","chanNumber":500,"hasCatchup":false,"ottChannel":true,"userSubscribed":false,"shows":[{"showId":"17298142","title":"Najčudniji svjetski restorani","startTime":1636952400,"endTime":1636952700,"category":"Kulinarski","hasReminder":false,"hasRecording":false,"hasSeriesRecording":false,"userOttPlayable":false,"userLocked":false,"isPPV":false,"buyPrice":""}]}]}` +const content = `{"status":{"code":200,"message":"OK","authType":"Unauthenticated","ottSessionToken":null},"data":[{"channelId":"316","title":"24Kitchen","logo":"http://ottepg5.nexttv.ht.hr:33200/EPG/jsp/images/universal/film/logo/fileEntity/20161109/000200/XTV100002173/493d03f8-0f08-4932-8371-e5b57d96f17d.png","chanNumber":500,"hasCatchup":false,"ottChannel":true,"userSubscribed":false,"shows":[{"showId":"-1","title":"Nema informacija","startTime":1636952400,"endTime":1636967400,"category":"ostalo","hasReminder":false,"hasRecording":false,"hasSeriesRecording":false,"userOttPlayable":false,"userLocked":false,"isPPV":false,"buyPrice":""},{"showId":"17298142","title":"Najčudniji svjetski restorani","startTime":1636952400,"endTime":1636952700,"category":"Kulinarski","hasReminder":false,"hasRecording":false,"hasSeriesRecording":false,"userOttPlayable":false,"userLocked":false,"isPPV":false,"buyPrice":""}]}]}` it('can generate valid url', () => { expect(url).toBe('https://player.maxtvtogo.tportal.hr:8082/OTT4Proxy/proxy/epg/shows') From 43ded66833e91a8e499aa00c80d95f95976067ad Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 17 Nov 2021 00:21:37 +0300 Subject: [PATCH 5/6] Update maxtv.hrvatskitelekom.hr.config.js --- .../maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.config.js b/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.config.js index e7b17990..f34d9524 100644 --- a/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.config.js +++ b/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.config.js @@ -22,7 +22,7 @@ module.exports = { const programs = [] const items = parseItems(content, channel) items.forEach(item => { - if (item.showId === -1) return + if (item.showId == -1) return programs.push({ title: item.title, category: item.category, From 6ed1b3d072dab741cafd4a14813afe58c4311be9 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Wed, 17 Nov 2021 00:24:26 +0300 Subject: [PATCH 6/6] Update canalplus-reunion.com.config.js --- sites/canalplus-reunion.com/canalplus-reunion.com.config.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sites/canalplus-reunion.com/canalplus-reunion.com.config.js b/sites/canalplus-reunion.com/canalplus-reunion.com.config.js index 218a7bff..b0bba85c 100644 --- a/sites/canalplus-reunion.com/canalplus-reunion.com.config.js +++ b/sites/canalplus-reunion.com/canalplus-reunion.com.config.js @@ -1,9 +1,12 @@ const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') + +dayjs.extend(utc) module.exports = { site: 'canalplus-reunion.com', url: function ({ channel, date }) { - const diff = date.diff(dayjs().startOf('d'), 'd') + const diff = date.diff(dayjs.utc().startOf('d'), 'd') return `https://service.canal-overseas.com/ott-frontend/vector/63001/channel/${channel.site_id}/events?filter.day=${diff}` },