diff --git a/sites/movistarplus.es/movistarplus.es.config.js b/sites/movistarplus.es/movistarplus.es.config.js new file mode 100644 index 00000000..ccb6d32d --- /dev/null +++ b/sites/movistarplus.es/movistarplus.es.config.js @@ -0,0 +1,38 @@ +const dayjs = require('dayjs') +var customParseFormat = require('dayjs/plugin/customParseFormat') +dayjs.extend(customParseFormat) + +module.exports = { + site: 'movistarplus.es', + url: function ({ date }) { + return `https://www.movistarplus.es/programacion-tv/${date.format('YYYY-MM-DD')}?v=json` + }, + parser({ content, channel, date }) { + let programs = [] + let items = parseItems(content, channel) + if (!items.length) return programs + let guideDate = date + items.forEach(item => { + let startTime = dayjs(`${guideDate.format('YYYY-MM-DD')} ${item.HORA_INICIO}`,"YYYY-MM-DD HH:mm") + let stopTime = dayjs(`${guideDate.format('YYYY-MM-DD')} ${item.HORA_FIN}`,"YYYY-MM-DD HH:mm") + if (stopTime.isBefore(startTime)) { + guideDate = guideDate.add(1, 'd') + stopTime = stopTime.add(1, 'd') + } + programs.push({ + title: item.TITULO, + category: item.GENERO, + start: startTime.toJSON(), + stop: stopTime.toJSON() + }) + }) + return programs + } + } + + function parseItems(content, channel) { + const json = typeof content === 'string' ? JSON.parse(content) : content + if (!(`${channel.site_id}-CODE` in json.data)) return [] + const data = json.data[`${channel.site_id}-CODE`] + return data ? data.PROGRAMAS : [] + } \ No newline at end of file diff --git a/sites/movistarplus.es/movistarplus.es.test.js b/sites/movistarplus.es/movistarplus.es.test.js new file mode 100644 index 00000000..892de8b0 --- /dev/null +++ b/sites/movistarplus.es/movistarplus.es.test.js @@ -0,0 +1,52 @@ +const { parser, url, request } = require('./movistarplus.es.config.js') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const customParseFormat = require('dayjs/plugin/customParseFormat') +dayjs.extend(customParseFormat) +dayjs.extend(utc) + +const date = dayjs.utc('2022-03-11', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: 'TVE', + xmltv_id: 'SomeChannel.es' +} + +it('can generate valid url', () => { + expect(url({ date })).toBe( + 'https://www.movistarplus.es/programacion-tv/2022-03-11?v=json' + ) + }) + + it('can parse response', () => { + const content = `{"success":"true","msg":"","data":{"TVE-CODE":{"DATOS_CADENA":{"CODIGO":"TVE","MARCA":"TVE","NOMBRE":"LA 1","URL":"https://www.movistarplus.es/canal?nombre=LA%2B1&id=TVE","DIAL_PRINCIPAL":["01"],"DIALES":[1],"UID":null,"CASID":null,"SERVICEUID":null,"SERVICEUID2":null,"SERVICEID":null,"ESVIRTUAL":null,"ESSATELITE":null,"UPSELLING":null,"puntoReproduccion":null},"PROGRAMAS":[{"DIRECTO":false,"TEMPORADA":"","TITULO":"Telediario Matinal","GENERO":"Información","CODIGO_GENERO":"IF","DURACION":150,"DURACION_VISUAL":150,"HORA_INICIO":"06:00","HORA_FIN":"08:30","ELEMENTO":"1709045","EVENTO":"99422566","ShowId":null,"x1":0,"x2":0,"Disponible":null,"URL":"https://www.movistarplus.es/ficha/telediario-matinal?tipo=R&id=99422566"},{"DIRECTO":false,"TEMPORADA":"","TITULO":"Las Claves del Siglo XXI: Episodio 8","GENERO":"Información","CODIGO_GENERO":"IF","DURACION":135,"DURACION_VISUAL":135,"HORA_INICIO":"22:15","HORA_FIN":"00:30","ELEMENTO":"2051356","EVENTO":"99422634","ShowId":null,"x1":0,"x2":0,"Disponible":null,"URL":"https://www.movistarplus.es/ficha/las-claves-del-siglo-xxi-t1/episodio-8?tipo=R&id=99422634"},{"DIRECTO":false,"TEMPORADA":"","TITULO":"Noticias 24H","GENERO":"Información","CODIGO_GENERO":"IF","DURACION":170,"DURACION_VISUAL":170,"HORA_INICIO":"03:10","HORA_FIN":"06:00","ELEMENTO":"518403","EVENTO":"99422646","ShowId":null,"x1":0,"x2":0,"Disponible":null,"URL":"https://www.movistarplus.es/ficha/noticias-24h?tipo=R&id=99422646"}]}}}` + const result = parser({ content, channel, date }) + expect(result).toMatchObject([ + { + start: '2022-03-11T06:00:00.000Z', + stop: '2022-03-11T08:30:00.000Z', + category: 'Información', + title: `Telediario Matinal` + }, + { + start: '2022-03-11T22:15:00.000Z', + stop: '2022-03-12T00:30:00.000Z', + category: 'Información', + title: `Las Claves del Siglo XXI: Episodio 8` + }, + { + start: '2022-03-12T03:10:00.000Z', + stop: '2022-03-12T06:00:00.000Z', + category: 'Información', + title: `Noticias 24H` + } + ]) + }) + + it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: `{"success":"true","msg":"","data":{}}` + }) + expect(result).toMatchObject([]) + }) \ No newline at end of file diff --git a/sites/movistarplus.es/movistarplus.es_es_channels.xml b/sites/movistarplus.es/movistarplus.es_es_channels.xml new file mode 100644 index 00000000..5e4afc98 --- /dev/null +++ b/sites/movistarplus.es/movistarplus.es_es_channels.xml @@ -0,0 +1,191 @@ + + + + #0 + 3/24 + 7 Televisión Región de Murcia + 8 TV Cádiz + Aljazeera English + Alquiler 1 + Alquiler HD + AMC España + Antena 3 + À Punt + Aragón TV + Aragón TV + Aragón TV Internacional + Atreseries + AXN España + AXN White España + Baby TV Latin America + Barça TV + BBC World News Europe + Be Mad + betevé + Blaze España + Bloomberg TV Europe + Boing España + Bom Cine + Calle 13 + Canal 24 Horas + Canal 33 Madrid + Canal Cocina + Canal Extremadura + Canal Extremadura Satélite + Canal Fútbol Replay + Canal Hollywood España + Canal Panda España + Canal Sur + Canal Sur + Canal Sur Andalucía + Canal Sur Andalucía + Caza y Pesca + CGTN Español + Clan TVE + CNBC Europe + CNC World English + CNN International Europe + Comedy Central España + Cosmopolitan TV España + Crimen + Investigación + Cuatro + Cubavisión Internacional + Dark + DAZN 1 España + DAZN 2 España + DAZN 3 España + DAZN 4 España + DAZN F1 + Decasa + Discovery Channel Iberia + Disney Channel España + Disney Junior España + Divinity + DKiss + DMAX España + DreamWorks TV + EITB Basque + El Garage TV + El Toro TV + Energy + Esport3 + ETB 1 + ETB 2 + ETB 3 + EuroNews Español + Eurosport 1 + Eurosport 2 + EWTN España - Latinoamérica + Factoria de Ficción + Fox España + Fox News Channel + France 24 Español + Galicia TV Europa + Gol + Historia España + Horse TV + IB3 Global + Iberalia TV + La 1 + La 2 + La 7 + La Ocho TV + LaOtra + La Resistencia + Las Estrellas Europa + La Sexta + Mega + Mezzo + Mezzo Live HD + Movistar Acción + Movistar Cine Español + Movistar Clásicos + Movistar Comedia + Movistar Deportes + Movistar Deportes 1 + Movistar Deportes 2 + Movistar Deportes 3 + Movistar Deportes 4 + Movistar Deportes 5 + Movistar Deportes 6 + Movistar Deportes 7 + Movistar Drama + Movistar Estrenos + Movistar Estrenos 2 + Movistar Fest + Movistar Golf + Movistar LaLiga + Movistar LaLiga 1 + Movistar LaLiga 10 + Movistar LaLiga 2 + Movistar LaLiga 3 + Movistar LaLiga 4 + Movistar LaLiga 5 + Movistar LaLiga 6 + Movistar LaLiga 7 + Movistar LaLiga 8 + Movistar LaLiga 9 + Movistar LaLiga UHD + Movistar Liga de Campeones + Movistar Liga de Campeones 1 + Movistar Liga de Campeones 10 + Movistar Liga de Campeones 11 + Movistar Liga de Campeones 12 + Movistar Liga de Campeones 2 + Movistar Liga de Campeones 3 + Movistar Liga de Campeones 4 + Movistar Liga de Campeones 5 + Movistar Liga de Campeones 6 + Movistar Liga de Campeones 7 + Movistar Liga de Campeones 8 + Movistar Liga de Campeones 9 + Movistar Liga de Campeones UHD + Movistar Los Oscar + Movistar Series + Movistar Series 2 + MTV 00s + MTV España + National Geographic España + National Geographic Wild España + Nautical Channel + Negocios TV + Neox + NHK World Japan + Nickelodeon Iberia + Nick Jr España + Nova + Odisea + Paramount Channel España + Playboy TV Iberia + RCN Nuestra Tele Internacional + Real Madrid TV Español + Sky News International + Sol Música + Somos + Stingray Classica + Sundance TV España + Syfy España + TCM España + Telecinco + Teledeporte + Telefe Internacional + Telemadrid + Telesur + Ten + TNT España + Toros TV + TPA 7 + Trece TV + TV3 + TV3CAT + TV5Monde Europe + TV Canaria + TV Castilla-La Mancha + TV Chile + tvG2 + TVG Europa + U-Beat + #Vamos + Xtrm + + \ No newline at end of file