diff --git a/sites/canalplus-haiti.com/canalplus-haiti.com.channels.xml b/sites/canalplus-haiti.com/canalplus-haiti.com.channels.xml deleted file mode 100644 index ea53e0f8..00000000 --- a/sites/canalplus-haiti.com/canalplus-haiti.com.channels.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - Sony Channel Centro - 13ème Rue - 6ter - Action - Alizés - A+ - Automoto la chaîne - BBC World News Americas - Bblack! Caribbean - C8 - Canal 10 - Canal + Cinéma France - Canal + Haïti - Canal + Kids - 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 - Cuisines - Discovery Channel France - Discovery Science France - Disney Channel France - Disney Junior France - Dorcel TV Africa - E! France - English Club TV - ESPN 2 Caribbean - ESPN Caribbean - ETV - Eurosport 1 - Eurosport 2 - France 2 - France 24 Français - France 3 - France 5 - Franceinfo: - Game One - Globo News - Graphé TV - Guadeloupe 1ère - Guyane 1ère - Haiti Sports TV 1 - Haiti Sports TV 2 - 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 - Nathan TV - National Geographic France - National Geographic Wild France - Nickelodeon France - Nick Jr Africa - Nollywood TV - Novelas TV - NRJ 12 - Paramount Channel France - Paris Première - Penthouse Black - Piwi + - Planète + - Planète + A&E - Planète + CI - LCP Public Sénat - RTL 9 - Seasons - Studiocanal - STVS 8.1 - Syfy France - Télé 20 - Telemicro Internacional - Telemundo - Tele Pacific - Tele Soleil - TéléToon + - TF 1 - TF 1 Séries Films - TFX - TNH - Toute l'Histoire - Trace Ayiti - Trace Caribbean - Trace Gospel - Trace Latina - Trace Urban - TV5Monde Amérique Latine - TV Caraïbes - Ushuaïa TV - ViàATV - Vixen - Wataaa TV - XXL - Zitata TV - Zouk TV - \ No newline at end of file diff --git a/sites/canalplus-haiti.com/canalplus-haiti.com.config.js b/sites/canalplus-haiti.com/canalplus-haiti.com.config.js deleted file mode 100644 index 77c7d7fe..00000000 --- a/sites/canalplus-haiti.com/canalplus-haiti.com.config.js +++ /dev/null @@ -1,94 +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-haiti.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/53101/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), - image: parseImage(item), - start: parseStart(item), - stop: parseStop(item) - }) - } - - return programs - }, - async channels() { - const html = await axios - .get('https://www.canalplus-haiti.com/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 parseImage(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-haiti.com/canalplus-haiti.com.test.js b/sites/canalplus-haiti.com/canalplus-haiti.com.test.js deleted file mode 100644 index 4590d1ff..00000000 --- a/sites/canalplus-haiti.com/canalplus-haiti.com.test.js +++ /dev/null @@ -1,174 +0,0 @@ -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: '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/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/51006/events?filter.day=1' - ) -}) - -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: '' }) - } - }) - - 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', - image: - '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', 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) -}) diff --git a/sites/canalplus-haiti.com/readme.md b/sites/canalplus-haiti.com/readme.md deleted file mode 100644 index 5ba0efbc..00000000 --- a/sites/canalplus-haiti.com/readme.md +++ /dev/null @@ -1,21 +0,0 @@ -# canalplus-haiti.com - -https://www.canalplus-haiti.com/guide-tv-maintenant - -### Download the guide - -```sh -npm run grab --- --site=canalplus-haiti.com -``` - -### Update channel list - -```sh -npm run channels:parse --- --config=./sites/canalplus-haiti.com/canalplus-haiti.com.config.js --output=./sites/canalplus-haiti.com/canalplus-haiti.com.channels.xml -``` - -### Test - -```sh -npm test --- canalplus-haiti.com -```