diff --git a/sites/canalplus-afrique.com/canalplus-afrique.com.channels.xml b/sites/canalplus-afrique.com/canalplus-afrique.com.channels.xml deleted file mode 100644 index c6a552de..00000000 --- a/sites/canalplus-afrique.com/canalplus-afrique.com.channels.xml +++ /dev/null @@ -1,247 +0,0 @@ - - - - 2S TV - 3 TV - 7 Info - 10'ème Rue TV - 13ème Rue - AB 1 - Action - Africa 24 - Africable TV - Africanews - Alafia TV - Aljazeera Channel - Animaux - Antenne A - A+ - A+ Ivoire - A+ Kids TV - Arewa 24 - ARTE Français - Asfiyahi TV - Asonga TV - Authentic TV - Automoto la chaîne - Bantamba TV - BBC World News Africa - BF1 - Bloomberg TV Africa - B-One TV - Bonferey - BTN TV - Burkina Info TV - Business 24 Africa - C8 - Canal 2 International - Canal 2 Movies - Canal 3 - Canal 3 Benin - Canal + Action Centre - Canal + Action Ouest - Canal + Cinéma Centre - Canal + Cinéma Ouest - Canal + Elles Centre - Canal + Elles Ouest - Canal + Family Centre - Canal + Family Ouest - Canal + Pop Centre - Canal + Pop Ouest - Canal + Première Centre - Canal + Première Ouest - Canal + Sport 1 - Canal + Sport 2 - Canal + Sport 3 - Canal + Sport 4 - Canal + Sport 5 - Capital Santé TV - Cartoon Network France - CDirect - CGTN Français - Cherifla TV - CIS TV - Clique TV - CNBC Africa - C News - Crime District - CRTV - CRTV News - CRTV Sports and Entertainment - C Star - Cuisines - CVK - Digital Congo TV - Discovery Channel France - Discovery Science France - Disney Channel France - Disney Junior France - Djoma TV - Dorcel TV - Dorcel TV Africa - Dounia TV - DRTV International - E! Africa - Ecclesia TV - EDAN - Electron TV - Elmouritania - EMCI TV Afrique - Equinoxe TV - ES1 - Espace TV - E-Télé Benin - EuroNews Français - Eurosport 1 France - Eurosport 2 France - Evasión Guinée - Farin Wata - Fashion Africa TV - Flash TV - France 2 - France 3 - France 5 - France 24 Français - Gabon 1ère - Gabon 24 - Gabon Culture - Game One - Genesis TV - Golfe TV Africa - Gulli Africa - Histoire TV - I24 News Français - ImpacTV - InfoSport + - InfoTV - Iqraa Africa & Europe - Isango TV - ITV - Ivoire TV Music - Joliba TV News - J-One - Kalac TV - KC2 - KTO - Label TV - Lamp Fall TV - La Nouvelle Chaîne Ivorienne - LCA - LCI - Life TV - LM TV Français - Love Nature - LTM TV - Ludikids - Lux TV - M6 - Maboke TV - Madi TV - Mandé TV - Mangas - MCR TV NF - Medi 1 TV Arabic - Melody - Mikuba TV - Mishapi Voice TV - Moliere TV - MTV France - MTV Hits France - Museum International - My Media Prime - Nathan TV - National Geographic France - National Geographic Wild France - NBA TV - NHK World Japan - Nickelodeon France - Nickelodeon Junior France - Nollywood TV - Nollywood TV Épic - Novelas TV - Nyota TV - Omega TV - ORTB TV - ORTM 1 - ORTM 2 - Pacis TV - Paramount Channel France - Penthouse Black - Piwi + - Planète + - Planète + A&E - Planète + CI - PSTV HD - Rai Italia Africa - Reba TV 1 - Renouveau TV - RTB TV - RTDS Delta TV - RTG - RTI 1 - RTI 2 - RTI La 3 - RTL 9 - RTNB TV - RTNC - RTS 1 - RTS 2 - Rwanda TV - Sahara TV - Savane TV - Science & Vie TV - Sen TV - Série Club - SSM TV - STV - Sud1ère - Sunna TV - Sunu Yeuf - Syfy France - Télé 50 - Télé Africa - Tele Congo - Télé Sahel - Telesud - Télé Tchad - TéléToon Africa - TF 1 - TF 1 Séries Films - TFM - TFX - TGB - Tiji - Tivi 5 Monde - TLS Africa - TM1 TV - TMC - TNT Africa - Toute l'Histoire - Trace Africa Français - Trace Afrikora - Trace Gospel - Trace Kitoko - Trace MBOA - Trace Mziki - Trace Urban Afrique - Trek - TV5Monde Afrique - TV 7 - TV 10 - TV Al Bayane - TVC Benin - TVGE - TVT - Ushuaïa TV - Vision 4 - Vision 4 RCA - Vixen - Voir + - Voxafrica Afrique - Vox TV - Walf TV - Wataaa TV - XXL - Zee Magic - - \ No newline at end of file diff --git a/sites/canalplus-afrique.com/canalplus-afrique.com.config.js b/sites/canalplus-afrique.com/canalplus-afrique.com.config.js deleted file mode 100644 index afc50fff..00000000 --- a/sites/canalplus-afrique.com/canalplus-afrique.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-afrique.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/83001/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-afrique.com/bf/guide-tv-maintenant`) - .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-afrique.com/canalplus-afrique.com.test.js b/sites/canalplus-afrique.com/canalplus-afrique.com.test.js deleted file mode 100644 index 9288ffc1..00000000 --- a/sites/canalplus-afrique.com/canalplus-afrique.com.test.js +++ /dev/null @@ -1,151 +0,0 @@ -// [Geo-blocked] node ./scripts/commands/parse-channels.js --config=./sites/canalplus-afrique.com/canalplus-afrique.com.config.js --output=./sites/canalplus-afrique.com/canalplus-afrique.com.channels.xml -// npx epg-grabber --config=sites/canalplus-afrique.com/canalplus-afrique.com.config.js --channels=sites/canalplus-afrique.com/canalplus-afrique.com.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: '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/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/80759/events?filter.day=1' - ) -}) - -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: '' }) - } - }) - - 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', 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) -})