const
	script_name='Cinemovies';
	language='French';
	version=7;
	author='JeF/Vlad';
	MinProgramBuild=4007;
	PCount = 12;
	//MaxPicturesCount = 3;
var
	title, MovieName, s, s2, s3, s4, year, director, name, character, BasicURL, country, description, salary: string;
	movie_code, movie_site_url, title_code, small_image, imdb_code: string;
	titles: array of string;
	titles_count, image_mode: integer;
	i, j: integer;
	director_code, code: string;
	directors, writers, actors, characters, genres, imdb_codes: array of string;
	duration: integer;
	imdb_rating: double;
	front_cover_url: string;
	posters_exists, ask_amazon: boolean;
	original_title, mpaa, mpaa_rating: string;
	prefixes: array [1..PCount] of string;
	occurstart,txtpos: string;
	resolution, barcode, aspect_ratio, features, media_format, video_codec: string;
	
	DownloadMovieBigCover, DownloadMovieShortCast, DownloadMovieFullCast, 
	DownloadMovieBigDescription, DownloadMovieComments, 
	DownloadMovieStudios,	DownloadMovieAwards, DownloadMovieEarnings, 
	DownloadMovieAdditionalInfo, DownloadMovieSeasonsList: boolean;
	MaxShotsCount, MaxPostersCount: integer;
	MaxTrailersCount: Integer;

function MovieSearch: integer;
var
	i, j: integer;
	title: string;
begin
	s:='';
	titles_count:=0;
	i:=pos('<div id=searchresult>', all);
	j:=pos('<div class=pages><a href="news.php">News</a></div>',all);
	if (j<=i) then j:=pos('<div id="side-col">',all);
	if (i>0) and (j>i) then
		s:=copy(all, i, j-i);
	if (s='') then
	//movie not found
	else begin

		// Decode "FILM" search results
		occurstart:='title="Voir la fiche film de';
		i:=pos(occurstart,s);
		while i>0 do begin
			delete(s, 1, i+length(occurstart));
			titles_count:=titles_count+1;
			SetLength(titles, titles_count);
			j:= pos('</td></tr></table>', s);
			s2:=copy(s, 1, j+20);
			title_code:=ParseString(s2, 'IDfilm=(\d+)', 1);
			year:=ParseString(s2, '<td valign=.*?>(\d+)</td></tr></table>', 1);
			year:=ClearExtraSpaces(year);
			if (length(year)>0) then year:=' '+year;
			title:='(Film'+year+')';
			title:=title+'  '+ParseString(s2, 'href="fiche_film.php.*?">(.*?)</a>', 1);  //title
			title:=title+'  '+ParseString(s2, 'box>(.*?)</font><br>', 1);  //original title
			title:=title+'  '+ParseString(s2, '</font><br>.(.*?)</td>.<td', 1);  //director and actors

			title:=RemoveTags(title);
			title:=ClearExtraCharacters(title);
			title:=DecodeHTML(title);
			title:=ClearExtraSpaces(title);
			
			while (length(title)>0) and (title[1]=' ') do
				delete(title, 1, 1);

			titles[titles_count-1]:=title_code;
			SetSearchResult(title, title_code);
			i:=pos(occurstart,s);
		end;
		
		// Decode "SERIE TV" search results
		occurstart:='title="Voir la fiche série de';
		i:=pos(occurstart,s);
		while i>0 do begin
			delete(s, 1, i+length(occurstart));
			titles_count:=titles_count+1;
			SetLength(titles, titles_count);
			j:= pos('</td></tr></table>', s);
			s2:=copy(s, 1, j+15);
			title_code:=ParseString(s2, 'serietv=(\d+)', 1);
			if (length(title_code)>0) then title_code:= 'S' + title_code;
			year:=ParseString(s2, '<td valign=".*?">(\d+)</td></tr>', 1);
			year:=ClearExtraSpaces(year);
			if (length(year)>0) then year:=' '+year;
			title:='(Série'+year+')';
			title:=title+'  '+ParseString(s2, 'href="fiche_serie.php.*?">(.*?)</a>', 1);  //title
			title:=title+'  '+ParseString(s2, '<font.*?>(.*?)</font>', 1);  //original title
			title:=title+'  '+ParseString(s2, '</font><br>.(.*?)</td>', 1);  //director and actors
			title:=ClearExtraCharacters(title);			
			title:=DecodeHTML(title);
			title:=ClearExtraSpaces(title);
			
			while (length(title)>0) and (title[1]=' ') do
				delete(title, 1, 1);
			titles[titles_count-1]:=title_code;
			SetSearchResult(title, title_code);
			i := pos(occurstart,s);
		
		end;
	end;
	result:=titles_count;

