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}`
},
diff --git a/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.config.js b/sites/maxtv.hrvatskitelekom.hr/maxtv.hrvatskitelekom.hr.config.js
index a66f8090..f34d9524 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 : []
+}
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..f9840281
--- /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":"-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')
+})
+
+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([])
+})
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