**------------------------------------------------------------------------------------------------
* @header_start
* WebGrab+Plus ini for grabbing EPG data from TvGuide websites
* @Site: directv.com
* @MinSWversion: V1.57
* none
* @Revision 12 - [07/11/2016] Blackbear199
* - fix urlsubdetails
* - adapt season/episode to new system
* @Revision 11 - [19/09/2016] Blackbear199
* - showsplit change
* @Revision 10 - [03/01/2016] Francis De Paemeleere
* - removed duplicates from index
* - remove json stuff
* @Revision 9 - [28/12/2015] Francis De Paemeleere
* - small change to index split due to site changes
* @Revision 8 - [17/11/2015] Jan van Straaten
* - removed duplicates from index
* @Revision 7 - [29/10/2015] Jan van Straaten
* - wrong error in cookiefile name corrected
* @Revision 6 - [28/10/2015] Jan van Straaten
* - new creation
* @Remarks:
* - USA and N/S - America
* @header_end
**------------------------------------------------------------------------------------------------
site {url=directv.com|timezone=America/New_York|maxdays=7|cultureinfo=en-US|charset=UTF-8|titlematchfactor=90}
site {loadcookie=directv.com.cookies.txt}
site {ratingsystem=MPAA|episodesystem=onscreen}
*
url_index {url|https://www.directv.com/json/channelschedule?channels=|channel|,&startTime=|urldate|%20|subpage|:00:00%20GMT&hours=12}
url_index.headers {referer=https://www.directv.com/assets/js/dtve/apps/guide/programDataServiceProcessor.js}
url_index.headers {customheader=Accept-Encoding=gzip,deflate}
subpage.format{list|06|18}
urldate.format{datestring|ddd"%20"MMM"%20"dd"%20"yyyy}
*
index_showsplit.scrub {regex||\"schedules\":\[(.*?\}\])||}
*
scope.range {(splitindex)|end}
index_showsplit.modify {substring(type=regex)|"\{.*?\}"}
index_temp_1.modify {substring(type=regex)|'index_showsplit' "\"airTime\":\"([^\"]*)\""}
index_temp_1.modify {cleanup(removeduplicates link="index_showsplit")}
end_scope
title.modify {addstart|'index_title'}
*
scope.range {(indexshowdetails)|end}
index_start.scrub {regex||"airTime":"(\d{4}-\d{1,2}-\d{1,2}T\d{1,2}:\d{1,2}):||}
index_temp_2.modify {calculate(format=date,unix)|'index_start'}
index_temp_2.modify {calculate(timezone=America/New_York)}
index_temp_2.modify {calculate(format=date,unix)}
index_temp_3.modify {calculate(format=date,dddd)|'index_temp_2'}
index_temp_4.modify {calculate(format=time,h:mmtt)|'index_temp_2'}
index_title.modify {addend| - 'index_temp_3' @ 'index_temp_4' ET}
index_duration.scrub {single|"duration":||,|,}
index_title.scrub {single|"title":"||"|"}
*
* details
index_temp_1.scrub {regex||"programID":"(.*?)",||} * programID
index_temp_1.modify {clear("-1")}
index_urlshow.modify {set('index_temp_1' not "")|https://www.directv.com/json/program/flip/'index_temp_1'}
index_urlshow.headers {accept=application/json, text/plain, */*}
urlshow.headers {customheader=Accept-Encoding=gzip,deflate}
end_scope
*
scope.range {(showdetails)|end}
title.scrub {regex||"title":"(.+?)","||}
subtitle.scrub {regex||"episodeTitle":"(.*?)","||}
description.scrub {regex||"description":"(.*?)","||}
*
temp_2.scrub {regex||"episodeNumber":([^,]*),"||}
temp_2.modify {clear("0")}
temp_2.modify {addstart(not "")|E}
temp_3.scrub {regex||"episodeSeason":([^,]*),"||} *season
temp_3.modify {clear("0")}
temp_3.modify {addstart(not "")|S}
temp_3.modify {addend|'temp_2'}
episode.modify {addstart(pattern="S'S1'E'E1'""S'S1'""E'E1'")|'temp_3'}
*
starrating.scrub {regex||"starRating":"(.*?)","||}
rating.scrub {regex||"rating":"(.*?)","||}
productiondate.scrub {regex||"releaseYear":"(\d{4})","||}
productiondate.scrub {regex||"originalAirDate":"(\d{4})-\d{2}-\d{2}","||}
title.modify {cleanup(style=jsondecode)}
subtitle.modify {cleanup(style=jsondecode)}
starrating.modify {cleanup(style=jsondecode)}
rating.modify {cleanup(style=jsondecode)}
description.modify {remove|\}
*
* subdetail url:
temp_1.scrub {regex||"detailsLinkUrl":"(.*?)","||}
urlsubdetail.modify {addstart('temp_1' not "")|https://www.directv.com'temp_1'}
urlsubdetail.headers {customheader=Accept-Encoding=gzip,deflate}
end_scope
*
scope.range {(showsubdetails)|end}
subdetail_title.scrub {single||"/>}
subdetail_director.scrub {multi(max=2 includeblock=">Director <")|class="poster"/>|||}
subdetail_producer.scrub {multi(max=2 includeblock=">Producer <")|class="poster"/>|||}
subdetail_actor.scrub {multi(max=5 excludeblock=">Director <"">Producer <")|class="poster"/>|||}
end_scope
*
** _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
** ##### CHANNEL FILE CREATION (only to create the xxx-channel.xml file)
**
** @auto_xml_channel_start
*scope.range {(channellist)|end}
*url_index {url|https://www.directv.com/guide?lpos=Header:1}
*index_site_channel.scrub {regex||"chName":"(.+?)","||}
*index_site_id.scrub {regex||"chNum":(\d{1,4})(?:,"\|\})||}
*index_temp_6.scrub {regex||"chCall":"(.+?)","||}
*** add channel call makes it more clear?
*index_temp_1.modify {set|0}
*loop {(each "index_temp_2" in 'index_site_channel')|end}
*index_temp_3.modify {substring(type=element)|'index_temp_6' 'index_temp_1' 1} * chCall
*index_temp_4.modify {addend|'index_temp_2' ('index_temp_3')####}
*index_temp_1.modify {calculate(format=F0)|1+}
*end_loop
*index_site_channel.modify {set|'index_temp_4'}
*index_site_channel.modify {replace|####|\|}
*index_site_channel.modify {cleanup(removeduplicates=equal,100 link="index_site_id")}
*end_scope
** @auto_xml_channel_end