end;

//get  movie name by barcode(UPC-12)
function GetMovieNameByUPC(barcode: string): string;
var
	url, all, s2, s3, res: string;
	i, j: integer;
begin
	res:='';
	url:=format('http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&SubscriptionId=0J0N83PT9M72BYH98YR2&Operation=ItemSearch&Keywords=%s&SearchIndex=Video&ResponseGroup=Request,Images,Tracks,ItemAttributes', [barcode]);	
	url:=ReplaceStr(url, ' ', '+', -1);
	all:=DownloadURL(url);
	//search image by title
	i:=pos('<Item>', all);
	while (i>0) and (res='') do begin
		j:=MyPos('</Item>', all, i+1);
		if j>0 then begin
			s2:=copy(all, i, j-i);
			s3:=ParseString(s2, '<Title>(.*?) \(.*\)</Title>', 1);
			if s3='' then
				s3:=ParseString(s2, '<Title>(.*?)</Title>', 1);
			if s3<>'' then
				res:=s3;
		end;
		i:=MyPos('<Item>', all, i+1);
	end;
	i:=pos('[', res);
	if i>0 then begin
		j:=MyPos(']', res, i+1);
		if j>0 then
			delete(res, i, j-i+1);
	end;
	result:=res;
end;

//Get search URL by movie name
function GetSearchURLbyName(MovieName, AYear, ABarcode: string): string;
var
	url: string;
begin
	url:=format('http://www.cinemovies.fr/resultat_recherche.php?cherche=%s&typsearch=1', [MovieName]);
	url:=ReplaceStr(url, ' ', '+', -1);
	result:=url;
end;

//Download search results from URL
function DownloadSearchURL(url: string): integer;
begin
	all:=DownloadURL(url);
	if all='-1' then
		result:=-1
	else
		result:=MovieSearch;
end;

function GetMovieURL(code: string; images_only: boolean): string;
var
	codeserie: string;
begin	
	if (pos('S',code)=1) then begin
		codeserie:=copy(code,2,length(code)-1);
		result:=format('http://www.cinemovies.fr/fiche_serie.php?serietv=%s', [codeserie]);
	end
	else
		result:=format('http://www.cinemovies.fr/fiche_film.php?IDfilm=%s', [code]);
end;

function GetAmazonImages: string;
var
	res, all, url, s, s2, s3, amazon_url: string;
	i, j: integer;
begin
	s:=original_title;
	amazon_url:='';
	url:=format('http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&SubscriptionId=0J0N83PT9M72BYH98YR2&Operation=ItemSearch&Keywords=%s&SearchIndex=Video&ResponseGroup=Request,Images,Tracks,ItemAttributes', [original_title]);	
	url:=ReplaceStr(url, ' ', '+', -1);
	all:=DownloadURL(url);
	//search image by title
	amazon_url:='';
	i:=pos('<Item>', all);
	while (i>0) and (amazon_url='') do begin
		j:=MyPos('</Item>', all, i+1);
		if j>0 then begin
			s2:=copy(all, i, j-i);
			s3:=ParseString(s2, '<Title>(.*?) \(.*\)</Title>', 1);
			if s3='' then
				s3:=ParseString(s2, '<Title>(.*?)</Title>', 1);
			if s3<>'' then 
			begin
				//if title=s3 then begin //!!!
				if (pos(UpperCase(original_title), UpperCase(s3))=1) then 
				begin
					amazon_url:=ParseString(s2, '<LargeImage><URL>(.*?)</URL>', 1);
				end;

			end;
		end;
		i:=MyPos('<Item>', all, i+1);
	end;
	if amazon_url<>'' then
		SetImageName('', amazon_url, '', 1);
	res:=amazon_url;

end;

//save front cover to file
function SaveFrontCover(url, FileName: string): boolean;
var
  fs: TFileStream;
	s: string;
begin
	s:=DownloadURL(url);
	if (length(s)>0) and (s<>'-1') then begin
		try
			fs:=TFileStream.Create(FileName, fmCreate);
			fs.Write(s, Length(s));
			fs.Free;
			result:=true;
		except
			result:=false;
		end;
	end
	else
		result:=false;
end;

function MovePrefixLeft(name: string): string;
var
	i, j: integer;
