mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Merge pull request #986 from RevGear/master
Canal Plus description / category
This commit is contained in:
commit
bf09b29ce3
8 changed files with 634 additions and 118 deletions
|
@ -12,18 +12,21 @@ module.exports = {
|
|||
|
||||
return `https://service.canal-overseas.com/ott-frontend/vector/83001/channel/${channel.site_id}/events?filter.day=${diff}`
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
async parser({ content }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
for (let item of items) {
|
||||
if (item.title === 'Fin des programmes') return
|
||||
const detail = await loadProgramDetails(item)
|
||||
programs.push({
|
||||
title: item.title,
|
||||
icon: item.URLImageDefault,
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
title: item.title,
|
||||
description:parseDescription(detail),
|
||||
category: parseCategory(detail),
|
||||
icon: parseIcon(item),
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return programs
|
||||
},
|
||||
|
@ -49,6 +52,28 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
async function loadProgramDetails(item) {
|
||||
if (!item.onClick.URLPage) return {}
|
||||
const url = item.onClick.URLPage
|
||||
const data = await axios
|
||||
.get(url)
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
return data || {}
|
||||
}
|
||||
|
||||
function parseDescription(detail){
|
||||
return detail.detail.informations.summary || null
|
||||
}
|
||||
|
||||
function parseCategory(detail){
|
||||
return detail.detail.informations.subGenre || null
|
||||
}
|
||||
function parseIcon(item){
|
||||
return item.URLImage || item.URLImageDefault
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.unix(item.startTime)
|
||||
}
|
||||
|
@ -67,3 +92,4 @@ function parseItems(content) {
|
|||
|
||||
return items
|
||||
}
|
||||
|
||||
|
|
|
@ -2,52 +2,149 @@
|
|||
// npx epg-grabber --config=sites/canalplus-afrique.com/canalplus-afrique.com.config.js --channels=sites/canalplus-afrique.com/canalplus-afrique.com_bf.channels.xml --output=guide.xml --days=2
|
||||
|
||||
const { parser, url } = require('./canalplus-afrique.com.config.js')
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
jest.mock('axios')
|
||||
|
||||
const channel = {
|
||||
site_id: '60020',
|
||||
xmltv_id: 'CanalPlusReunion.fr'
|
||||
site_id: '80759',
|
||||
xmltv_id: 'Animaux.fr'
|
||||
}
|
||||
|
||||
it('can generate valid url for today', () => {
|
||||
const date = dayjs.utc().startOf('d')
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/83001/channel/60020/events?filter.day=0'
|
||||
)
|
||||
const date = dayjs.utc().startOf('d')
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/83001/channel/80759/events?filter.day=0'
|
||||
)
|
||||
})
|
||||
|
||||
it('can generate valid url for tomorrow', () => {
|
||||
const date = dayjs.utc().startOf('d').add(1, 'd')
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/83001/channel/60020/events?filter.day=1'
|
||||
)
|
||||
const date = dayjs.utc().startOf('d').add(1, 'd')
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/83001/channel/80759/events?filter.day=1'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = `{"timeSlices":[{"contents":[{"title":"Fin des programmes","thirdTitle":"MA TV","startTime":1636768800,"endTime":1636855200,"onClick":{"displayTemplate":"miniDetail","displayName":"Fin des programmes","URLPage":"https://service.canal-overseas.com/ott-frontend/vector/63001/event/110427432","URLVitrine":"https://service.canal-overseas.com/ott-frontend/vector/63001/program/0/recommendations"},"programID":0,"diffusionID":"110427432","URLImageDefault":"https://service.canal-overseas.com/image-api/v1/image/generic","URLImage":"https://service.canal-overseas.com/image-api/v1/image/generic"}],"timeSlice":"0"},{"contents":[{"title":"Le cercle","subtitle":"5 Novembre 2021","thirdTitle":"CANAL+ HD","startTime":1636793201,"endTime":1636795901,"onClick":{"displayTemplate":"miniDetail","displayName":"Le cercle","URLPage":"https://service.canal-overseas.com/ott-frontend/vector/63001/event/110427540","URLVitrine":"https://service.canal-overseas.com/ott-frontend/vector/63001/program/193072081/recommendations"},"programID":193072081,"diffusionID":"110427540","URLImageDefault":"https://service.canal-overseas.com/image-api/v1/image/2a311987c642d97485d5f531e698dfb7","URLImage":"https://service.canal-overseas.com/image-api/v1/image/2de336e6a8c962921638c8aeee5f7e52"}],"timeSlice":"1"},{"contents":[],"timeSlice":"2"},{"contents":[],"timeSlice":"3"},{"contents":[],"timeSlice":"4"}]}`
|
||||
const result = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
it('can parse response', done => {
|
||||
const content = `{"timeSlices":[{"contents":[{"title":"A petit pas","subtitle":"Episode 1 - La naissance","thirdTitle":"ANIMAUX","startTime":1660794900,"endTime":1660797900,"onClick":{"displayTemplate":"miniDetail","displayName":"A petit pas","URLPage":"https://service.canal-overseas.com/ott-frontend/vector/83001/event/140280189","URLVitrine":"https://service.canal-overseas.com/ott-frontend/vector/83001/program/104991257/recommendations"},"programID":104991257,"diffusionID":"140280189","URLImageDefault":"https://service.canal-overseas.com/image-api/v1/image/generic","URLImage":"https://service.canal-overseas.com/image-api/v1/image/7dedf4a579b66153a1988637e9e023f5"}],"timeSlice":"1"}]}`
|
||||
axios.get.mockImplementation(url => {
|
||||
if (url === 'https://service.canal-overseas.com/ott-frontend/vector/83001/event/140280189') {
|
||||
return Promise.resolve({
|
||||
data: JSON.parse(`{
|
||||
"currentPage": {
|
||||
"displayName": "A petit pas",
|
||||
"displayTemplate": "detailPage",
|
||||
"URLVitrine": "https://service.canal-overseas.com/ott-frontend/vector/83001/program/104991257/recommendations"
|
||||
},
|
||||
"detail": {
|
||||
"informations": {
|
||||
"programmeType": "EPG",
|
||||
"isInOffer": false,
|
||||
"isInOfferOnDevice": false,
|
||||
"isInOfferForD2G": false,
|
||||
"availableInVoDOnDevice": false,
|
||||
"availableInVoDOnG5": false,
|
||||
"availableInD2GOnDevice": false,
|
||||
"availableInLiveOnDevice": false,
|
||||
"rediffusions": true,
|
||||
"canBeRecorded": false,
|
||||
"channelName": "ANIMAUX",
|
||||
"startTime": 1660794900,
|
||||
"endTime": 1660797900,
|
||||
"title": "A petit pas",
|
||||
"subtitle": "Episode 1 - La naissance",
|
||||
"thirdTitle": "ANIMAUX",
|
||||
"genre": "Découverte",
|
||||
"subGenre": "Doc. Animalier",
|
||||
"editorialTitle": "Découverte, France, 2013, 0h50",
|
||||
"audioLanguage": "VF",
|
||||
"personnalities": [
|
||||
{
|
||||
"prefix": "De :",
|
||||
"content": "Emilie Fertil"
|
||||
}
|
||||
],
|
||||
"summary": "Suivi pendant une année entière de trois bébés animaux, un border collie, un poulain et un lémurien, prédestinés par leur maître à devenir de véritables champions.",
|
||||
"summaryMedium": "Suivi pendant une année entière de trois bébés animaux, un border collie, un poulain et un lémurien, prédestinés par leur maître à devenir de véritables champions.",
|
||||
"programID": 104991257,
|
||||
"sharingURL": "https://www.canalplus-afrique.com/grille-tv/event/140280189-a-petit-pas.html",
|
||||
"EpgId": 80759,
|
||||
"CSA": 1,
|
||||
"HD": false,
|
||||
"3D": false,
|
||||
"diffusionID": "140280189",
|
||||
"duration": "3000",
|
||||
"URLImageDefault": "https://service.canal-overseas.com/image-api/v1/image/generic",
|
||||
"URLImage": "https://service.canal-overseas.com/image-api/v1/image/7dedf4a579b66153a1988637e9e023f5",
|
||||
"URLLogo": "https://service.canal-overseas.com/image-api/v1/image/9d91bf8d25632e77d004cf5b84f296b1",
|
||||
"URLLogoBlack": "https://service.canal-overseas.com/image-api/v1/image/9d91bf8d25632e77d004cf5b84f296b1",
|
||||
"URLVitrine": "https://service.canal-overseas.com/ott-frontend/vector/83001/program/104991257/recommendations"
|
||||
},
|
||||
"diffusions": [
|
||||
{
|
||||
"diffusionDateUTC": 1660794900,
|
||||
"sharingUrl": "https://www.canalplus-afrique.com/grille-tv/event/140280189-a-petit-pas.html",
|
||||
"broadcastId": "140280189",
|
||||
"name": "ANIMAUX",
|
||||
"epgID": "80759",
|
||||
"ZapNumber": "161",
|
||||
"URLLogo": "https://service.canal-overseas.com/image-api/v1/image/9d91bf8d25632e77d004cf5b84f296b1",
|
||||
"URLLogoBlack": "https://service.canal-overseas.com/image-api/v1/image/9d91bf8d25632e77d004cf5b84f296b1"
|
||||
},
|
||||
{
|
||||
"diffusionDateUTC": 1661475600,
|
||||
"sharingUrl": "https://www.canalplus-afrique.com/grille-tv/event/141170299-a-petit-pas.html",
|
||||
"broadcastId": "141170299",
|
||||
"name": "ANIMAUX",
|
||||
"epgID": "80759",
|
||||
"ZapNumber": "161",
|
||||
"URLLogo": "https://service.canal-overseas.com/image-api/v1/image/9d91bf8d25632e77d004cf5b84f296b1",
|
||||
"URLLogoBlack": "https://service.canal-overseas.com/image-api/v1/image/9d91bf8d25632e77d004cf5b84f296b1"
|
||||
}
|
||||
]
|
||||
}
|
||||
}`)
|
||||
})
|
||||
} else {
|
||||
return Promise.resolve({ data: '' })
|
||||
}
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-13T08:46:41.000Z',
|
||||
stop: '2021-11-13T09:31:41.000Z',
|
||||
title: 'Le cercle',
|
||||
icon: 'https://service.canal-overseas.com/image-api/v1/image/2a311987c642d97485d5f531e698dfb7'
|
||||
}
|
||||
])
|
||||
parser({ content })
|
||||
.then(result => {
|
||||
result = result.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-08-18T03:55:00.000Z',
|
||||
stop: '2022-08-18T04:45:00.000Z',
|
||||
title: 'A petit pas',
|
||||
icon: 'https://service.canal-overseas.com/image-api/v1/image/7dedf4a579b66153a1988637e9e023f5',
|
||||
category: 'Doc. Animalier',
|
||||
description: 'Suivi pendant une année entière de trois bébés animaux, un border collie, un poulain et un lémurien, prédestinés par leur maître à devenir de véritables champions.'
|
||||
}
|
||||
])
|
||||
done()
|
||||
})
|
||||
.catch(done)
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: `{"currentPage":{"displayTemplate":"error","BOName":"Page introuvable"},"title":"Page introuvable","text":"La page que vous demandez est introuvable. Si le problème persiste, vous pouvez contacter l'assistance de CANAL+/CANALSAT.","code":404}`
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
it('can handle empty guide', done => {
|
||||
parser({
|
||||
content: `{"currentPage":{"displayTemplate":"error","BOName":"Page introuvable"},"title":"Page introuvable","text":"La page que vous demandez est introuvable. Si le problème persiste, vous pouvez contacter l'assistance de CANAL+/CANALSAT.","code":404}`
|
||||
})
|
||||
.then(result => {
|
||||
expect(result).toMatchObject([])
|
||||
done()
|
||||
})
|
||||
.catch(done)
|
||||
})
|
||||
|
|
|
@ -12,18 +12,21 @@ module.exports = {
|
|||
|
||||
return `https://service.canal-overseas.com/ott-frontend/vector/53001/channel/${channel.site_id}/events?filter.day=${diff}`
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
async parser({ content }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
for (let item of items) {
|
||||
if (item.title === 'Fin des programmes') return
|
||||
const detail = await loadProgramDetails(item)
|
||||
programs.push({
|
||||
title: item.title,
|
||||
icon: item.URLImageDefault,
|
||||
start: parseStart(item).toJSON(),
|
||||
stop: parseStop(item).toJSON()
|
||||
title: item.title,
|
||||
description:parseDescription(detail),
|
||||
category: parseCategory(detail),
|
||||
icon: parseIcon(item),
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return programs
|
||||
},
|
||||
|
@ -49,6 +52,26 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
|
||||
async function loadProgramDetails(item) {
|
||||
if (!item.onClick.URLPage) return {}
|
||||
const url = item.onClick.URLPage
|
||||
const data = await axios
|
||||
.get(url)
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
return data || {}
|
||||
}
|
||||
|
||||
function parseDescription(detail){
|
||||
return detail.detail.informations.summary || null
|
||||
}
|
||||
|
||||
function parseCategory(detail){
|
||||
return detail.detail.informations.subGenre || null
|
||||
}
|
||||
function parseIcon(item){
|
||||
return item.URLImage || item.URLImageDefault
|
||||
}
|
||||
function parseStart(item) {
|
||||
return dayjs.unix(item.startTime)
|
||||
}
|
||||
|
|
|
@ -2,48 +2,134 @@
|
|||
// npx epg-grabber --config=sites/canalplus-caraibes.com/canalplus-caraibes.com.config.js --channels=sites/canalplus-caraibes.com/canalplus-caraibes.com_bl.channels.xml --output=.gh-pages/guides/bl/canalplus-caraibes.com.epg.xml --days=2
|
||||
|
||||
const { parser, url } = require('./canalplus-caraibes.com.config.js')
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
jest.mock('axios')
|
||||
|
||||
const channel = {
|
||||
site_id: '60020',
|
||||
xmltv_id: 'CanalPlusReunion.fr'
|
||||
site_id: '50115',
|
||||
xmltv_id: 'beINSports1France.fr'
|
||||
}
|
||||
|
||||
it('can generate valid url for today', () => {
|
||||
const date = dayjs.utc().startOf('d')
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/53001/channel/60020/events?filter.day=0'
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/53001/channel/50115/events?filter.day=0'
|
||||
)
|
||||
})
|
||||
|
||||
it('can generate valid url for tomorrow', () => {
|
||||
const date = dayjs.utc().startOf('d').add(1, 'd')
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/53001/channel/60020/events?filter.day=1'
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/53001/channel/50115/events?filter.day=1'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = `{"timeSlices":[{"contents":[{"title":"Fin des programmes","thirdTitle":"MA TV","startTime":1636768800,"endTime":1636855200,"onClick":{"displayTemplate":"miniDetail","displayName":"Fin des programmes","URLPage":"https://service.canal-overseas.com/ott-frontend/vector/63001/event/110427432","URLVitrine":"https://service.canal-overseas.com/ott-frontend/vector/63001/program/0/recommendations"},"programID":0,"diffusionID":"110427432","URLImageDefault":"https://service.canal-overseas.com/image-api/v1/image/generic","URLImage":"https://service.canal-overseas.com/image-api/v1/image/generic"}],"timeSlice":"0"},{"contents":[{"title":"Le cercle","subtitle":"5 Novembre 2021","thirdTitle":"CANAL+ HD","startTime":1636793201,"endTime":1636795901,"onClick":{"displayTemplate":"miniDetail","displayName":"Le cercle","URLPage":"https://service.canal-overseas.com/ott-frontend/vector/63001/event/110427540","URLVitrine":"https://service.canal-overseas.com/ott-frontend/vector/63001/program/193072081/recommendations"},"programID":193072081,"diffusionID":"110427540","URLImageDefault":"https://service.canal-overseas.com/image-api/v1/image/2a311987c642d97485d5f531e698dfb7","URLImage":"https://service.canal-overseas.com/image-api/v1/image/2de336e6a8c962921638c8aeee5f7e52"}],"timeSlice":"1"},{"contents":[],"timeSlice":"2"},{"contents":[],"timeSlice":"3"},{"contents":[],"timeSlice":"4"}]}`
|
||||
const result = parser({ content })
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-13T08:46:41.000Z',
|
||||
stop: '2021-11-13T09:31:41.000Z',
|
||||
title: 'Le cercle',
|
||||
icon: 'https://service.canal-overseas.com/image-api/v1/image/2a311987c642d97485d5f531e698dfb7'
|
||||
}
|
||||
])
|
||||
it('can parse response', done => {
|
||||
const content = `{"timeSlices":[{"contents":[{"title":"Rugby - Leinster / La Rochelle","subtitle":"Rugby","thirdTitle":"BEIN SPORTS 1 HD","startTime":1660815000,"endTime":1660816800,"onClick":{"displayTemplate":"miniDetail","displayName":"Rugby - Leinster / La Rochelle","URLPage":"https://service.canal-overseas.com/ott-frontend/vector/53001/event/140377765","URLVitrine":"https://service.canal-overseas.com/ott-frontend/vector/53001/program/224515801/recommendations"},"programID":224515801,"diffusionID":"140377765","URLImageDefault":"https://service.canal-overseas.com/image-api/v1/image/75fca4586fdc3458930dd1ab6fc2e643","URLImage":"https://service.canal-overseas.com/image-api/v1/image/7854e20fb6efecd398598653c57cc771"}],"timeSlice":"4"}]}`
|
||||
axios.get.mockImplementation(url => {
|
||||
if (url === 'https://service.canal-overseas.com/ott-frontend/vector/53001/event/140377765') {
|
||||
return Promise.resolve({
|
||||
data: JSON.parse(`{
|
||||
"currentPage": {
|
||||
"displayName": "Rugby - Leinster / La Rochelle",
|
||||
"displayTemplate": "detailPage",
|
||||
"URLVitrine": "https://service.canal-overseas.com/ott-frontend/vector/53001/program/224515801/recommendations"
|
||||
},
|
||||
"detail": {
|
||||
"informations": {
|
||||
"programmeType": "EPG",
|
||||
"isInOffer": false,
|
||||
"isInOfferOnDevice": false,
|
||||
"isInOfferForD2G": false,
|
||||
"availableInVoDOnDevice": false,
|
||||
"availableInVoDOnG5": false,
|
||||
"availableInD2GOnDevice": false,
|
||||
"availableInLiveOnDevice": false,
|
||||
"rediffusions": true,
|
||||
"canBeRecorded": false,
|
||||
"channelName": "BEIN SPORTS 1 HD",
|
||||
"startTime": 1660815000,
|
||||
"endTime": 1660816800,
|
||||
"title": "Rugby - Leinster / La Rochelle",
|
||||
"subtitle": "Rugby",
|
||||
"thirdTitle": "BEIN SPORTS 1 HD",
|
||||
"genre": "Sport",
|
||||
"subGenre": "Rugby",
|
||||
"editorialTitle": "Sport, France, 0h30",
|
||||
"audioLanguage": "VF",
|
||||
"summary": "Retransmission d'un match de Champions Cup de rugby à XV. L'European Rugby Champions Cup est une compétition annuelle interclubs de rugby à XV disputée par les meilleures équipes en Europe. Jusqu'en 2014, cette compétition s'appelait Heineken Cup, ou H Cup, et était sous l'égide de l'ERC, et depuis cette date l'EPRC lui a succédé. La première édition s'est déroulée en 1995.",
|
||||
"summaryMedium": "Retransmission d'un match de Champions Cup de rugby à XV. L'European Rugby Champions Cup est une compétition annuelle interclubs de rugby à XV disputée par les meilleures équipes en Europe. Jusqu'en 2014, cette compétition s'appelait Heineken Cup, ou H Cup, et était sous l'égide de l'ERC, et depuis cette date l'EPRC lui a succédé. La première édition s'est déroulée en 1995.",
|
||||
"programID": 224515801,
|
||||
"sharingURL": "https://www.canalplus-caraibes.com/grille-tv/event/140377765-rugby-leinster-la-rochelle.html",
|
||||
"EpgId": 50115,
|
||||
"CSA": 1,
|
||||
"HD": false,
|
||||
"3D": false,
|
||||
"diffusionID": "140377765",
|
||||
"duration": "1800",
|
||||
"URLImageDefault": "https://service.canal-overseas.com/image-api/v1/image/75fca4586fdc3458930dd1ab6fc2e643",
|
||||
"URLImage": "https://service.canal-overseas.com/image-api/v1/image/7854e20fb6efecd398598653c57cc771",
|
||||
"URLLogo": "https://service.canal-overseas.com/image-api/v1/image/4e121baf92f46b2df622c6d4f9cebf8e",
|
||||
"URLLogoBlack": "https://service.canal-overseas.com/image-api/v1/image/4e121baf92f46b2df622c6d4f9cebf8e",
|
||||
"URLVitrine": "https://service.canal-overseas.com/ott-frontend/vector/53001/program/224515801/recommendations"
|
||||
},
|
||||
"diffusions": [
|
||||
{
|
||||
"diffusionDateUTC": 1660815000,
|
||||
"sharingUrl": "https://www.canalplus-caraibes.com/grille-tv/event/140377765-rugby-leinster-la-rochelle.html",
|
||||
"broadcastId": "140377765",
|
||||
"name": "BEIN SPORTS 1 HD",
|
||||
"epgID": "50115",
|
||||
"ZapNumber": "191",
|
||||
"URLLogo": "https://service.canal-overseas.com/image-api/v1/image/4e121baf92f46b2df622c6d4f9cebf8e",
|
||||
"URLLogoBlack": "https://service.canal-overseas.com/image-api/v1/image/4e121baf92f46b2df622c6d4f9cebf8e"
|
||||
}
|
||||
]
|
||||
}
|
||||
}`)
|
||||
})
|
||||
} else {
|
||||
return Promise.resolve({ data: '' })
|
||||
}
|
||||
})
|
||||
|
||||
parser({ content })
|
||||
.then(result => {
|
||||
result = result.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-08-18T09:30:00.000Z',
|
||||
stop: '2022-08-18T10:00:00.000Z',
|
||||
title: 'Rugby - Leinster / La Rochelle',
|
||||
icon: 'https://service.canal-overseas.com/image-api/v1/image/7854e20fb6efecd398598653c57cc771',
|
||||
category: 'Rugby',
|
||||
description: 'Retransmission d\'un match de Champions Cup de rugby à XV. L\'European Rugby Champions Cup est une compétition annuelle interclubs de rugby à XV disputée par les meilleures équipes en Europe. Jusqu\'en 2014, cette compétition s\'appelait Heineken Cup, ou H Cup, et était sous l\'égide de l\'ERC, et depuis cette date l\'EPRC lui a succédé. La première édition s\'est déroulée en 1995.'
|
||||
}
|
||||
])
|
||||
done()
|
||||
})
|
||||
.catch(done)
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: `{"currentPage":{"displayTemplate":"error","BOName":"Page introuvable"},"title":"Page introuvable","text":"La page que vous demandez est introuvable. Si le problème persiste, vous pouvez contacter l'assistance de CANAL+/CANALSAT.","code":404}`
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
it('can handle empty guide', done => {
|
||||
parser({
|
||||
content: `{"currentPage":{"displayTemplate":"error","BOName":"Page introuvable"},"title":"Page introuvable","text":"La page que vous demandez est introuvable. Si le problème persiste, vous pouvez contacter l'assistance de CANAL+/CANALSAT.","code":404}`
|
||||
})
|
||||
.then(result => {
|
||||
expect(result).toMatchObject([])
|
||||
done()
|
||||
})
|
||||
.catch(done)
|
||||
})
|
||||
|
|
|
@ -12,18 +12,21 @@ module.exports = {
|
|||
|
||||
return `https://service.canal-overseas.com/ott-frontend/vector/53101/channel/${channel.site_id}/events?filter.day=${diff}`
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
async parser({ content }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
for (let item of items) {
|
||||
if (item.title === 'Fin des programmes') return
|
||||
const detail = await loadProgramDetails(item)
|
||||
programs.push({
|
||||
title: item.title,
|
||||
icon: item.URLImageDefault,
|
||||
start: parseStart(item).toJSON(),
|
||||
stop: parseStop(item).toJSON()
|
||||
title: item.title,
|
||||
description:parseDescription(detail),
|
||||
category: parseCategory(detail),
|
||||
icon: parseIcon(item),
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return programs
|
||||
},
|
||||
|
@ -49,6 +52,28 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
async function loadProgramDetails(item) {
|
||||
if (!item.onClick.URLPage) return {}
|
||||
const url = item.onClick.URLPage
|
||||
const data = await axios
|
||||
.get(url)
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
return data || {}
|
||||
}
|
||||
|
||||
function parseDescription(detail){
|
||||
return detail.detail.informations.summary || null
|
||||
}
|
||||
|
||||
function parseCategory(detail){
|
||||
return detail.detail.informations.subGenre || null
|
||||
}
|
||||
function parseIcon(item){
|
||||
return item.URLImage || item.URLImageDefault
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.unix(item.startTime)
|
||||
}
|
||||
|
|
|
@ -2,48 +2,173 @@
|
|||
// npx epg-grabber --config=sites/canalplus-haiti.com/canalplus-haiti.com.config.js --channels=sites/canalplus-haiti.com/canalplus-haiti.com_ht.channels.xml --output=.gh-pages/guides/ht/canalplus-haiti.com.epg.xml --days=2
|
||||
|
||||
const { parser, url } = require('./canalplus-haiti.com.config.js')
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
jest.mock('axios')
|
||||
|
||||
const channel = {
|
||||
site_id: '60020',
|
||||
xmltv_id: 'CanalPlusReunion.fr'
|
||||
site_id: '51006',
|
||||
xmltv_id: 'ViaATV.mq'
|
||||
}
|
||||
|
||||
it('can generate valid url for today', () => {
|
||||
const date = dayjs.utc().startOf('d')
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/53101/channel/60020/events?filter.day=0'
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/53101/channel/51006/events?filter.day=0'
|
||||
)
|
||||
})
|
||||
|
||||
it('can generate valid url for tomorrow', () => {
|
||||
const date = dayjs.utc().startOf('d').add(1, 'd')
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/53101/channel/60020/events?filter.day=1'
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/53101/channel/51006/events?filter.day=1'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = `{"timeSlices":[{"contents":[{"title":"Fin des programmes","thirdTitle":"MA TV","startTime":1636768800,"endTime":1636855200,"onClick":{"displayTemplate":"miniDetail","displayName":"Fin des programmes","URLPage":"https://service.canal-overseas.com/ott-frontend/vector/63001/event/110427432","URLVitrine":"https://service.canal-overseas.com/ott-frontend/vector/63001/program/0/recommendations"},"programID":0,"diffusionID":"110427432","URLImageDefault":"https://service.canal-overseas.com/image-api/v1/image/generic","URLImage":"https://service.canal-overseas.com/image-api/v1/image/generic"}],"timeSlice":"0"},{"contents":[{"title":"Le cercle","subtitle":"5 Novembre 2021","thirdTitle":"CANAL+ HD","startTime":1636793201,"endTime":1636795901,"onClick":{"displayTemplate":"miniDetail","displayName":"Le cercle","URLPage":"https://service.canal-overseas.com/ott-frontend/vector/63001/event/110427540","URLVitrine":"https://service.canal-overseas.com/ott-frontend/vector/63001/program/193072081/recommendations"},"programID":193072081,"diffusionID":"110427540","URLImageDefault":"https://service.canal-overseas.com/image-api/v1/image/2a311987c642d97485d5f531e698dfb7","URLImage":"https://service.canal-overseas.com/image-api/v1/image/2de336e6a8c962921638c8aeee5f7e52"}],"timeSlice":"1"},{"contents":[],"timeSlice":"2"},{"contents":[],"timeSlice":"3"},{"contents":[],"timeSlice":"4"}]}`
|
||||
const result = parser({ content })
|
||||
it('can parse response', done => {
|
||||
const content = `{
|
||||
"timeSlices": [
|
||||
{
|
||||
"contents": [
|
||||
{
|
||||
"title": "New Amsterdam - S3 - Ep7",
|
||||
"subtitle": "Episode 7 - Le mur de la honte",
|
||||
"thirdTitle": "viaATV",
|
||||
"startTime": 1660780500,
|
||||
"endTime": 1660783200,
|
||||
"onClick": {
|
||||
"displayTemplate": "miniDetail",
|
||||
"displayName": "New Amsterdam - S3 - Ep7",
|
||||
"URLPage": "https://service.canal-overseas.com/ott-frontend/vector/53101/event/140952809",
|
||||
"URLVitrine": "https://service.canal-overseas.com/ott-frontend/vector/53101/program/187882282/recommendations"
|
||||
},
|
||||
"programID": 187882282,
|
||||
"diffusionID": "140952809",
|
||||
"URLImageDefault": "https://service.canal-overseas.com/image-api/v1/image/generic",
|
||||
"URLImage": "https://service.canal-overseas.com/image-api/v1/image/52a18a209e28380b199201961c27097e"
|
||||
}
|
||||
],
|
||||
"timeSlice": "2"
|
||||
}
|
||||
]
|
||||
}`
|
||||
axios.get.mockImplementation(url => {
|
||||
if (url === 'https://service.canal-overseas.com/ott-frontend/vector/53101/event/140952809') {
|
||||
return Promise.resolve({
|
||||
data: JSON.parse(`{
|
||||
"currentPage": {
|
||||
"displayName": "New Amsterdam - S3 - Ep7",
|
||||
"displayTemplate": "detailPage",
|
||||
"URLVitrine": "https://service.canal-overseas.com/ott-frontend/vector/53101/program/187882282/recommendations"
|
||||
},
|
||||
"detail": {
|
||||
"informations": {
|
||||
"programmeType": "EPG",
|
||||
"isInOffer": false,
|
||||
"isInOfferOnDevice": false,
|
||||
"isInOfferForD2G": false,
|
||||
"availableInVoDOnDevice": false,
|
||||
"availableInVoDOnG5": false,
|
||||
"availableInD2GOnDevice": false,
|
||||
"availableInLiveOnDevice": false,
|
||||
"rediffusions": true,
|
||||
"canBeRecorded": false,
|
||||
"channelName": "viaATV",
|
||||
"startTime": 1660780500,
|
||||
"endTime": 1660783200,
|
||||
"title": "New Amsterdam - S3 - Ep7",
|
||||
"subtitle": "Episode 7 - Le mur de la honte",
|
||||
"thirdTitle": "viaATV",
|
||||
"genre": "Séries",
|
||||
"subGenre": "Série Hôpital",
|
||||
"editorialTitle": "Séries, Etats-Unis, 2020, 0h45",
|
||||
"audioLanguage": "VF",
|
||||
"personnalities": [
|
||||
{
|
||||
"prefix": "De :",
|
||||
"content": "Darnell Martin"
|
||||
},
|
||||
{
|
||||
"prefix": "Avec :",
|
||||
"content": "André De Shields, Anna Suzuki, Anupam Kher, Baylen Thomas, Christine Chang, Craig Wedren, Daniel Dae Kim, Dierdre Friel, Em Grosland, Emma Ramos, Freema Agyeman, Gina Gershon, Graham Norris, Jamie Ann Romero, Janet Montgomery, Jefferson Friedman, Joshua Gitta, Kerry Flanagan, Larry Bryggman, Mike Doyle, Nora Clow, Opal Clow, Ryan Eggold, Simone Policano, Stephen Spinella, Tyler Labine"
|
||||
}
|
||||
],
|
||||
"summary": "C'est la journée nationale de dépistage du VIH et Max offre des soins gratuits à tous les malades séropositifs qui se présentent à New Amsterdam.",
|
||||
"summaryMedium": "C'est la journée nationale de dépistage du VIH et Max offre des soins gratuits à tous les malades séropositifs qui se présentent à New Amsterdam.",
|
||||
"programID": 187882282,
|
||||
"sharingURL": "https://www.canalplus-haiti.com/grille-tv/event/140952809-new-amsterdam-s3-ep7.html",
|
||||
"labels": {
|
||||
"allocine": false,
|
||||
"telerama": false,
|
||||
"sensCritique": false
|
||||
},
|
||||
"EpgId": 51006,
|
||||
"CSA": 1,
|
||||
"HD": false,
|
||||
"3D": false,
|
||||
"diffusionID": "140952809",
|
||||
"duration": "2700",
|
||||
"URLImageDefault": "https://service.canal-overseas.com/image-api/v1/image/generic",
|
||||
"URLImage": "https://service.canal-overseas.com/image-api/v1/image/52a18a209e28380b199201961c27097e",
|
||||
"URLLogo": "https://service.canal-overseas.com/image-api/v1/image/0f67b2e85f74101c4c776cf423240fce",
|
||||
"URLLogoBlack": "https://service.canal-overseas.com/image-api/v1/image/0f67b2e85f74101c4c776cf423240fce",
|
||||
"URLVitrine": "https://service.canal-overseas.com/ott-frontend/vector/53101/program/187882282/recommendations"
|
||||
},
|
||||
"diffusions": [
|
||||
{
|
||||
"diffusionDateUTC": 1660780500,
|
||||
"sharingUrl": "https://www.canalplus-haiti.com/grille-tv/event/140952809-new-amsterdam.html",
|
||||
"broadcastId": "140952809",
|
||||
"name": "viaATV",
|
||||
"epgID": "51006",
|
||||
"ZapNumber": "28",
|
||||
"URLLogo": "https://service.canal-overseas.com/image-api/v1/image/0f67b2e85f74101c4c776cf423240fce",
|
||||
"URLLogoBlack": "https://service.canal-overseas.com/image-api/v1/image/0f67b2e85f74101c4c776cf423240fce"
|
||||
}
|
||||
]
|
||||
}
|
||||
}`)
|
||||
})
|
||||
} else {
|
||||
return Promise.resolve({ data: '' })
|
||||
}
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-13T08:46:41.000Z',
|
||||
stop: '2021-11-13T09:31:41.000Z',
|
||||
title: 'Le cercle',
|
||||
icon: 'https://service.canal-overseas.com/image-api/v1/image/2a311987c642d97485d5f531e698dfb7'
|
||||
}
|
||||
])
|
||||
parser({ content })
|
||||
.then(result => {
|
||||
result = result.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-08-17T23:55:00.000Z',
|
||||
stop: '2022-08-18T00:40:00.000Z',
|
||||
title: 'New Amsterdam - S3 - Ep7',
|
||||
icon: 'https://service.canal-overseas.com/image-api/v1/image/52a18a209e28380b199201961c27097e',
|
||||
category: 'Série Hôpital',
|
||||
description: 'C\'est la journée nationale de dépistage du VIH et Max offre des soins gratuits à tous les malades séropositifs qui se présentent à New Amsterdam.'
|
||||
}
|
||||
])
|
||||
done()
|
||||
})
|
||||
.catch(done)
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: `{"currentPage":{"displayTemplate":"error","BOName":"Page introuvable"},"title":"Page introuvable","text":"La page que vous demandez est introuvable. Si le problème persiste, vous pouvez contacter l'assistance de CANAL+/CANALSAT.","code":404}`
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
it('can handle empty guide', done => {
|
||||
parser({
|
||||
content: `{"currentPage":{"displayTemplate":"error","BOName":"Page introuvable"},"title":"Page introuvable","text":"La page que vous demandez est introuvable. Si le problème persiste, vous pouvez contacter l'assistance de CANAL+/CANALSAT.","code":404}`
|
||||
})
|
||||
.then(result => {
|
||||
expect(result).toMatchObject([])
|
||||
done()
|
||||
})
|
||||
.catch(done)
|
||||
})
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
|
@ -10,23 +11,46 @@ module.exports = {
|
|||
|
||||
return `https://service.canal-overseas.com/ott-frontend/vector/63001/channel/${channel.site_id}/events?filter.day=${diff}`
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
async parser({ content }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
for (let item of items) {
|
||||
if (item.title === 'Fin des programmes') return
|
||||
const detail = await loadProgramDetails(item)
|
||||
programs.push({
|
||||
title: item.title,
|
||||
icon: item.URLImageDefault,
|
||||
start: parseStart(item).toJSON(),
|
||||
stop: parseStop(item).toJSON()
|
||||
title: item.title,
|
||||
description:parseDescription(detail),
|
||||
category: parseCategory(detail),
|
||||
icon: parseIcon(item),
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
async function loadProgramDetails(item) {
|
||||
if (!item.onClick.URLPage) return {}
|
||||
const url = item.onClick.URLPage
|
||||
const data = await axios
|
||||
.get(url)
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
return data || {}
|
||||
}
|
||||
|
||||
function parseDescription(detail){
|
||||
return detail.detail.informations.summary || null
|
||||
}
|
||||
|
||||
function parseCategory(detail){
|
||||
return detail.detail.informations.subGenre || null
|
||||
}
|
||||
function parseIcon(item){
|
||||
return item.URLImage || item.URLImageDefault
|
||||
}
|
||||
function parseStart(item) {
|
||||
return dayjs.unix(item.startTime)
|
||||
}
|
||||
|
|
|
@ -1,48 +1,158 @@
|
|||
// npx epg-grabber --config=sites/canalplus-reunion.com/canalplus-reunion.com.config.js --channels=sites/canalplus-reunion.com/canalplus-reunion.com_km.channels.xml --output=.gh-pages/guides/km/canalplus-reunion.com.epg.xml --days=2
|
||||
|
||||
const { parser, url } = require('./canalplus-reunion.com.config.js')
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
jest.mock('axios')
|
||||
|
||||
const channel = {
|
||||
site_id: '60020',
|
||||
xmltv_id: 'CanalPlusReunion.fr'
|
||||
site_id: '60243',
|
||||
xmltv_id: 'beINSports2France.fr'
|
||||
}
|
||||
|
||||
it('can generate valid url for today', () => {
|
||||
const date = dayjs.utc().startOf('d')
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/63001/channel/60020/events?filter.day=0'
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/63001/channel/60243/events?filter.day=0'
|
||||
)
|
||||
})
|
||||
|
||||
it('can generate valid url for tomorrow', () => {
|
||||
const date = dayjs.utc().startOf('d').add(1, 'd')
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/63001/channel/60020/events?filter.day=1'
|
||||
'https://service.canal-overseas.com/ott-frontend/vector/63001/channel/60243/events?filter.day=1'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = `{"timeSlices":[{"contents":[{"title":"Fin des programmes","thirdTitle":"MA TV","startTime":1636768800,"endTime":1636855200,"onClick":{"displayTemplate":"miniDetail","displayName":"Fin des programmes","URLPage":"https://service.canal-overseas.com/ott-frontend/vector/63001/event/110427432","URLVitrine":"https://service.canal-overseas.com/ott-frontend/vector/63001/program/0/recommendations"},"programID":0,"diffusionID":"110427432","URLImageDefault":"https://service.canal-overseas.com/image-api/v1/image/generic","URLImage":"https://service.canal-overseas.com/image-api/v1/image/generic"}],"timeSlice":"0"},{"contents":[{"title":"Le cercle","subtitle":"5 Novembre 2021","thirdTitle":"CANAL+ HD","startTime":1636793201,"endTime":1636795901,"onClick":{"displayTemplate":"miniDetail","displayName":"Le cercle","URLPage":"https://service.canal-overseas.com/ott-frontend/vector/63001/event/110427540","URLVitrine":"https://service.canal-overseas.com/ott-frontend/vector/63001/program/193072081/recommendations"},"programID":193072081,"diffusionID":"110427540","URLImageDefault":"https://service.canal-overseas.com/image-api/v1/image/2a311987c642d97485d5f531e698dfb7","URLImage":"https://service.canal-overseas.com/image-api/v1/image/2de336e6a8c962921638c8aeee5f7e52"}],"timeSlice":"1"},{"contents":[],"timeSlice":"2"},{"contents":[],"timeSlice":"3"},{"contents":[],"timeSlice":"4"}]}`
|
||||
const result = parser({ content })
|
||||
it('can parse response', done => {
|
||||
const content = `{
|
||||
"timeSlices": [
|
||||
{
|
||||
"contents": [
|
||||
{
|
||||
"title": "Almeria / Real Madrid",
|
||||
"subtitle": "Football",
|
||||
"thirdTitle": "BEIN SPORTS 2 HD",
|
||||
"startTime": 1660780800,
|
||||
"endTime": 1660788000,
|
||||
"onClick": {
|
||||
"displayTemplate": "miniDetail",
|
||||
"displayName": "Almeria / Real Madrid",
|
||||
"URLPage": "https://service.canal-overseas.com/ott-frontend/vector/63001/event/140382363",
|
||||
"URLVitrine": "https://service.canal-overseas.com/ott-frontend/vector/63001/program/224523053/recommendations"
|
||||
},
|
||||
"programID": 224523053,
|
||||
"diffusionID": "140382363",
|
||||
"URLImageDefault": "https://service.canal-overseas.com/image-api/v1/image/a6b640e16608ffa3d862e2bd8a4b3e4c",
|
||||
"URLImage": "https://service.canal-overseas.com/image-api/v1/image/47000149dabce60d1769589c766aad20"
|
||||
}
|
||||
],
|
||||
"timeSlice": "4"
|
||||
}
|
||||
]
|
||||
}`
|
||||
axios.get.mockImplementation(url => {
|
||||
if (url === 'https://service.canal-overseas.com/ott-frontend/vector/63001/event/140382363') {
|
||||
return Promise.resolve({
|
||||
data: JSON.parse(`{
|
||||
"currentPage": {
|
||||
"displayName": "Almeria / Real Madrid",
|
||||
"displayTemplate": "detailPage",
|
||||
"URLVitrine": "https://service.canal-overseas.com/ott-frontend/vector/63001/program/224523053/recommendations"
|
||||
},
|
||||
"detail": {
|
||||
"informations": {
|
||||
"programmeType": "EPG",
|
||||
"isInOffer": false,
|
||||
"isInOfferOnDevice": false,
|
||||
"isInOfferForD2G": false,
|
||||
"availableInVoDOnDevice": false,
|
||||
"availableInVoDOnG5": false,
|
||||
"availableInD2GOnDevice": false,
|
||||
"availableInLiveOnDevice": false,
|
||||
"rediffusions": true,
|
||||
"canBeRecorded": false,
|
||||
"channelName": "BEIN SPORTS 2 HD",
|
||||
"startTime": 1660780800,
|
||||
"endTime": 1660788000,
|
||||
"title": "Almeria / Real Madrid",
|
||||
"subtitle": "Football",
|
||||
"thirdTitle": "BEIN SPORTS 2 HD",
|
||||
"genre": "Sport",
|
||||
"subGenre": "Football",
|
||||
"editorialTitle": "Sport, Espagne, 2h00",
|
||||
"audioLanguage": "VF",
|
||||
"summary": "Diffusion d'un match de LaLiga Santander, championnat d'Espagne de football, la plus haute compétition de football d'Espagne. Cette compétition professionnelle, placée sous la supervision de la Fédération espagnole de football, a été fondée en 1928 et s'appelle Primera Division jusqu'en 2008. Elle se nomme ensuite Liga BBVA jusqu'en 2016 puis LaLiga Santander depuis cette date.",
|
||||
"summaryMedium": "Diffusion d'un match de LaLiga Santander, championnat d'Espagne de football, la plus haute compétition de football d'Espagne. Cette compétition professionnelle, placée sous la supervision de la Fédération espagnole de football, a été fondée en 1928 et s'appelle Primera Division jusqu'en 2008. Elle se nomme ensuite Liga BBVA jusqu'en 2016 puis LaLiga Santander depuis cette date.",
|
||||
"programID": 224523053,
|
||||
"sharingURL": "https://www.canalplus-reunion.com/grille-tv/event/140382363-almeria-real-madrid.html",
|
||||
"EpgId": 60243,
|
||||
"CSA": 1,
|
||||
"HD": false,
|
||||
"3D": false,
|
||||
"diffusionID": "140382363",
|
||||
"duration": "7200",
|
||||
"URLImageDefault": "https://service.canal-overseas.com/image-api/v1/image/a6b640e16608ffa3d862e2bd8a4b3e4c",
|
||||
"URLImage": "https://service.canal-overseas.com/image-api/v1/image/47000149dabce60d1769589c766aad20",
|
||||
"URLLogo": "https://service.canal-overseas.com/image-api/v1/image/6e2124827406ed41236a8430352d4ed9",
|
||||
"URLLogoBlack": "https://service.canal-overseas.com/image-api/v1/image/6e2124827406ed41236a8430352d4ed9",
|
||||
"URLVitrine": "https://service.canal-overseas.com/ott-frontend/vector/63001/program/224523053/recommendations"
|
||||
},
|
||||
"diffusions": [
|
||||
{
|
||||
"diffusionDateUTC": 1660780800,
|
||||
"sharingUrl": "https://www.canalplus-reunion.com/grille-tv/event/140382363-almeria-real-madrid.html",
|
||||
"broadcastId": "140382363",
|
||||
"name": "BEIN SPORTS 2 HD",
|
||||
"epgID": "60243",
|
||||
"ZapNumber": "96",
|
||||
"URLLogo": "https://service.canal-overseas.com/image-api/v1/image/6e2124827406ed41236a8430352d4ed9",
|
||||
"URLLogoBlack": "https://service.canal-overseas.com/image-api/v1/image/6e2124827406ed41236a8430352d4ed9"
|
||||
}
|
||||
]
|
||||
}
|
||||
}`)
|
||||
})
|
||||
} else {
|
||||
return Promise.resolve({ data: '' })
|
||||
}
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-13T08:46:41.000Z',
|
||||
stop: '2021-11-13T09:31:41.000Z',
|
||||
title: 'Le cercle',
|
||||
icon: 'https://service.canal-overseas.com/image-api/v1/image/2a311987c642d97485d5f531e698dfb7'
|
||||
}
|
||||
])
|
||||
parser({ content })
|
||||
.then(result => {
|
||||
result = result.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-08-18T00:00:00.000Z',
|
||||
stop: '2022-08-18T02:00:00.000Z',
|
||||
title: 'Almeria / Real Madrid',
|
||||
icon: 'https://service.canal-overseas.com/image-api/v1/image/47000149dabce60d1769589c766aad20',
|
||||
category: 'Football',
|
||||
description: 'Diffusion d\'un match de LaLiga Santander, championnat d\'Espagne de football, la plus haute compétition de football d\'Espagne. Cette compétition professionnelle, placée sous la supervision de la Fédération espagnole de football, a été fondée en 1928 et s\'appelle Primera Division jusqu\'en 2008. Elle se nomme ensuite Liga BBVA jusqu\'en 2016 puis LaLiga Santander depuis cette date.'
|
||||
}
|
||||
])
|
||||
done()
|
||||
})
|
||||
.catch(done)
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: `{"currentPage":{"displayTemplate":"error","BOName":"Page introuvable"},"title":"Page introuvable","text":"La page que vous demandez est introuvable. Si le problème persiste, vous pouvez contacter l'assistance de CANAL+/CANALSAT.","code":404}`
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
it('can handle empty guide', done => {
|
||||
parser({
|
||||
content: `{"currentPage":{"displayTemplate":"error","BOName":"Page introuvable"},"title":"Page introuvable","text":"La page que vous demandez est introuvable. Si le problème persiste, vous pouvez contacter l'assistance de CANAL+/CANALSAT.","code":404}`
|
||||
})
|
||||
.then(result => {
|
||||
expect(result).toMatchObject([])
|
||||
done()
|
||||
})
|
||||
.catch(done)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue