diff --git a/sites/canalplus-caraibes.com/canalplus-caraibes.com.channels.xml b/sites/canalplus-caraibes.com/canalplus-caraibes.com.channels.xml deleted file mode 100644 index 8aeaf739..00000000 --- a/sites/canalplus-caraibes.com/canalplus-caraibes.com.channels.xml +++ /dev/null @@ -1,130 +0,0 @@ - - - - 13ème Rue - 6ter - Action - Alizés - A+ - ARTE Français - Automoto la chaîne - BBC World News Americas - Bblack! Caribbean - BeIn Sports 1 France - BeIn Sports 2 France - BeIn Sports 3 France - BeIn Sports Max 4 France - BeIn Sports Max 5 France - C8 - Canal 10 - Canal J - Canal + Caraïbes - Canal + Cinéma France - Canal + Kids - Canal + Séries France - Canal + Sport France - Cine + Classic - Cine + Club - Cine + Émotion - Cine + Famiz - Cine + Frisson - Cine + Premier - C News - CNN International Latin America - Comédie + - C Star - Discovery Channel France - Discovery Science France - Disney Channel France - Disney Junior France - Dorcel TV - E! France - English Club TV - Equidia - ESPN 2 Caribbean - ESPN Caribbean - ETV - Eurosport 1 - Eurosport 2 - France 2 - France 24 Français - France 3 - France 4 - France 5 - Franceinfo: - Game One - Globo News - Golf + - Graphé TV - Guadeloupe 1ère - Gulli - Guyane 1ère - HBO Xtreme Latinoamérica - InfoSport + - IOTV - KMT - KTO - KTV Guyane - LCI - L'Équipe - Ludikids - M6 - Martinique 1ère - MCM France - Metropole - ES1 - MTV France - MTV Hits France - National Geographic France - National Geographic Wild France - Nickelodeon France - Nick Jr Africa - Nollywood TV - Novelas TV - NRJ 12 - OCS choc - OCS City - OCS geants - OCS max - Paramount Channel France - Paris Première - Penthouse Black - Pink TV - Piwi + - Planète + - Planète + A&E - Planète + CI - LCP Public Sénat - RTL 9 - Seasons - STVS 8.1 - Syfy France - Télé 20 - Telemicro Internacional - Telemundo - Tele Pacific - Tele Soleil - TéléToon + - Téva - TF 1 - TF 1 Séries Films - TFX - TMC - TNH - Toute l'Histoire - Trace Ayiti - Trace Caribbean - Trace Gospel - Trace Latina - Trace Urban - TV5Monde Amérique Latine - TV Breizh - Ushuaïa TV - ViàATV - Vixen - W9 - Wataaa TV - XXL - Zitata TV - Zouk TV - \ No newline at end of file diff --git a/sites/canalplus-caraibes.com/canalplus-caraibes.com.config.js b/sites/canalplus-caraibes.com/canalplus-caraibes.com.config.js deleted file mode 100644 index 47a5d7a9..00000000 --- a/sites/canalplus-caraibes.com/canalplus-caraibes.com.config.js +++ /dev/null @@ -1,93 +0,0 @@ -const axios = require('axios') -const cheerio = require('cheerio') -const dayjs = require('dayjs') -const utc = require('dayjs/plugin/utc') - -dayjs.extend(utc) - -module.exports = { - site: 'canalplus-caraibes.com', - days: 2, - url: function ({ channel, date }) { - const diff = date.diff(dayjs.utc().startOf('d'), 'd') - - return `https://service.canal-overseas.com/ott-frontend/vector/53001/channel/${channel.site_id}/events?filter.day=${diff}` - }, - async parser({ content }) { - let programs = [] - const items = parseItems(content) - for (let item of items) { - if (item.title === 'Fin des programmes') return - const detail = await loadProgramDetails(item) - programs.push({ - title: item.title, - description: parseDescription(detail), - category: parseCategory(detail), - icon: parseIcon(item), - start: parseStart(item), - stop: parseStop(item) - }) - } - - return programs - }, - async channels() { - const html = await axios - .get('https://www.canalplus-caraibes.com/bl/guide-tv-ce-soir') - .then(r => r.data) - .catch(console.log) - - const $ = cheerio.load(html) - const script = $('body > script:nth-child(2)').html() - const [, json] = script.match(/window.APP_STATE=(.*);/) || [null, null] - const data = JSON.parse(json) - const items = data.tvGuide.channels.byZapNumber - - return Object.values(items).map(item => { - return { - lang: 'fr', - site_id: item.epgID, - name: item.name - } - }) - } -} - -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) -} - -function parseStop(item) { - return dayjs.unix(item.endTime) -} - -function parseItems(content) { - const data = JSON.parse(content) - if (!data || !data.timeSlices) return [] - const items = data.timeSlices.reduce((acc, curr) => { - acc = acc.concat(curr.contents) - return acc - }, []) - - return items -} diff --git a/sites/canalplus-caraibes.com/canalplus-caraibes.com.test.js b/sites/canalplus-caraibes.com/canalplus-caraibes.com.test.js deleted file mode 100644 index 161d6a37..00000000 --- a/sites/canalplus-caraibes.com/canalplus-caraibes.com.test.js +++ /dev/null @@ -1,137 +0,0 @@ -// [Geo-blocked] npm run channels:parse -- --config=./sites/canalplus-caraibes.com/canalplus-caraibes.com.config.js --output=./sites/canalplus-caraibes.com/canalplus-caraibes.com.channels.xml -// npm run grab -- --site=canalplus-caraibes.com - -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: '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/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/50115/events?filter.day=1' - ) -}) - -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', 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) -})