begin
	// replace "The", "A", "An"... to the left
	for j:=1 to PCount do
	begin
		i:=pos(', '+Prefixes[j], name);
		if i>0 then
			if (i = length(name)-length(Prefixes[j])-1) or
			(length(name) >= i+2+length(Prefixes[j])) and (name[i+2+length(Prefixes[j])]=':') then
			begin
				if Prefixes[j][length(Prefixes[j])] = '''' then
					name := Prefixes[j] + copy(name, 1, i-1) + copy(name, i+length(Prefixes[j])+2, length(name)-i-length(Prefixes[j])-2+1)
				else
					name := Prefixes[j]+' ' + copy(name, 1, i-1) + copy(name, i+length(Prefixes[j])+2, length(name)-i-length(Prefixes[j])-2+1);
				break;
			end;
	end;
	Result := name;
end;

function ClearExtraQuotes(name: string): string;
begin
	// Clears extra quotes «"»
	if length(name)>0 then
		if (name[1]='"') and (name[length(name)]='"') then
			name := copy(name,2,length(name)-2);
	Result := name;
end;

function ClearExtraBlankCharacters(text: string): string;
begin
	// Clear all extra blank charackters
	while (length(text) > 0) and (ord(text[1]) in [1..20, 32]) do
		delete(text, 1, 1);
	while (length(text) > 0) and (ord(text[length(text)]) in [1..20, 32]) do
		delete(text, length(text), 1);
	Result := text;
end;


function GetInfo(url: string; images_only: boolean): string;
var 
	keyword, s, s2, s3, plot_outline: string;
	season, episode: string;
	i, j, k, l: integer;
	pictures_exist: boolean;
	serie: boolean;
	season_nbr, episode_nbr: integer;
	AirDate, EpisodeTitle, EpisodeIMDB, EpisodeDescription, day, month, ayear: string;

begin
	result:='';
	BasicURL:=url;
	all:=DownloadURL(url);
	if all='-1' then
		result:='-1'
	else
		result:=all;
	
	//is it a serie ?
	serie:=false;
	i:=pos('fiche_serie.php',url);
	if (i>0) then
		serie:=true;
	
	movie_code:=ParseString(url, '=(\d+)', 1);
	movie_site_url:=BasicURL;  //GetMovieSiteURL(movie_code);
	
	//Movie title
	title:=ParseString(all, '<title>(.*?) - ', 1);
	title:=DecodeHTML(title);
	
	//Original title
	i:=pos('Titre original :', all);
	if i>0 then begin
		j:=MyPos('</tr>', all, i+1);
		//16 is the number of letters in the above expression
		s2:=copy(all, i+16, j-i-16);
		original_title:=RemoveTags(s2);
		original_title:=DecodeHTML(original_title);
		original_title:=ClearExtraSpaces(original_title);
	end;
	if original_title='' then
		original_title:=title;

	//Year
	if (serie) then begin
		txtpos:='<b>Crée en</b>';
		i:=pos(txtpos, all);
		if i>0 then begin
			j:=MyPos('</font>',all,i+1);
			year:=copy(all, i+length(txtpos), j-i+7);
			year:=ParseString(year, '>(.*?)</font>', 1);
			year:=copy(year,length(year)-3,4);
		end;
	end
	else begin
		txtpos:='Voir les films sortis à la même date en France';
		i:=pos(txtpos, all);
		if i>0 then begin
			year:=copy(all, i+length(txtpos), 50);
			year:=ParseString(year, '>(.*?)</a>', 1);
			year:=copy(year,length(year)-3,4);
		end;
	end;

	//Genre
	if (serie) then
		setGenre('Série');
	i:=pos('<b>Genre :</b>', all);
	if i>0 then begin
		j:=MyPos('</td></tr', all, i+1);
		s2:=copy(all, i, j-i);
		occurstart:='class="bodyFont2">';
		i:=pos(occurstart, s2);
		while i>0 do begin
			j:=pos('</a>', s2);
			s3:=copy(s2, i, j-i);
			name:=ParseString(s3, '>(.*?)$', 1);
			if name<>'' then begin
				name:=DecodeHTML(name);
				setGenre(name);
			end;
			delete(s2, 1, j+5);
			i:=pos(occurstart, s2);
		end;
	end;
	
	//countries
	s2:=ParseString(all, '<b>Pays :</b></td>.*?<td class="bodyfont" valign="top">(.*?)</td>', 1);
	if s2<>'' then begin
		s2:=RemoveTags(s2);
		i:=pos(',', s2);
		while i>0 do begin
			name:=copy(s2, 1, i-1);
			if name<>'' then begin
				name:=DecodeHTML(name);
				setCountry(name);
			end;
			if (name='américain') or (name='britannique') or (name='australien') then
				ask_amazon:=true;
			delete(s2, 1, i+1);
			i:=pos(',', s2);
		end;
		if s2<>'' then begin
			name:=DecodeHTML(s2);
			setCountry(name);
			if (name='américain') or (name='britannique') or (name='australien') then
				ask_amazon:=true;			
		end;
	end;

	//duration
	duration:=0;
	j:=0;         
	s2:=ParseString(all, '<b>Durée :</b></td><td .*?>(.*?)</td>', 1);
	s2:=RemoveTags(s2);
	s2:=copy(s2,1,length(s2));
	s3:=ParseString(s2, '^(\d+)h', 1);
	if s3<>'' then
		try
		//extract hours to j
		j:=StrToInt(s3);
		except
		end;
	//hours to minutes
	j:=j*60;
	s3:=ParseString(s2, 'h(\d+)', 1);
	if s3='' then
		//if the duration is less than an hour
		s3:=ParseString(s2, '^(\d+)min', 1);
	if s3<>'' then
		try
			duration:=StrToInt(s3);
		except
	end;
	duration:=duration+j;
	
	//Synopsis / description
	description := ParseString(all, 'L''histoire</h2>(.*?)<br />', 1);
	description:=RemoveTags(description);
	description:=DecodeHTML(description);
	description:=ClearExtraBlankCharacters(description);
	
	//small image
	if (serie) then
			i:=pos('serie_photos.php?serietv=', all)
	else
		i:=pos('fiche_affiches.php', all);
	if i>0 then begin
		j:=MyPos('alt=', all, i+1);
		s2:=copy(all, i, j-i);
		if s2<>'' then
			small_image:=ParseString(s2, '<img src="(.*?)"', 1);
	end;

	//check if the 'galerie' exists
	pictures_exist:=false;
	if (serie) then
		i:=pos('serie_photos.php?serietv=',all)
	else
		i:=pos('fiche_photos.php?IDfilm=', all);
	if i>0 then
		pictures_exist:=true;
	
	//if serie, download seasons/episodes page and extact infos
	if (serie) then begin
		url:='http://www.cinemovies.fr/serie_episodes.php?serietv='+movie_code;
		all:=DownloadURL(url);
		i:=pos('Saison n°',all);
		while i>0 do begin  //scan all seasons
			j:=MyPos('</font>', all, i+1);
			s2:=copy(all,i-3,j-i+10);
			season_nbr:=StrtoInt(ParseString(s2, '> Saison n°(\d+) <font', 1));
			year:=ParseString(s2, '<font.*?>.(.*?) .*?</font', 1);
			j:=MyPos('</table>', all, j);
			s2:=copy(all,i,j-i+10); //all episodes of one season in s2
			episode_nbr:=0;
			occurstart:='href="fiche_episode-';
			j:=Pos(occurstart,s2);
			while j>0 do begin  //scan all episodes of the examined season
				k:=MyPos('</td>', s2, j);
				s3:=copy(s2,j,k-j+5);
				EpisodeTitle:=ParseString(s3, '>(.*?)</a>', 1)+ParseString(s3, '</a>(.*?)</td>', 1);
				code:=ParseString(s3, 'fiche_episode-(.*?).html', 1);
				EpisodeIMDB:='http://www.cinemovies.fr/fiche_episode-'+code+'.html';
				AirDate:='01/01/'+year;  //format MM/DD/YYYY
				EpisodeDescription:='';
				{
				//download episode page for description
				url:='http://www.cinemovies.fr/fiche_episode-'+code+'.html';
				s3:=DownloadURL(url);
				k:=pos('Le résumé',s3);
				k:=MyPos('/></a></div>',s3,k);
				l:=MyPos('</div>',s3,k+15);
				s4:=copy(s3,k,l-k+10);
				EpisodeDescription:=ParseString(s3, '/></a></div>(.*?)</div>', 1);
				}
				episode_nbr:=episode_nbr+1;
				SetEpisode(season_nbr, episode_nbr, EpisodeTitle, EpisodeDescription, EpisodeIMDB, AirDate);
				j:=MyPos(occurstart,s2,j+10);
			end;
			i:=MyPos('Saison n°',all,i+10);
		end;
		description:=RemoveTags(description);
		description:=DecodeHTML(description);
		description:=ClearExtraSpaces(description);
	end;
	
	//download casting page
	if serie then begin
		i:=pos('serie_cast.php?serietv=', all);
		if (i>0) then begin
			url:='http://www.cinemovies.fr/serie_cast.php?serietv='+movie_code;
			all:=DownloadURL(url);
		end;
	end
	else begin
		i:=pos('fiche_cast.php?IDfilm=', all);
		if (i>0) then begin
			url:='http://www.cinemovies.fr/fiche_cast.php?IDfilm='+movie_code;
			all:=DownloadURL(url);
		end;	
	end;
	
	//Directors
	if (serie) then begin
		txtpos:='<b>Crée par</b>';
		i:=pos(txtpos, all);
	end
	else begin
		txtpos:='>Réalisé par<';
		i:=pos(txtpos, all);
	end;
	if i>0 then begin
		j:=MyPos('>Scénario de<', all, i+1);
		k:=MyPos('>Comédiens<', all, i+1);
		if (j=0) or (k<j) then
			j := k;			
		s2:=copy(all, i+length(txtpos), j-i-length(txtpos));
		occurstart:='href="perso-';
		i:=pos(occurstart, s2);
		while i>0 do begin
			j:=MyPos('</a>', s2, i+1);
			s3:=copy(s2, i, j-i+5);
			name:=ParseString(s3, '>(.*?)</a>', 1);
			if Pos('<img', name)>0 then
				name := '';
			name:=DecodeHTML(name);
			code:=ParseString(s3, 'href="perso-(.*?).html"', 1);
			if name<>'' then
				setPersonName(name, '', 1, code);
			delete(s2, 1, j);
			i:=pos(occurstart, s2);
		end;
	end;

	//Actors
	txtpos:='>Comédiens<';
	i:=pos(txtpos, all);
	if i>0 then begin
		j:=MyPos('>Scénario de<', all, i+1);
		k:=MyPos('>Distribution<', all, i+1);
		if (j=0) or (k<j) then
			j := k;
		if (j=0) then j:=MyPos('</table>', all, i+1);
		s2:=copy(all, i+length(txtpos), j-i-length(txtpos));
		occurstart:='href="perso-';
		i:=pos(occurstart, s2);
		while i>0 do begin
			j:=MyPos('</li>', s2, i+1);
			s3:=copy(s2, i, j-i);
			character:=ParseString(s3, 'class="dark-link-small">(.*?)</font></td>', 1);
			character:=RemoveTags(character);
			i:=pos('">',character);
			while i>0 do begin
				delete(character,1,i+1);
				i:=pos('">',character);
			end;	
			character:=DecodeHTML(character);
			code:=ParseString(s3, 'href="perso-(.*?).html"', 1);
			name:=ParseString(s3, '.html">(.*?)</a>', 1);
			if Pos('<img', name)>0 then
				name := '';
			name:=DecodeHTML(name);
			if name<>'' then
				setPersonName(name, character, 3, code);
			delete(s2, 1, j+10);
			i:=pos(occurstart, s2);
		end;
	end;
	
	//Screenplay writers
	txtpos:='>Scénario de<';
	i:=pos(txtpos, all);
	if i>0 then begin
		j:=MyPos('>Comédiens<', all, i+1);
		if (j=0) then j:=MyPos('</table>', all, i+1);
		s2:=copy(all, i+length(txtpos), j-i-length(txtpos));
		occurstart:='href=';
		i:=pos(occurstart, s2);
		while i>0 do begin
			j:=MyPos('</a>', s2, i+1);
			s3:=copy(s2, i, j-i+5);
			name:=ParseString(s3, '>(.*?)</a>', 1);
			if Pos('<img', name)>0 then
				name := '';
			name:=DecodeHTML(name);
			code:=ParseString(s3, 'href=''perso-(.*?).html''', 1);
			if name<>'' then
				setPersonName(name, '', 2, code);
			delete(s2, 1, j);
			i:=pos(occurstart, s2);
		end;
	end;
{	
	//Composers
	i:=pos('<h5>Compositeur</h5></td>', all);
	j:=MyPos('</tr>', all, i+1);
	s2:=copy(all, i, j-i);
	i:=pos('<a href="/personne/fichepersonne_gen_cpersonne=', s2);
	while i>0 do begin
		j:=MyPos('</a>', s2, i+1);
		s3:=copy(s2, i, j-i+5);
		code:=ParseString(s3, '<a href="/personne/fichepersonne_gen_cpersonne=(\d+).html', 1);
		name:=ParseString(s3, 'class="link1">(.*?)</a>', 1);
		name:=DecodeHTML(name);
		if name<>'' then
			setPersonName(name, '', 4, code);
		delete(s2, 1, j-1);
		i:=pos('<a href="/personne/fichepersonne_gen_cpersonne=', s2);
	end;
	
	//Studios
	i:=pos('<h5>Production</h5></td>', all);
	j:=MyPos('</table>', all, i+1);
	s2:=copy(all, i+24, j-i-24);
	i:=pos('<td width="50%" valign="top" style="padding:5 2 0 0"><h5>', s2);
	if i>0 then
		delete(s2, i, length(s2)-i);
	i:=pos('<h4><a href="/societe/fichesociete_gen_csociete=', s2);
	while i>0 do begin
		j:=MyPos('</a>', s2, i+1);
		s3:=copy(s2, i, j-i+5);
		name:=ParseString(s3, 'class="link1"><h4>(.*?)</h4></a>', 1);
		name:=DecodeHTML(name);
		if name<>'' then
			SetStudio(name);
		delete(s2, 1, j+4);
		i:=pos('<h4><a href="/societe/fichesociete_gen_csociete=', s2);
	end;
	
	//download page with images
	if pictures_exist then begin
		url:='http://www.cinemovies.fr/fiche_photos.php?IDfilm='+movie_code+'.html';
		all:=DownloadURL(url);
		front_cover_url:=ParseString(all, '<img id=''imgNormal'' class=''photo'' src=''(.*?)''', 1);
		s2:=ParseString(all, '<img id=''imgNormal'' class=''photo'' src=''.*?'' title="(.*?)" alt', 1);
		if (s2=title) then
			image_mode:=1
		else
			image_mode:=3;
	end;
}
end;

