<?xml version="1.0" encoding="UTF-8"?>
<scraper framework="1.1" date="2009-08-10" name="PTGate and IMDb" content="movies" thumb="ptgate.jpg" language="pt">
	<include>common/tmdb.xml</include>
	<include>common/movieposterdb.xml</include>
	<include>common/impa.xml</include>
	<include>common/imdb.xml</include>
	<GetSettings dest="3">
		<RegExp input="$$5" output="&lt;settings&gt;\1&lt;/settings&gt;" dest="3">
			<RegExp input="$$1" output="&lt;setting label=&quot;Utilizar apenas o Cinema PTGate&quot; type=&quot;bool&quot; id=&quot;ptgateonly&quot; default=&quot;false&quot;&gt;&lt;/setting&gt;" dest="5">
				<expression/>
			</RegExp>
			<RegExp input="$$1" output="&lt;setting type=&quot;sep&quot;&gt;&lt;/setting&gt;" dest="5+">
				<expression/>
			</RegExp>
			<RegExp input="$$1" output="&lt;setting label=&quot;Incluir detalhes e fotos dos Actores&quot; type=&quot;bool&quot; id=&quot;fullcredits&quot; default=&quot;false&quot;&gt;&lt;/setting&gt;" dest="5+">
				<expression/>
			</RegExp>
			<RegExp input="$$1" output="&lt;setting label=&quot;Incluir detalhes do IMPAwards&quot; type=&quot;bool&quot; id=&quot;impawards&quot; default=&quot;true&quot;&gt;&lt;/setting&gt;" dest="5+">
				<expression/>
			</RegExp>
			<RegExp input="$$1" output="&lt;setting label=&quot;Incluir detalhes do MoviePosterDB&quot; type=&quot;bool&quot; id=&quot;movieposterdb&quot; default=&quot;false&quot;&gt;&lt;/setting&gt;" dest="5+">
				<expression/>
			</RegExp>
			<RegExp input="$$1" output="&lt;setting label=&quot;Incluir trailer&quot; type=&quot;bool&quot; id=&quot;trailer&quot; default=&quot;true&quot;&gt;&lt;/setting&gt;" dest="5+">
				<expression/>
			</RegExp>
			<RegExp input="$$1" output="&lt;setting label=&quot;Incluir Fanart&quot; type=&quot;bool&quot; id=&quot;fanart&quot; default=&quot;true&quot;&gt;&lt;/setting&gt;" dest="5+">
				<expression/>
			</RegExp>
			<RegExp input="$$1" output="&lt;setting label=&quot;Tamanhos do Poster e das Fotos dos Actores&quot; type=&quot;labelenum&quot; values=&quot;192|256|384|512|1024&quot; id=&quot;imdbscale&quot; default=&quot;512&quot;&gt;&lt;/setting&gt;" dest="5+">
				<expression/>
			</RegExp>
			<expression noclean="1"/>
		</RegExp>
	</GetSettings>
	<NfoUrl dest="3">
		<RegExp input="$$1" output="\1" dest="3">
			<expression clear="yes" noclean="1">(http://www.cinema.ptgate.pt/filmes/[0-9]*)</expression>
		</RegExp>
	</NfoUrl>
	<CreateSearchUrl dest="3">
		<RegExp input="$$1" output="&lt;url&gt;http://www.cinema.ptgate.pt/pesquisa/?q=\1&lt;/url&gt;" dest="3">
			<expression noclean="1">([^\(]+)</expression>
		</RegExp>
	</CreateSearchUrl>
	<GetSearchResults dest="8">
		<RegExp input="$$5" output="&lt;?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot; standalone=&quot;yes&quot;?&gt;&lt;results&gt;\1&lt;/results&gt;" dest="8">
			<RegExp dest="5+" input="$$1" output="&lt;entity&gt;&lt;title&gt;\2 - \4 (\3)&lt;/title&gt;&lt;url&gt;http://www.cinema.ptgate.pt/filmes/\1&lt;/url&gt;&lt;id&gt;\1&lt;/id&gt;&lt;/entity&gt;">
				<expression repeat="yes" trim="2,3">&lt;a href=&quot;/filmes/([0-9]*)&quot;&gt;(.*?)&lt;/a&gt; &lt;small&gt;([^\(]*)\(([0-9]*)\)</expression>
			</RegExp>
			<RegExp dest="5" input="$$1" output="&lt;entity&gt;&lt;title&gt;\2 - \3 (\4)&lt;/title&gt;&lt;url&gt;http://www.cinema.ptgate.pt/filmes/\1&lt;/url&gt;&lt;id&gt;\1&lt;/id&gt;&lt;/entity&gt;">
				<expression trim="2,4">&lt;a href=&quot;/filmes/([0-9]*)&quot; class=&quot;upper&quot;&gt;([^&lt;]*)&lt;/a&gt; &lt;small&gt;\(([0-9]*)\)&lt;br /&gt;([^&lt;]*)</expression>
			</RegExp>
			<expression noclean="1"/>
		</RegExp>
	</GetSearchResults>
	<GetDetails clearbuffers="no" dest="3">
		<RegExp input="$$5" output="&lt;details&gt;\1&lt;/details&gt;" dest="3">
			<!-- Id -->
			<RegExp dest="5" input="$$2" output="&lt;id&gt;\1&lt;/id&gt;">
				<expression/>
			</RegExp>
			<!-- Title -->
			<RegExp dest="5+" input="$$1" output="&lt;title&gt;\1&lt;/title&gt;">
				<expression>&lt;h2&gt;([^&lt;]*)&lt;/h2&gt;</expression>
			</RegExp>
			<!-- Plot -->
			<RegExp dest="5+" input="$$1" output=";&lt;plot&gt;\1&lt;/plot&gt;">
				<expression>&lt;b&gt;sinopse[^\n]*\s+([^\n]*)</expression>
			</RegExp>
			<!-- Outline -->
			<RegExp dest="5+" input="$$1" output="&lt;outline&gt;\1&lt;/outline&gt;">
				<expression>&lt;b&gt;sinopse[^\n]*\s+(.*?[^A-Z]\.)</expression>
			</RegExp>
			<!-- Genre -->
			<RegExp dest="5+" input="$$9" output="&lt;genre&gt;\1&lt;/genre&gt;">
				<RegExp dest="9" input="$$1" output="\1,">
					<expression>&lt;b&gt;g.nero&lt;/b&gt;: ([^&lt;]*)</expression>
				</RegExp>
				<expression repeat="yes" trim="1">([^,]+),</expression>
			</RegExp>
			<!-- Year -->
			<RegExp dest="11" input="$$1" output="&lt;year&gt;\1&lt;/year&gt;">
				<expression>&lt;b&gt;ano&lt;/b&gt;: ([^&lt;]*)</expression>
			</RegExp>
			<RegExp dest="5+" input="$$11" output="\1">
				<expression noclean="1"/>
			</RegExp>
			<!-- Actor -->
			<RegExp dest="8" input="$$9" output="&lt;actor&gt;&lt;name&gt;\1&lt;/name&gt;&lt;/actor&gt;">
				<RegExp input="$$1" output="\1," dest="9">
					<expression>&lt;b&gt;int.rpretes&lt;/b&gt;&lt;br /&gt;\s*(.*?)&lt;br /&gt;</expression>
				</RegExp>
				<expression clear="yes" repeat="yes" trim="1">([^,]*),</expression>
			</RegExp>
			<RegExp dest="4" input="$$8" output="&lt;actors&gt;\1&lt;/actors&gt;">
				<expression noclean="1"/>
			</RegExp>
			<RegExp dest="5+" input="$$8" conditional="ptgateonly" output="\1">
				<expression noclean="1"/>
			</RegExp>
			<!-- Director -->
			<RegExp dest="8" input="$$9" output="&lt;director&gt;\1&lt;/director&gt;">
				<RegExp input="$$1" output="\1," dest="9">
					<expression>&lt;b&gt;realiza..o&lt;/b&gt;&lt;br /&gt;\s*(.*?)&lt;br /&gt;</expression>
				</RegExp>
				<expression repeat="yes" trim="1">([^,]+),</expression>
			</RegExp>
			<RegExp dest="4+" input="$$8" output="&lt;directors&gt;\1&lt;/directors&gt;">
				<expression noclean="1"/>
			</RegExp>
			<RegExp dest="5+" input="$$8" conditional="ptgateonly" output="\1">
				<expression noclean="1"/>
			</RegExp>
			<!-- Add PTGate image as last Thumb -->
			<RegExp dest="12" input="$$2" output="&lt;thumb&gt;http://www.cinema.ptgate.pt/Movies/\1.jpg&lt;/thumb&gt;">
				<expression/>
			</RegExp>
			<RegExp dest="5+" input="$$12" conditional="ptgateonly" output="\1">
				<expression noclean="1"/>
			</RegExp>
			<!-- Add PT Distributor -->
			<RegExp dest="13" input="$$1" output="&lt;studio&gt;Dist: \1&lt;/studio&gt;">
				<expression>&lt;b&gt;distribuidora&lt;/b&gt;: ([^&lt;]*)</expression>
			</RegExp>
			<RegExp dest="5+" input="$$13" conditional="ptgateonly" output="\1">
				<expression noclean="1"/>
			</RegExp>
			<!-- IMDB Details -->
			<RegExp dest="5+" input="$$10" conditional="!ptgateonly" output="\1">
				<!-- Use Google as last resort -->
				<RegExp dest="10" input="$$8" output="&lt;url function=&quot;GetIMDBfromGoogle&quot;&gt;http://www.google.com/search?q=site:imdb.com\1&lt;/url&gt;">
					<!-- search google for the original title -->
					<RegExp input="$$1" output="\1" dest="7">
						<expression trim="1">\&amp;#8250; ([^&lt;]+)&lt;br /&gt;</expression>
					</RegExp>
					<!-- add year to search string -->
					<RegExp input="$$11" output="+\1" dest="8">
						<expression/>
					</RegExp>
					<!-- remove spaces and , -->
					<RegExp input="$$7" output="+\1" dest="8+">
						<expression repeat="yes">([^ ,]+)</expression>
					</RegExp>
					<expression/>
				</RegExp>
				<!-- use IMDB link on PTGATE, when available -->
				<RegExp dest="10" input="$$9" output="&lt;url function=&quot;GetIMDBDetails&quot;&gt;http://akas.imdb.com/title/\1/&lt;/url&gt;">
					<RegExp dest="9" input="$$1" output="\1">
						<expression clear="yes">\.imdb\.com/title/(tt[0-9]*)</expression>
					</RegExp>
					<expression>(.+)</expression>
				</RegExp>
				<expression noclean="1"/>
			</RegExp>
			<expression noclean="1"/>
		</RegExp>
	</GetDetails>
	<GetIMDBfromGoogle clearbuffers="no" dest="3">
		<RegExp input="$$5" dest="3" output="&lt;details&gt;\1&lt;/details&gt;">
			<RegExp input="$$1" dest="5" output="&lt;url function=&quot;GetIMDBDetails&quot;&gt;http://akas.imdb.com/title/\1/&lt;/url&gt;">
				<expression>\.imdb\.com/title/(tt[0-9]*)</expression>
			</RegExp>
			<expression noclean="1"/>
		</RegExp>
	</GetIMDBfromGoogle>
	<GetIMDBDetails clearbuffers="no" dest="3">
		<RegExp input="$$5" dest="3" output="&lt;details&gt;\1&lt;/details&gt;">
			<!-- IMDB Id -->
			<RegExp input="$$1" dest="2" output="\1">
				<expression>id=(tt[t0-9]*)</expression>
			</RegExp>
			<!-- Studio -->
			<RegExp input="$$1" output="&lt;studio&gt;\1&lt;/studio&gt;" dest="5">
				<expression clear="yes" repeat="yes">&quot;/company/[^/]*/&quot;&gt;([^&lt;]*)&lt;/a&gt;</expression>
			</RegExp>
			<RegExp input="$$13" output="\1" dest="5+">
				<expression noclean="1"/>
			</RegExp>
			<!-- Certificates -->
			<RegExp input="$$1" output="&lt;certification&gt;\1 \3&lt;/certification&gt;" dest="5+">
				<expression repeat="yes">&lt;a href=&quot;/List\?certificates=[^&quot;]*&quot;&gt;([^&lt;]*)&lt;/a&gt;[^&lt;]*(&lt;i&gt;([^&lt;]*)&lt;/i&gt;)?</expression>
			</RegExp>
			<!-- Runtime -->
			<RegExp input="$$1" output="&lt;runtime&gt;\1&lt;/runtime&gt;" dest="5+">
				<expression trim="1">&lt;h5&gt;Runtime:&lt;/h5&gt;[^0-9]*([^&lt;|]*)</expression>
			</RegExp>
			<!-- Rating -->
			<RegExp input="$$1" output="&lt;rating&gt;\1&lt;/rating&gt;&lt;votes&gt;\2&lt;/votes&gt;" dest="5+">
				<expression>&lt;b&gt;([0-9.]+)/10&lt;/b&gt;[^&lt;]*&lt;a href=&quot;ratings&quot; class=&quot;tn15more&quot;&gt;([0-9,]+) votes&lt;/a&gt;</expression>
			</RegExp>
			<!-- Actor -->
			<RegExp conditional="!fullcredits" input="$$2" output="&lt;url cache=&quot;$$2-credits.html&quot; function=&quot;GetIMDBCast&quot;&gt;$$3&lt;/url&gt;" dest="5+">
				<expression/>
			</RegExp>
			<!-- Director -->
			<RegExp conditional="!fullcredits" input="$$2" output="&lt;url cache=&quot;$$2-credits.html&quot; function=&quot;GetMovieDirectors&quot;&gt;$$3&lt;/url&gt;" dest="5+">
				<expression/>
			</RegExp>
			<!-- Credits -->
			<RegExp conditional="!fullcredits" input="$$2" output="&lt;url cache=&quot;$$2-credits.html&quot; function=&quot;GetIMDBWriters&quot;&gt;$$3&lt;/url&gt;" dest="5+">
				<expression/>
			</RegExp>
			<!-- Actor, full -->
			<RegExp conditional="fullcredits" input="$$2" output="&lt;url cache=&quot;$$2-fullcredits.html&quot; function=&quot;GetIMDBCast&quot;&gt;$$3fullcredits&lt;/url&gt;" dest="5+">
				<expression/>
			</RegExp>
			<!-- Director, full -->
			<RegExp conditional="fullcredits" input="$$2" output="&lt;url cache=&quot;$$2-fullcredits.html&quot; function=&quot;GetIMDBDirectors&quot;&gt;$$3fullcredits&lt;/url&gt;" dest="5+">
				<expression/>
			</RegExp>
			<!-- Credits, full -->
			<RegExp conditional="fullcredits" input="$$2" output="&lt;url cache=&quot;$$2-fullcredits.html&quot; function=&quot;GetIMDBWriters&quot;&gt;$$3fullcredits&lt;/url&gt;" dest="5+">
				<expression/>
			</RegExp>
			<!-- Thumb, IMPAwards -->
			<RegExp conditional="impawards" input="$$2" output="&lt;url cache=&quot;$$2-posters.html&quot; function=&quot;GetIMPALink&quot;&gt;$$3posters&lt;/url&gt;" dest="5+">
				<expression/>
			</RegExp>
			<!-- Poster, MoviePosterDB -->
			<RegExp conditional="movieposterdb" input="$$1" output="&lt;url function=&quot;GetMoviePosterDBLink&quot;&gt;http://www.movieposterdb.com/browse/search?type=movies&amp;amp;query=\1&lt;/url&gt;" dest="5+">
				<expression>/title/tt([t0-9]*)/faq</expression>
			</RegExp>
			<!-- Trailer -->
			<RegExp conditional="trailer" input="$$1" output="&lt;url function=&quot;GetIMDBTrailer&quot;&gt;http://akas.imdb.com/video/imdb/vi\1/player&lt;/url&gt;" dest="5+">
				<expression>/vi([0-9]*)/&quot;</expression>
			</RegExp>
			<!-- Thumb, IMDB -->
			<RegExp input="$$2" output="&lt;url cache=&quot;$$2-posters.html&quot; function=&quot;GetIMDBPoster&quot;&gt;$$3posters&lt;/url&gt;" dest="5+">
				<expression/>
			</RegExp>
			<!-- Fanart -->
			<RegExp conditional="fanart" input="$$2" output="&lt;url function=&quot;GetTMDBFanartById&quot;&gt;$$3&lt;/url&gt;" dest="5+">
				<expression/>
			</RegExp>
			<expression noclean="1"/>
		</RegExp>
	</GetIMDBDetails>
</scraper>
