It currently retrieves translated title, category and link to trailer (goes in comments)
Title, picture, director, actors, year and country are commented off.
Code: Select all
// GETINFO SCRIPTING
// cinema.ptgate import with small picture
(***************************************************
* Movie importation script for: *
* http://cinema.ptgate.pt *
* *
* (c) 2003 Yorgul *
* *
* For use with Ant Movie Catalog 3.4.0 *
* www.ant.be.tf/moviecatalog ··· www.buypin.com *
* *
* The source code of the script can be used in *
* another program only if full credits to *
* script author and a link to Ant Movie Catalog *
* website are given in the About box or in *
* the documentation of the program *
***************************************************)
program PTGATE;
var
MovieName: string;
function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
var
i: Integer;
begin
result := -1;
if StartAt < 0 then
StartAt := 0;
for i := StartAt to List.Count-1 do
if Pos(Pattern, List.GetString(i)) <> 0 then
begin
result := i;
Break;
end;
end;
procedure AnalyzePage(Address: string);
var
Line, MovieItem, MovieTitle, MovieAddress: string;
TitlePos, BeginPos, EndPos, Found: Integer;
List: TStringList;
begin
Line := GetPage(Address);
PickTreeClear;
if Pos('encontrou 0 resultados', Line) = 0 then
begin
PickTreeAdd('Search results for "'+MovieName+'"', '');
BeginPos := Pos('pesquisa por título', Line);
EndPos := Pos('Anterior', Line);
Line := Copy(Line, BeginPos, EndPos - BeginPos);
List := TStringList.Create;
repeat
TitlePos := Pos('<a class=srch href=', Line);
if TitlePos > 0 then
begin
Found := 1;
Delete(Line, 1, TitlePos+19);
MovieAddress := 'http://cinema.ptgate.pt/' + Copy(Line, 1, Pos('>', Line)-2);
Delete(Line, 1, Pos('>', Line));
EndPos := Pos('</a><br>', Line) - 1;
MovieTitle := Copy(Line, 1, EndPos);
PickTreeAdd(MovieTitle, MovieAddress);
end;
until TitlePos = 0;
if Found = 0 then
begin
PickTreeAdd('No results found.', 'http://cinema.ptgate.pt/arquivo.php?pesquisa='+UrlEncode(MovieName));
end;
List.Free;
end;
if PickTreeExec(Address) then
AnalyzeMoviePage(Address);
end;
procedure AnalyzeMoviePage(Address: string);
var
Line, Value, FullValue, MovieAddress: string;
LineNr: Integer;
BeginPos, EndPos: Integer;
Page: TStringList;
begin
MovieAddress := Address;
Line := GetPage(Address);
BeginPos := Pos('<!-- main -->', Line);
EndPos := Pos('<!-- wall -->', Line);
Line := Copy(Line, BeginPos, EndPos - BeginPos);
// picture
// BeginPos := Pos('filmes/', Line);
// if BeginPos > 0 then
// begin
// Delete(Line, 1, BeginPos - 1);
// EndPos := Pos('.jpg', Line)+3;
// Value := 'http://cinema.ptgate.pt/' + (Copy(Line, 1, EndPos));
// GetPicture(Value, False);
// end;
// title
BeginPos := Pos('<b class=ttl>', Line);
Delete(Line, 1, BeginPos+17);
EndPos := Pos('</', Line);
Value := Copy(Line, 1, EndPos-1);
HTMLDecode(Value);
SetField(fieldOriginalTitle, Value);
// translatedtitle (PT)
BeginPos := Pos('<i class=subttl>', Line);
Delete(Line, 1, BeginPos+15);
EndPos := Pos('<', Line);
Value := Copy(Line, 1, EndPos - 1);
HTMLDecode(Value);
SetField(fieldTranslatedTitle, Value);
// Year
// BeginPos := Pos('Ano:', Line);
// Delete(Line, 1, BeginPos+41);
// EndPos := Pos('</', Line);
// Value := Copy(Line, 1, EndPos - 1);
// HTMLDecode(Value);
// SetField(fieldYear, Value);
// Country
// BeginPos := Pos('País:', Line);
// Delete(Line, 1, BeginPos+42);
// EndPos := Pos('</', Line);
// Value := Copy(Line, 1, EndPos - 1);
// HTMLDecode(Value);
// SetField(fieldCountry, Value);
// Category
BeginPos := Pos('Género:', Line);
Delete(Line, 1, BeginPos+44);
if Pos(' /', Line) = 0 then
begin
EndPos := Pos('</', Line);
end else
EndPos := Pos(' /', Line);
Value := Copy(Line, 1, EndPos - 1);
HTMLDecode(Value);
SetField(fieldCategory, trim(Value));
// Director
// BeginPos := Pos('Realizador:', Line);
// Delete(Line, 1, BeginPos+53);
// EndPos := Pos('</', Line);
// Value := Copy(Line, 1, EndPos - 4);
// HTMLDecode(Value);
// SetField(fieldDirector, Value);
// Actors
// BeginPos := Pos('Intérpretes:', Line);
// Delete(Line, 1, BeginPos+54);
// EndPos := Pos('</', Line);
// Value := Copy(Line, 1, EndPos - 4);
// HTMLDecode(Value);
// SetField(fieldActors, Value);
// URL
// BeginPos := Pos('Site oficial:', Line);
// Delete(Line, 1, BeginPos+13);
// BeginPos := Pos('size=2>', Line);
// Delete(Line, 1, BeginPos+6);
// EndPos := Pos('</', Line);
// Value := Copy(Line, 1, EndPos - 1);
// if Value = 'Não disponível' then
// else
// begin
// HTMLDecode(Value);
// MovieAddress := MovieAddress + ' ' + Value;
// end;
// SetField(fieldUrl, trim(MovieAddress));
// Trailer
BeginPos := Pos('Trailer:', Line);
Delete(Line, 1, BeginPos+8);
BeginPos := Pos('http://', Line);
EndPos := Pos('>[', Line)-2;
Value := Copy(Line, BeginPos, EndPos - BeginPos);
if pos('Não está disponível', Line) = 0 then
begin
HTMLDecode(Value);
if pos('Trailer: ', getfield(fieldComments)) = 0 then
SetField(fieldComments, 'Trailer: ' + Value + Chr(13) + Chr(10));
end;
DisplayResults;
end;
begin
if CheckVersion(3,4,0) then
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
if Input('Cinema.PTgate Import', 'Enter the title of the movie:', MovieName) then
begin
AnalyzePage('http://cinema.ptgate.pt/arquivo.php?pesquisa='+UrlEncode(MovieName));
end;
end else
ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
end.