**------------------------------------------------------------------------------------------------
* @header_start
* WebGrab+Plus ini for grabbing EPG data from TvGuide websites
* @Site: movistar.com.pe
* @MinSWversion:
* @Revision 1 - [08/04/2015] Francis De Paemeleere
* - adjust to new url
* @Revision 0 - [09/12/2014] Francis De Paemeleere
* - creation
* @Remarks:
* @header_end
**------------------------------------------------------------------------------------------------
site {url=movistar.com.pe|timezone=America/Lima|maxdays=7|cultureinfo=es-PE|charset=UTF-8|titlematchfactor=90|nopageoverlaps|firstshow=1}
*http://tm.movistar.com.pe/tv/programacion/guia-de-programacion/guia-de-programacion-lr2?
urldate.format {datestring|_d__m___yyyy}
url_index{url|http://tm.movistar.com.pe/FrontEnd/Paginas/MovistarTV/Services.aspx/GetProgramacionGrilla}
url_index.headers {method=POST|contenttype=application/json; charset=utf-8}
url_index.headers {customheader=Accept-Encoding=gzip,deflate} * to speedup the downloading of the index pages
url_index.headers {customheader=X-Requested-With=XMLHttpRequest}
scope.range{(urlindex)|end}
index_temp_1.modify {clear}
index_temp_1.modify {addstart|'config_site_id'}
index_temp_1.modify {substring(type=regex)|LOCATIONID_(\d*)}
index_variable_element.modify {calculate(format=date,_d__M___yyyy)|'urldate'}
index_variable_element.modify {addend|"}
index_variable_element.modify {replace|___|", "anio":"}
index_variable_element.modify {replace|__|", "mes":"}
index_variable_element.modify {replace|_|"dia":"}
index_variable_element.modify {addstart|"localidadID": "'index_temp_1'" ,}
url_index.headers {postdata={'index_variable_element'}}
end_scope
scope.range{(datelogo)|end}
index_variable_element.modify {clear}
index_variable_element.modify {addstart|'config_site_id'}
index_variable_element.modify {substring(type=regex)|CHANNELID_(\d*)}
end_scope
index_showsplit.scrub {regex||\\"Programas\\"[^]]*],\\"CC\\"\:'index_variable_element'}||}
scope.range{(splitindex)|end}
index_showsplit.modify {replace|\\"|"}
index_showsplit.modify {substring(type=regex)|\{"DU"[^\}]*\}}
index_showsplit.modify {cleanup(removeduplicates=equal)} * remove any duplicate show
end_scope
index_temp_3.modify {clear}
index_temp_3.modify {addstart|'config_site_id'}
index_temp_3.modify {substring(type=regex)|LOCATIONID_(\d*)}
index_start.scrub {regex||"HI"\s*:\s*"([^"\\]*(?:\\.[^"\\]*)*)"||}
index_stop.scrub {regex||"HF"\s*:\s*"([^"\\]*(?:\\.[^"\\]*)*)"||}
index_temp_1.scrub {regex||"CP"\s*:\s*([+-]?\d*)||}
*index_urlshow {url|http://www.movistar.com.pe/FrontEnd/Paginas/MovistarTV/Services.aspx/ObtenerProgramacion}
index_title.scrub {regex||"TI"\s*:\s*"([^"\\]*(?:\\.[^"\\]*)*)"||}
*index_urlchannellogo.scrub {single(debug)||}
*
*index_urlchannellogo.modify {addstart|http://tm.movistar.com.pe/FrontEnd/Paginas/MovistarTV/Services.aspx/ObtenerCanal}
*index_urlchannellogo.headers {method=POST|contenttype=application/json; charset=utf-8}
*index_urlchannellogo.headers {customheader=Accept-Encoding=gzip,deflate} * to speedup the downloading of the index pages
*index_urlchannellogo.headers {customheader=X-Requested-With=XMLHttpRequest}
*id:25, localidad:1
*scope.range {(channellist)|end}
*index_temp_2.modify {addstart(debug)|id:'index_variable_element', localidad:'index_temp_3'}
*index_urlchannellogo.headers {postdata={'index_temp_2'}}
*end_scope
*index_urlchannellogo.scrub {single(debug)|"ImgGrd":"||",|}
*index_urlchannellogo.modify {addstart|http://tolcdn.movistar.com.pe/Content/CMS/EquipoTerra/MovistarTV/Canales/Imagenes/}
*
*
index_urlshow.modify {addstart|http://tm.movistar.com.pe/FrontEnd/Paginas/MovistarTV/Services.aspx/ObtenerProgramacion}
index_urlshow.headers {method=POST|contenttype=application/json; charset=utf-8}
index_urlshow.headers {customheader=Accept-Encoding=gzip,deflate} * to speedup the downloading of the index pages
index_urlshow.headers {customheader=X-Requested-With=XMLHttpRequest}
scope.range {(indexshowdetails)|end}
index_temp_4.modify {clear}
index_temp_4.modify {calculate(format=date,___yyyy__M_d)|'urldate'}
index_temp_4.modify {replace|___|, anio:}
index_temp_4.modify {replace|__|, mes:}
index_temp_4.modify {replace|_|, dia:}
index_temp_2.modify {clear}
index_temp_2.modify {addstart|codProg:'index_temp_1'}
index_temp_2.modify {addend|, canal:'index_variable_element'}
index_temp_2.modify {addend|, localidad:'index_temp_3'}
index_temp_2.modify {addend|'index_temp_4'}
index_temp_5.modify {substring(type=regex)|'index_start' "(^.*?(?=:))"}
index_temp_6.modify {substring(type=regex)|'index_start' "\:(.*)"}
index_temp_2.modify {addend|, hora:'index_temp_5', minuto:'index_temp_6'}
index_urlshow.headers {postdata={'index_temp_2'}}
end_scope
scope.range {(showdetails)|end}
title.scrub {single|"TituloEsp":"||",|}
subtitle.scrub {single (notnull)|"Capitulo":"||",|}
subtitle.scrub {single (notnull)|"Temporada":"||",|}
titleoriginal.scrub {single|"Tit. Original:||.|}
description.scrub {single|"SinopsisWeb":"||",|}
actor.scrub {multi|{"CodProg":|"DesPer":"|"|],}
director.scrub {single|Dir:||.|}
productiondate.scrub {single (notnull)|"Anio":||,|}
category.scrub {single|"DesCat":"||","DesGen"|}
category.scrub {single|"DesGen":"||"|}
duration.scrub {single|"Duracion":||,|}
duration.modify {calculate(notnull format=time)|60 /}
rating.scrub {single|"Rating":||,|}
showicon.scrub {single|"Imagen":"||",|}
showicon.modify {addstart(notnull)|http://tolcdn.movistar.com.pe/Content/CMS/EquipoTerra/MovistarTV/Programas/Imagenes/}
end_scope
** _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
** ##### CHANNEL FILE CREATION (only to create the xxx-channel.xml file)
**
** @auto_xml_channel_start
*
***
**
**
**
**
**
**
**
**
***
*
*subpage.format {list(step=1 count=8)|1}
*url_index{url|http://tm.movistar.com.pe/FrontEnd/Paginas/MovistarTV/Services.aspx/GetChannels###SUBPAGE|subpage}
*url_index.headers {method=POST|contenttype=application/json; charset=utf-8}
*url_index.headers {customheader=Accept-Encoding=gzip,deflate} * to speedup the downloading of the pages
*url_index.headers {customheader=X-Requested-With=XMLHttpRequest}
*
*scope.range{(urlindex)|end}
*url_index.headers {postdata={'localidadID':'subpage'}}
*url_index.modify {remove(type=regex)|###SUBPAGE.*$}
*end_scope
*
*index_site_id.scrub {regex||"d":"\[.*?\}\]"}||} * list of location channels
*scope.range {(channellist)|end}
*index_site_id.modify {replace|\\"|"}
*index_temp_5.modify {clear}
*index_temp_5.modify {addstart|1}
*index_temp_1.modify {clear}
*
*index_temp_6.modify {clear}
*loop {(each 'index_temp_6' in 'index_site_id' max=10)|end}
*index_temp_6.modify {replace(type=regex)|""CodCanal"(\:)\d*"|:LOCATIONID_'index_temp_5'__CHANNELID_}
*index_temp_5.modify {calculate(format=D0)|1 +}
*index_temp_1.modify {addend|'index_temp_6'###_###}
*end_loop
*
*index_temp_1.modify {replace|LOCATIONID_1|LOCATIONID_1__LOCATION_Lima}
*index_temp_1.modify {replace|LOCATIONID_2|LOCATIONID_2__LOCATION_Arequipa}
*index_temp_1.modify {replace|LOCATIONID_3|LOCATIONID_3__LOCATION_Chiclayo}
*index_temp_1.modify {replace|LOCATIONID_4|LOCATIONID_4__LOCATION_Piura}
*index_temp_1.modify {replace|LOCATIONID_5|LOCATIONID_5__LOCATION_Cusco}
*index_temp_1.modify {replace|LOCATIONID_6|LOCATIONID_6__LOCATION_Huancayo}
*index_temp_1.modify {replace|LOCATIONID_7|LOCATIONID_7__LOCATION_Chimbote}
*index_temp_1.modify {replace|LOCATIONID_8|LOCATIONID_8__LOCATION_Trujillo}
**index_temp_1.modify {replace|###_###|\|}
*index_temp_1.modify {addend|###_###1}
*index_site_channel.modify {substring(type=regex)|'index_temp_1' "LOCATIONID[^\,]*,"NomCanal":"([^\"]*)""}
*index_site_id.modify {substring(type=regex)|'index_temp_1' "(LOCATIONID[^\,]*),"NomCanal":"[^\"]*""}
*index_temp_1.modify {addend|###_##2}
*
*index_site_id.modify {cleanup(removeduplicates=equal,100 link="index_site_channel")}
*end_scope
** @auto_xml_channel_end