**------------------------------------------------------------------------------------------------
* @header_start
* WebGrab+Plus ini for grabbing MDB data from TvGuide websites
* @MinSWversion : V1.1.1/56.25
* - (postprocess V2.0)
* @Site: thetvdb.com
* @Revision 2 - [19/06/2016] Jan van Straaten
* - improved mdb_show_id
* @Revision 1 - [22/05/2016] Jan van Straaten
* - support for match on episode-num or sub-title, use of new scopes
* - added mdbiniype
* @Revision 0 - [02/12/2015] Jan van Straaten
* - creation
* @Remarks: - series database , primarysearch with bing
* @header_end
**------------------------------------------------------------------------------------------------
*
*
site {url=thetvdb.com|mdbinitype=serie|cultureinfo=en-US|charset=utf-8,iso-8859-2|matchfactor=70|searchsite=bing}
*site {episodesystem=xmltv_ns}
* primary search:
url_primarysearch {url()|http://www.bing.com/search?q=thetvdb+|'title'|}
url_primarysearch.headers {customheader=Accept-Encoding=gzip,deflate}
*http://www.bing.com/search?q=thetvdb+Malcolm+in+the+Middle
scope.range {(primarysearch)|end}
url_primarysearch.modify {replace()| |+} * if title has spaces
*
* followed by all the known episodes in a element
* following the mdbconfig mustmatch="title,subtitle" the program looks for a match of the title (in the element)
* and a match of the subtitle in one of the elements
*
scope.range {(match)|end}
* the subtitle is the episode title. The next scrub first results in all the subtitles for this series
* but the matching routine will automatically replace it by the one that matches (highest matchfactor )
*mdb_subtitle.scrub {multi|p1||||} * old style: use episodetitlelist instead:
mdb_episodetitlelist.scrub {multi|p1||||}
*****************************
* the episodenum can be used as alternative for episode matching if subtitle is not available
* it will be matched following the same procedure as for subtitle matching it with the xmltv episode-num
mdb_episodenumlist.scrub {regex(pattern="'E1''S1'")|p1||(.+?)||}
mdb_episodenumlist.modify {remove(type=regex)|'mdb_episodenumlist' "(.+?)"}
mdb_episodenumlist.modify {replace|| }
************************
* get the matching element (with most of the episode data)
* and select the matching one
* mdb_temp_6 contains all the episodes
mdb_temp_6.scrub {multi|p1||||} * all episodes
*mdb_temp_6.modify {replace()|\||\n\n\|} * testing only
end_scope
scope.range {(getelements)|end}
***************
* in case of matched subtitle
mdb_temp_1.modify {calculate('mdb_episodetitlelist' not "" type=element format=F0)|'mdb_episodetitlelist' 'mdb_subtitle' @} * index of the episode
* in case of matched episodenum
mdb_temp_1.modify {calculate('mdb_episodenumlist' not "" type=element format=F0)|'mdb_episodenumlist' 'mdb_episode' @} * index of the episode
mdb_temp_1.modify {substring(type=element)|'mdb_temp_6' 'mdb_temp_1' 1} * the episode in xml format
* from here mdb_temp_1 holds the with all the data
* episode_id
mdb_episode_id.modify {substring('mdb_temp_1' not "" type=regex)|'mdb_temp_1' "(\d+?)"}
*****************
* mdb elements:
* in the top element (from p1):
mdb_title.scrub {single()|p1||||}
mdb_actor.scrub {regex()|p1||(.*?)||}
mdb_category.scrub {single|p1||||}
mdb_category.modify {replace|!?!?!|\|}
* the rest of the elements (from temp_1)
*
* subtitle, if not already there
mdb_subtitle.modify {substring("" type=regex)|'mdb_temp_1' "(.*?)"}
* description
mdb_description.modify {substring(type=regex)|'mdb_temp_1' "(.*?)"}
* starrating
mdb_starrating.modify {substring(type=regex)|'mdb_temp_1' "(.*?)"}
* director
mdb_director.modify {substring(type=regex)|'mdb_temp_1' "(.*?)"}
mdb_director.modify {replace|!?!?!|\|}
* actor, if not already from the top elements
mdb_actor.modify {substring("" type=regex)|'mdb_temp_1' "(.*?)"}
mdb_actor.modify {replace|!?!?!|\|}
* writer
*mdb_writer.modify {substring(type=regex)|'mdb_temp_1' "(.*?)"}
mdb_showicon.modify {substring(type=regex)|'mdb_temp_1' "(.*?)"}
mdb_showicon.modify {addstart(not "")|http://www.thetvdb.com/banners/}
* productiondate
mdb_productiondate.modify {substring(type=regex)|'mdb_temp_1' "(\d{4}.*?)"}
*
* episodenum if not already done in the episodenumlist
* this part as the last one because episode is used to get mdb_temp_1 and may not be changed
* during the part above
* at this spot it can be changed from the internal 'onscreen' Sn En format to xmltv_ns or whatever else.
7
3
mdb_episode.modify {clear}
loop {('mdb_episode' "" max=1)|end}
mdb_episode.modify {substring("" type=regex)|'mdb_temp_1' "(\d*?)"}
mdb_temp_2.modify {substring(type=regex)|'mdb_temp_1' "(\d*?)(?:\.\d\|)"}
* onscreen
mdb_episode.modify {addstart(not "")|S}
mdb_episode.modify {addend('mdb_temp_2' not "")| E'mdb_temp_2'} *format Sx Ey
* xmltv_ns conversie
*mdb_temp_2.modify {calculate(not "" format=F0)|1 -} * episode is 1 based in tvdb!
*mdb_episode.modify {calculate(not "" format=F0)|1 -} * season is 1 based
*mdb_episode.modify {addend()|.'mdb_temp_2'.} * in xmltv_ns
end_loop
end_scope