**------------------------------------------------------------------------------------------------
* @header_start
* WebGrab+Plus ini for grabbing EPG data from TvGuide websites
* @Site: ontvtonight.com
* @MinSWversion: V5.0
* @Revision 9 - [04/12/2024] Mat8861 * fix start
* @Revision 8 - [26/08/2024] Blackbear199
* - rewrite
* @Revision 7 - [20/04/2024] Blackbear199
* - usa and canada only
* @Revision 6 - [10/02/2024] Blackbear199
* - add premiere,previously shown
* @Revision 5 - [29/01/2023] Blackbear199
* - actor,showicon fix
* @Remarks: timezone= on site {xxx} set to timezone of pc running webgrab.
* Step 1: Create Provider File
* For USA,Canada use zip or postal code(no spaces)
* example
* USA ZipCode 10001
* dummy
* c1-Providers-10001
* Canada Postal Code M1R3C7
* dummy
* c1-Providers-M1R3C7
* Step 2: Create Channel List
* Use a channel line created from one of the providers above.
* c2-10001-DTV
* or
* c2-M1R3C7-Bell
* @header_end
**------------------------------------------------------------------------------------------------
site {url=ontvtonight.com|timezone=America/Moncton|maxdays=7|cultureinfo=en-US|charset=UTF-8|titlematchfactor=90}
site {episodesystem=onscreen}
*
url_index {url|https://www.ontvtonight.com/|channel|.html?dt=|urldate|}
url_index.headers {customheader=Accept-Encoding=gzip,deflate,br}
*
scope.range {(urlindex)|end}
url_index.modify {replace|##|/guide/listings/channel/}
end_scope
*
urldate.format {datestring|yyyy-MM-dd}
*
index_urlchannellogo {url||
|src="|"|
}
*
index_showsplit.scrub {multi|||
|}
scope.range {(splitindex)|end}
index_temp_1.modify {substring(type=regex)|'index_showsplit' "(\d{1,2}:\d{1,2}\s[ap]m)<"}
index_temp_1.modify {cleanup(removeduplicates span=2 link="index_showsplit")}
*index_showsplit.modify {(debug)}
end_scope
*
index_urlshow {url||\s*(\d{1,2}:\d{1,2}\s[ap]m)\s*
||}
index_title.scrub {multi(includeblock=2)|||
|}
index_category.scrub {regex||alt="(?:TV\s(Movie\|Sport))">||}
index_premiere.scrub {regex||alt="(New)">||}
*
index_title.modify {cleanup(tags="<"">")}
index_title.modify {remove(type=regex)|"\s{5,}\(\d{4}\).*$"}
index_premiere.modify {set(not "")|true}
index_previousshown.modify {set('index_premiere' "")|true}
*
title.scrub {single|||
|}
subtitle.scrub {single|||
|}
description.scrub {multi(includeblock=1)|}
category.scrub {multi||||
}
actor.scrub {multi|||
|}
episode.scrub {single(pattern="Season 'S1' Episode 'E1'""Episode 'E1'")|||
|}
starrating.scrub {regex||([1-9]\.\d+)||}
productiondate.scrub {multi||||
}
showicon.scrub {single|
}
*
title.modify {addstart("")|'index_title'}
loop {(each "temp_9" in 'actor')|end}
temp_8.modify {substring(type=regex)|'temp_9' "(.*?)<\/strong>"}
temp_7.modify {substring(type=regex)|'temp_9' "\.\.\s([^<]*)"}
temp_8.modify {addend(['temp_8' not ""] ['temp_7' not ""] &)|(role='temp_7')}
temp_6.modify {addend('temp_8' not "")|'temp_8'####}
end_loop
actor.modify {substring('temp_6' not "" type=regex)|'temp_6' "(.*?)####"}
description.modify {remove(type=regex)|"^(?:Premiere\|Repeat)$"}
episode.modify {cleanup}
episode.modify {remove|,}
starrating.modify {calculate(not "" format=F1)}
starrating.modify {addend(not "")|(system=User)}
** _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
** ##### PROVIDER FILE CREATION (only to create the xxx-channel.xml file)
**
** @auto_xml_channel_start
*url_index {url|https://www.ontvtonight.com#_#domain#_#/getprovidersfromzip}
*url_index.headers {method=POST}
*url_index.headers {postdata=zipcode='channel'}
*scope.range {(urlindex)|end}
*global_temp_9.modify {substring(type=regex)|'config_site_id' "^\d+$"}
*url_index.modify {replace('global_temp_9' not "")|#_#domain#_#|}
*global_temp_9.modify {substring(type=regex)|'config_site_id' "^\D\d\D\d\D\d$"}
*url_index.modify {replace('global_temp_9' not "")|#_#domain#_#|/ca}
*end_scope
*index_site_id.scrub {regex||"(-?\w+)":\{"id":\d+,"title":||}
*index_site_id.modify {addend|##'config_site_id'}
*index_site_channel.scrub {regex||\{"id":\d+,"title":"(.*?)",||}
*index_site_channel.modify {cleanup(style=jsondecode)}
*index_site_id.modify {cleanup(removeduplicates link="index_site_channel")}
** @auto_xml_channel_end
*index_site_id.scrub {regex||"(-?\w+)":\{"id":\d+,"title":||}
** _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
** ##### CHANNEL FILE CREATION (only to create the xxx-channel.xml file)
**
** @auto_xml_channel_start
*url_index {url|https://www.ontvtonight.com#_#domain#_#/guide/schedule?provider=#_#provider#_#_#zipcode#_#&TVperiod=Afternoon&date=|urldate|&st=|subpage|}
}
*url_index.headers {method=POST}
*url_index.headers {postdata=action=1&menu=0&hour=5&minute=46&userdate='global_temp_7'}
*url_index.headers {customheader=Accept-Encoding=gzip,deflate,br}
*subpage.format {list|0|96|192|288|384|480|576|672|768|864|960|1056|1152|1248|1344|1440|1536|1632|1728|1824|1920|2016}
*scope.range {(urlindex)|end}
*index_variable_element.modify{substring(type=regex)|'config_site_id' "^([^#]*)##"}
*url_index.modify {replace|#_#provider#_#|'index_variable_element'}
*index_temp_9.modify {substring(type=regex)|'config_site_id' "^(?:[^#]*##(\d+)(?:##\d+)?)$"}
*loop {('index_temp_9' not "" max=1)|end}
*url_index.modify {replace|#_#domain#_#|}
*url_index.modify {replace|#_#zipcode#_#|zipcode='index_temp_9'}
*end_loop
*index_temp_9.modify {substring(type=regex)|'config_site_id' "^(?:[^#]*##(\D\d\D\d\D\d)(?:##\d+)?)$"}
*loop {('index_temp_9' not "" max=1)|end}
*url_index.modify {replace|##domain##|/ca}
*url_index.modify {replace|##zipcode##|zipcode='index_temp_9'}
*end_loop
*global_temp_8.modify {substring(type=regex)|'config_site_id' "(\d+)$"}
*global_temp_7.modify {calculate(format=date,ddd+MMM+dd+yyyy)|'urldate'}
*end_scope
*index_site_id.scrub {multi|||target=\"_blank\"|<\/a>|<\/span>}
*index_site_id.modify {replace|\/guide\/listings\/channel\/|##}
*index_site_id.modify {cleanup(style=jsondecode)}
*index_site_channel.modify {remove(type=regex)|"^[^>]*>"}
*index_site_channel.modify {cleanup(style=jsondecode)}
*index_site_id.modify {cleanup(removeduplicates link="index_site_channel")}
** @auto_xml_channel_end