* @header_start
* WebGrab+Plus ini for grabbing EPG data from TvGuide websites
* @Site: magentatv.de
* @MinSWversion: V5.0
* @Revision 3 - [15/02/2025] Blackbear199
* @Revision 2 - [01/02/2025] Blackbear199
*  - site changes
* @Revision 1 - [23/01/2021] Blackbear199
*  - url_index change
* @Revision 0 - [15/01/2019] Kvanc
*  - Creation
* @Remarks:
* @header_end
**------------------------------------------------------------------------------------------------
site {url=magentatv.de|timezone=Atlantic/Reykjavik|maxdays=14.1|cultureinfo=de-DE|charset=UTF-8|titlematchfactor=90|allowlastdayoverflow}
site {ratingsystem=FSK|episodesystem=onscreen}
*
scope.range                {(urlindex)|end}
url_index                  {url|https://api.prod.sngtv.magentatv.de/EPG/JSON/Authenticate?SID=reconnect&T=Windows_chrome_132&}
url_index.headers          {method=POST_BACK(POST,POST)}
url_index.headers          {contenttype=application/json}
url_index.headers          {postdata={"terminalid":"00:00:00:00:00:00","mac":"00:00:00:00:00:00","terminaltype":"WEBTV","utcEnable":1,"timezone":"Atlantic/Reykjavik","userType":3,"terminalvendor":"Unknown","preSharedKeyID":"PC01P00002","cnonce":"","areaid":"1","templatename":"NGTV","usergroup":"-1","subnetId":"4901"}|={"requestList": [{"name": "PlayBillList", "param":{"channelid":"'global_temp_2'","type":2,"offset":0,"count":-1,"isFillProgram":1,"properties":[{"name":"playbill","include":"subName,id,name,starttime,endtime,introduce,ratingForeignsn,subNum,seasonNum,genres,ratingForeignsn,cast,country,producedate"}],"endtime":"'global_temp_7'235959","begintime":"'global_temp_8'000000"}}]}}
url_index.headers          {host=api.prod.sngtv.magentatv.de}
url_index.headers          {referer=https://api.prod.sngtv.magentatv.de/EPG/}
url_index.headers          {customheader=X_CSRFToken='global_temp_1'}
url_index.headers          {customheader=Origin=https://api.prod.sngtv.magentatv.de}
url_index.headers          {customheader=X-Requested-With=XMLHttpRequest}
url_index.headers          {customheader=Accept-Encoding=gzip,deflate,br}
*
global_temp_1.scrub        {single|"csrfToken":"||"|"}
global_temp_2.modify       {substring(type=regex)|'config_site_id' "^(\d+)"}
*
global_temp_9.modify       {calculate(format=F0)|'config_timespan_days' 1 +}
global_temp_8.modify       {calculate(format=date,dd-MM-yyyy)|'urldate'}
global_temp_7.modify       {calculate(format=date,yyyyMMdd)|'global_temp_8' 'global_temp_9':0:0 +}
global_temp_8.modify       {calculate(format=date,yyyyMMdd)}
end_scope
*
scope.range                {(postback)|end}
url_index.modify           {set|https://api.prod.sngtv.magentatv.de/EPG/JSON/ExecuteBatch?PlayBillList&SID=startpageprogram&T=Windows_chrome_132}
end_scope
*
urldate.format             {datestring|dd-MM-yyyy}
*
index_urlchannellogo.modify{substring(type=regex)|'config_site_id' "##([^#]*)$"}
index_urlchannellogo.modify{addstart(not "")|http://ngiss.t-online.de/cm1s/media/}
*
scope.range {(splitindex)|end}
index_showsplit.scrub      {multi|"playbilllist":[||],"playbillVersion"|],"playbillVersion"}
index_showsplit.modify     {replace(type=regex)|"\!\?\?\!"|-}
index_showsplit.modify     {replace|\},\{"id"|\}\|\{"id"}
index_showsplit.modify     {cleanup(style=unidecode)}
index_showsplit.modify     {cleanup(style=jsondecode)}
index_showsplit.modify     {replace|\\n| }
*index_showsplit.modify    {(debug)}
end_scope
*
index_start.scrub          {single|"starttime":"|| UTC| UTC}
index_stop.scrub           {single|"endtime":"|| UTC| UTC}
index_title.scrub          {single|"name":"||","|","}
index_title.modify         {addend('index_title' "")|brechen}
index_subtitle.scrub       {single|"subName":"||",|",}
index_description.scrub    {single|"introduce":"||","|","}
index_category.scrub       {multi(separator=",")|"genres":"||"|"}
index_actor.scrub          {multi(separator=",")|"actor":"||"|"}
index_director.scrub       {multi(separator=",")|"director":"||"|"}
index_producer.scrub       {multi(separator=",")|"producer":"||"|"}
index_episode.scrub        {single(pattern="S'S1'E'E1'""E'E1'""S'S1'")|"subNum":"||"|"}
index_temp_1.scrub         {single|"seasonNum":"||"|"}
index_country.scrub        {multi(separator=",")|"country":"||"|"}
index_productiondate.scrub {single|"producedate":"||-|"}
index_rating.scrub         {single|"ratingForeignsn":"||"|"}
index_showicon.scrub       {single|"pictures":[{"rel":"image","href":"||"|"}
*
index_title.modify         {remove(type=regex)|"\s\(\d+(?:\/\d+)?\)"}
index_episode.modify       {addstart(not "")|E}
index_episode.modify       {addstart('index_temp_1' not "")|S'index_temp_1'}
index_country.modify       {cleanup(style=upper)}
index_rating.modify        {replace|FSK 0|Ab 0 Jahren (FSK)}
index_rating.modify        {replace|FSK 6|Ab 6 Jahren (FSK)}
index_rating.modify        {replace|FSK 12|Ab 12 Jahren (FSK)}
index_rating.modify        {replace|FSK 16_PIN|Ab 16 Jahren (FSK)}
index_rating.modify        {replace|FSK 16|Ab 16 Jahren (FSK)}
index_rating.modify        {replace|FSK 18|Ab 18 Jahren (FSK)}
index_rating.modify        {replace|FSK 18_Alt|Ab 18 Jahren (FSK)}
index_rating.modify        {replace|FSK 18_Neu|Ab 18 Jahren (FSK)}
index_rating.modify        {replace|OAF|Erwachsenenangebot}
index_rating.modify        {replace|FSK OAF|Erwachsenenangebot}
index_rating.modify        {replace|Unbekannt|Keine Altersangabe}
index_rating.modify        {replace|Andere 0|Ab 0 Jahren}
index_rating.modify        {replace|Andere 6|Ab 6 Jahren}
index_rating.modify        {replace|Andere 12|Ab 12 Jahren}
index_rating.modify        {replace|Andere 16|Ab 16 Jahren}
index_rating.modify        {replace|Andere 18|Ab 18 Jahren}
index_rating.modify        {replace|Andere oaf|Erwachsenenangebot}
index_rating.modify        {replace|FSF 0|Ab 0 Jahren (FSF)}
index_rating.modify        {replace|FSF 6|Ab 6 Jahren (FSF)}
index_rating.modify        {replace|FSF 12|Ab 12 Jahren (FSF)}
index_rating.modify        {replace|FSF 16|Ab 16 Jahren (FSF)}
index_rating.modify        {replace|FSF 18|Ab 18 Jahren (FSF)}
index_rating.modify        {replace|FSF OAF|Erwachsenenangebot}
index_rating.modify        {replace|NEUTRAL 0|Ab 0 Jahren}
index_rating.modify        {replace|NEUTRAL 6|Ab 6 Jahren}
index_rating.modify        {replace|NEUTRAL 12|Ab 12 Jahren}
index_rating.modify        {replace|NEUTRAL 16_PIN|Ab 16 Jahren}
index_rating.modify        {replace|NEUTRAL 16|Ab 16 Jahren}
index_rating.modify        {replace|NEUTRAL 18|Ab 18 Jahren}
index_rating.modify        {replace|NEUTRAL 18_EL|Ab 18 Jahren}
**  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _  _
**      #####  CHANNEL FILE CREATION (only to create the xxx-channel.xml file)
**
** @auto_xml_channel_start
*scope.range {(urlindex)|end}
*url_index.headers          {postdata={"terminalid":"00:00:00:00:00:00","mac":"00:00:00:00:00:00","terminaltype":"WEBTV","utcEnable":1,"timezone":"Atlantic/Reykjavik","userType":3,"terminalvendor":"Unknown","preSharedKeyID":"PC01P00002","cnonce":"","areaid":"1","templatename":"NGTV","usergroup":"-1","subnetId":"4901"}|={"properties":[{"name":"logicalChannel","include":"/channellist/logicalChannel/contentId,/channellist/logicalChannel/name,/channellist/logicalChannel/pictures/picture/href"}],"metaDataVer":"Channel/1.1","channelNamespace":"3","filterlist":[{"key":"IsHide","value":"-1"}],"returnSatChannel":0}}
*end_scope
*scope.range             {(postback)|end}
*url_index.modify        {set|https://api.prod.sngtv.magentatv.de/EPG/JSON/AllChannel?SID=first&T=Windows_chrome_132}
*end_scope
*index_site_id.scrub     {regex||\{"contentId":"(\d+","name":"[^"]*","pictures":\[\{"href":"[^"]*)"\}||}
*index_site_channel.scrub{multi|"channellist":[|"name":"|","|]}]}}
*index_site_id.modify    {replace(type=regex)|"^\d+(.*?media\/)"|##}
*index_site_id.modify    {cleanup(removeduplicates link="index+site_channel")}
** @auto_xml_channel_end
