change custom fix for movistarplus.es
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Build docker container / build (push) Successful in 4m58s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Build docker container / build (push) Successful in 4m58s
				
			This commit is contained in:
		| @@ -115,4 +115,6 @@ Sometimes a new version of this image will be bound to the same source commit. T | |||||||
| - 1.0.12 | - 1.0.12 | ||||||
|   [10-14-2024](https://github.com/iptv-org/epg/commit/7610f7b9f5cc1ccab8d17f3408a95d31b36ace7c)<br>Fix Pickx.be url |   [10-14-2024](https://github.com/iptv-org/epg/commit/7610f7b9f5cc1ccab8d17f3408a95d31b36ace7c)<br>Fix Pickx.be url | ||||||
| - 1.0.13 | - 1.0.13 | ||||||
|   [10-14-2024](https://github.com/iptv-org/epg/commit/7610f7b9f5cc1ccab8d17f3408a95d31b36ace7c)<br>Add custom fix for web.magentatv.de |   [10-14-2024](https://github.com/iptv-org/epg/commit/7610f7b9f5cc1ccab8d17f3408a95d31b36ace7c)<br>Add custom fix for web.magentatv.de | ||||||
|  | - 1.0.14 | ||||||
|  |   [10-14-2024](https://github.com/iptv-org/epg/commit/7610f7b9f5cc1ccab8d17f3408a95d31b36ace7c)<br>Change fix for movistarplus.es in order t owork with new API | ||||||
| @@ -2,14 +2,30 @@ | |||||||
|  |  | ||||||
| const { DateTime } = require('luxon') | const { DateTime } = require('luxon') | ||||||
|  |  | ||||||
| const API_PROD_ENDPOINT = 'https://www.movistarplus.es/programacion-tv' | const API_CHANNEL_ENDPOINT = 'https://www.movistarplus.es/programacion-tv' | ||||||
|  | const API_PROGRAM_ENDPOINT = 'https://comunicacion.movistarplus.es' | ||||||
| const API_IMAGE_ENDPOINT = 'https://www.movistarplus.es/recorte/n/caratulaH/'; | const API_IMAGE_ENDPOINT = 'https://www.movistarplus.es/recorte/n/caratulaH/'; | ||||||
|  |  | ||||||
| module.exports = { | module.exports = { | ||||||
|   site: 'movistarplus.es', |   site: 'movistarplus.es', | ||||||
|   days: 2, |   days: 2, | ||||||
|   url: function ({ date }) { |   url: function ({ channel, date }) { | ||||||
|     return `${API_PROD_ENDPOINT}/${date.format('YYYY-MM-DD')}?v=json` |     return `${API_PROGRAM_ENDPOINT}/wp-admin/admin-ajax.php` | ||||||
|  |   }, | ||||||
|  |   request: { | ||||||
|  |     method: 'POST', | ||||||
|  |     headers: { | ||||||
|  |       Origin: API_PROGRAM_ENDPOINT, | ||||||
|  |       Referer: `${API_PROGRAM_ENDPOINT}/programacion/`, | ||||||
|  |       "Content-Type" : 'application/x-www-form-urlencoded; charset=UTF-8' | ||||||
|  |     }, | ||||||
|  |     data: function ({ channel, date }) { | ||||||
|  |       return { | ||||||
|  |         action: 'getProgramation', | ||||||
|  |         day: date.format('YYYY-MM-DD'), | ||||||
|  |         "channels[]": channel.site_id | ||||||
|  |       } | ||||||
|  |     } | ||||||
|   }, |   }, | ||||||
|   parser({ content, channel, date }) { |   parser({ content, channel, date }) { | ||||||
|     let programs = [] |     let programs = [] | ||||||
| @@ -19,15 +35,15 @@ module.exports = { | |||||||
|  |  | ||||||
|     items.forEach(item => { |     items.forEach(item => { | ||||||
|       let startTime = DateTime.fromFormat( |       let startTime = DateTime.fromFormat( | ||||||
|         `${guideDate.format('YYYY-MM-DD')} ${item.HORA_INICIO}`, |         `${item.f_evento_rejilla}`, | ||||||
|         'yyyy-MM-dd HH:mm', |         'yyyy-MM-dd HH:mm:ss', | ||||||
|         { |         { | ||||||
|           zone: 'Europe/Madrid' |           zone: 'Europe/Madrid' | ||||||
|         } |         } | ||||||
|       ).toUTC() |       ).toUTC() | ||||||
|       let stopTime = DateTime.fromFormat( |       let stopTime = DateTime.fromFormat( | ||||||
|         `${guideDate.format('YYYY-MM-DD')} ${item.HORA_FIN}`, |         `${item.f_fin_evento_rejilla}`, | ||||||
|         'yyyy-MM-dd HH:mm', |         'yyyy-MM-dd HH:mm:ss', | ||||||
|         { |         { | ||||||
|           zone: 'Europe/Madrid' |           zone: 'Europe/Madrid' | ||||||
|         } |         } | ||||||
| @@ -37,9 +53,9 @@ module.exports = { | |||||||
|         stopTime = stopTime.plus({ days: 1 }) |         stopTime = stopTime.plus({ days: 1 }) | ||||||
|       } |       } | ||||||
|       programs.push({ |       programs.push({ | ||||||
|         title: item.TITULO, |         title: item.des_evento_rejilla, | ||||||
|         icon: parseIcon(item, channel), |         icon: parseIcon(item, channel), | ||||||
|         category: item.GENERO, |         category: item.des_genero, | ||||||
|         start: startTime, |         start: startTime, | ||||||
|         stop: stopTime |         stop: stopTime | ||||||
|       }) |       }) | ||||||
| @@ -50,7 +66,7 @@ module.exports = { | |||||||
|     const axios = require('axios') |     const axios = require('axios') | ||||||
|     const dayjs = require('dayjs') |     const dayjs = require('dayjs') | ||||||
|     const data = await axios |     const data = await axios | ||||||
|       .get(`${API_PROD_ENDPOINT}/${dayjs().format('YYYY-MM-DD')}?v=json`) |       .get(`${API_CHANNEL_ENDPOINT}/${dayjs().format('YYYY-MM-DD')}?v=json`) | ||||||
|       .then(r => r.data) |       .then(r => r.data) | ||||||
|       .catch(console.log) |       .catch(console.log) | ||||||
|  |  | ||||||
| @@ -70,7 +86,9 @@ function parseIcon(item, channel) { | |||||||
|  |  | ||||||
| function parseItems(content, channel) { | function parseItems(content, channel) { | ||||||
|   const json = typeof content === 'string' ? JSON.parse(content) : content |   const json = typeof content === 'string' ? JSON.parse(content) : content | ||||||
|   if (!(`${channel.site_id}-CODE` in json.data)) return [] |   const data = json.channelsProgram; | ||||||
|   const data = json.data[`${channel.site_id}-CODE`] |  | ||||||
|   return data ? data.PROGRAMAS : [] |   if(data.length != 1) | ||||||
| } |     return [] | ||||||
|  |   return data[0]; | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user