//returned images links
procedure GetImages;
var
	i: Integer;
begin
	if front_cover_url<>'' then
		SetImageName('', front_cover_url, '', image_mode);
	if ask_amazon then
		GetAmazonImages;
	if small_image<>'' then begin
		i := Pos('/Paff', small_image);
		if (i > 0) and DownloadMovieBigCover then
			small_image[i+1] := 'G';
		i := Pos('/AFFP', small_image);
		if (i > 0) and DownloadMovieBigCover then
			small_image[i+4] := 'G';
		i := Pos('/tn-', small_image);
		if (i > 0) and DownloadMovieBigCover then
			delete(small_image, i+1, 3);
		SetImageName('', small_image, '', 1);
	end;
	if MaxShotsCount > 1 then
		GetShots;
end;

procedure GetShots;
var
	i, j, k, img_cnt: Integer;
	s: String;
begin
	all := DownloadURL('http://www.cinemovies.fr/fiche_photos.php?IDfilm=' + movie_code);
	img_cnt := 0;
	i := Pos('http://www.cinemovies.fr/images/data/photos/', all);
	while (i>0) and (img_cnt < MaxShotsCount) do begin
		j := MyPos('"', all, i);
		s := copy(all, i, j-i);
		k := Pos('/tn-', s);
		if k > 0 then
			delete(s, k+1, 3);
		k := Pos('/PG', s);
		if k > 0 then
			delete(s, k+1, 1);
		k := Pos('/P', s);
		if k > 0 then
			s[k+1] := 'G';
		SetImageName('', s, '', 3);
		img_cnt := img_cnt + 1;
		delete(all, 1, j);
		i := Pos('http://www.cinemovies.fr/images/data/photos/', all);
	end;
end;

//get person site url
function GetPersonSiteURL(code: string): string;
begin
	if code='' then
		result:=''
	else
		result:='http://www.cinemovies.fr/perso-'+code+'.html';
end;

//get movie site url
function GetMovieSiteURL(code: string): string;
begin
	if code='' then
		result:=''
	else
		result:='hhttp://www.cinemovies.fr/fiche_film.php?IDfilm='+code;
end;

begin

prefixes[1]:='The';
prefixes[2]:='A';
prefixes[3]:='An';
prefixes[4]:='La';
prefixes[5]:='Les';
prefixes[6]:='Des';
prefixes[7]:='L''';
prefixes[8]:='Un';
prefixes[9]:='El';
prefixes[10]:='Il';
prefixes[11]:='Le';
prefixes[12]:='Uno';

end.