I tryed to do a script to a Brazilian site
Posted: 2004-12-31 12:13:58
Hi
I really liked AMC, it is the best catalogue prgram I´ve found. I am from Brazil and I saw that there is no script to any Brazilian page (often the translated title in Brazil is different from Portugal). I seached in the Internet and the best Brazilian page to get informations I´ve found seemed to be http://dvdworld.com.br. I tryed to do a script but the fact is that I don´t know Pascal at all, and of course I lost my patience.
I did a Frankenstain with the PTGATE script, it can get some informations but there is a lot of errors, someone who knows the language will take some minutes to fix it.
Thanks, and sorry, I also don´t know English.
// GETINFO SCRIPTING
// http://cinema.ptgate.pt/
// Script feito pelo O Guardião versão 1.0 Alpha 3
// 20-09-2004
(***************************************************
* For use with Ant Movie Catalog 3.4.0 *
* www.antp.be/software/moviecatalog *
* *
* 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 *
* *
* Please dont remove credits *
* Reportem os erros para bruno_mga@hotmail.com *
***************************************************)
program PTGate;
const
BaseAddress = 'http://dvdworld.com.br/dvdworld.hts';
ManualPictureSelect = True;
ExternalPictures = False;
DescriptionToImport = 2;
var
MovieName: string;
MovieURL: string;
function HTMLRemove(Value: String): String;
begin
HTMLDecode(Value);
HTMLRemoveTags(Value);
Value := Trim(Value);
result := Value;
end;
function UpFirstLetterWord(texto:string):string; //Function Made By O Guardião
var espaco:integer;
sst:string;
begin
texto:=AnsiUpFirstLetter(AnsiLowerCase(texto));
repeat
espaco:=Pos(' ',texto);
sst:=AnsiUpperCase(Copy(texto,espaco+1,1));
texto:=Copy(texto,1,espaco-1)+'/|\'+sst+Copy(texto,espaco+2,length(texto));
until Pos(' ',texto)=0;
texto := StringReplace(texto, '/|\', ' ');
if Copy(texto,1,1)=' ' then//se a 1º pos é espaço
texto:=Copy(texto,2,length(texto));
result:=texto;
end;
procedure AnalyzeFilmPage(Address: String);
var
Page : TStringList;
Line, Value : string;
LineNr, BeginPos, EndPos: Integer;
AllTitles: TStringList;
url_imdb:string;
nome_orig:string;
nome_trad:string;
ano:string;
pais:string;
genero:string;
realizac:string;
Interpretes:string;
descricao:string;
capa:string;
begin
Page := TStringList.Create;
value := 'http://216.247.85.101/images/'+Address+'.jpg';
// (it is working well)
GetPicture(Value, False);
Address:='http://dvdworld.com.br/dvdworld.hts?+'+Address+'+acha';
Page.Text := GetPage(Address);
SetField(fieldURL, Address);
//obter nome original do filme (it often also get the year and the country, but I didn´t figure how to trim it)
LineNr := FindLine('Título Original:', Page, 0);
if LineNr<>-1 then
begin
Value := Page.GetString(LineNr);
BeginPos := pos('/b>',value);
EndPos := pos('</f',value);
nome_orig:=copy(value,BeginPos+3,EndPos);
nome_orig:=HTMLRemove(nome_orig);
//ano (not working at all)
ano:=copy(nome_orig,length(nome_orig)-5,4);
SetField(fieldYear, ano);
SetField(fieldOriginalTitle, nome_orig);
end;
//obter nome traduzido (it has to cut some info of the DVD)
LineNr := FindLine('<td align="left" valign="top"><font face="Arial, Helvetica, sans-serif" size="4" color="#000066"><b>', Page, 0);
Value := Page.GetString(LineNr);
nome_trad:=HTMLRemove(Value);
nome_trad:=UpFirstLetterWord(nome_trad);
SetField(fieldTranslatedTitle, nome_trad);
//realização (it seems ok)
LineNr := FindLine('Diretor:</b>', Page, 0);
if LineNr<>-1 then
begin
Value := Page.GetString(LineNr);
BeginPos := pos('/b>',value);
EndPos := pos('</f',value);
realizac:=copy(value,BeginPos+3,EndPos);
realizac:=HTMLRemove(realizac);
SetField(fieldDirector, realizac);
end;
//Intérpretes (it seems ok)
LineNr := FindLine('Atores: </b>', Page, 0);
if LineNr<>-1 then
begin
Value := Page.GetString(LineNr);
BeginPos := pos('/b>',value);
EndPos := pos('</f',value);
Interpretes:=copy(value,BeginPos+3,EndPos);
Interpretes:=HTMLRemove(Interpretes);
SetField(fieldActors, Interpretes);
end;
//descrição (it seems ok)
LineNr := FindLine('<b>Sinopse:</b>', Page, 0);
if LineNr<>-1 then
begin
Value := Page.GetString(LineNr);
BeginPos := pos('/b>',value);
EndPos := pos('</f',value);
descricao:=copy(value,BeginPos+3,EndPos);
descricao:=HTMLRemove(descricao);
SetField(fieldDescription, descricao);
end;
end;
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
Page: TStringList;
LineNr, StartPos, EndPos: Integer;
Line: string;
x:integer;
MovieAddress, findMovieName,linedown : string;
guardar,url, nome_filme:string;
begin
PickTreeClear;
Page := TStringList.Create;
Page.Text := GetPage(Address);
if (pos('títulos que contém a palavra chave', Page.Text)>0) then //search portuguese
// need a report when the seach doesn´t have ant result
begin
LineNr :=0;
repeat
LineNr := FindLine('+acha', Page, LineNr);
If LineNr >0 Then Begin
Line := Page.GetString(LineNr);
StartPos := pos('hts?+', Line)+1;
url:=(copy(line,StartPos+4,7));
EndPos := pos('</A>',Line)-1;
Line := copy(Line, StartPos+18, EndPos);
Line:= HTMLRemove(Line);
nome_filme:=Line;
PickTreeAdd(nome_filme, url);
LineNr := LineNr + 1;
End;
until (LineNr<1);
if PickTreeExec(Address) then begin
AnalyzeFilmPage(Address);
end;
Page.Free;
end;
DisplayResults;
end;
begin
PickListClear;
MovieName := GetField(fieldOriginalTitle);
if Input('Importar do DVDWorld', 'Escreva o nome do filme:', MovieName) then begin
//espaço não são permitidos
MovieName := StringReplace(MovieName, ' ', '%20');
AnalyzePage('http://dvdworld.com.br/dvdworld.hts?+se ... e+'+titulo');
end;
end.
I really liked AMC, it is the best catalogue prgram I´ve found. I am from Brazil and I saw that there is no script to any Brazilian page (often the translated title in Brazil is different from Portugal). I seached in the Internet and the best Brazilian page to get informations I´ve found seemed to be http://dvdworld.com.br. I tryed to do a script but the fact is that I don´t know Pascal at all, and of course I lost my patience.
I did a Frankenstain with the PTGATE script, it can get some informations but there is a lot of errors, someone who knows the language will take some minutes to fix it.
Thanks, and sorry, I also don´t know English.
// GETINFO SCRIPTING
// http://cinema.ptgate.pt/
// Script feito pelo O Guardião versão 1.0 Alpha 3
// 20-09-2004
(***************************************************
* For use with Ant Movie Catalog 3.4.0 *
* www.antp.be/software/moviecatalog *
* *
* 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 *
* *
* Please dont remove credits *
* Reportem os erros para bruno_mga@hotmail.com *
***************************************************)
program PTGate;
const
BaseAddress = 'http://dvdworld.com.br/dvdworld.hts';
ManualPictureSelect = True;
ExternalPictures = False;
DescriptionToImport = 2;
var
MovieName: string;
MovieURL: string;
function HTMLRemove(Value: String): String;
begin
HTMLDecode(Value);
HTMLRemoveTags(Value);
Value := Trim(Value);
result := Value;
end;
function UpFirstLetterWord(texto:string):string; //Function Made By O Guardião
var espaco:integer;
sst:string;
begin
texto:=AnsiUpFirstLetter(AnsiLowerCase(texto));
repeat
espaco:=Pos(' ',texto);
sst:=AnsiUpperCase(Copy(texto,espaco+1,1));
texto:=Copy(texto,1,espaco-1)+'/|\'+sst+Copy(texto,espaco+2,length(texto));
until Pos(' ',texto)=0;
texto := StringReplace(texto, '/|\', ' ');
if Copy(texto,1,1)=' ' then//se a 1º pos é espaço
texto:=Copy(texto,2,length(texto));
result:=texto;
end;
procedure AnalyzeFilmPage(Address: String);
var
Page : TStringList;
Line, Value : string;
LineNr, BeginPos, EndPos: Integer;
AllTitles: TStringList;
url_imdb:string;
nome_orig:string;
nome_trad:string;
ano:string;
pais:string;
genero:string;
realizac:string;
Interpretes:string;
descricao:string;
capa:string;
begin
Page := TStringList.Create;
value := 'http://216.247.85.101/images/'+Address+'.jpg';
// (it is working well)
GetPicture(Value, False);
Address:='http://dvdworld.com.br/dvdworld.hts?+'+Address+'+acha';
Page.Text := GetPage(Address);
SetField(fieldURL, Address);
//obter nome original do filme (it often also get the year and the country, but I didn´t figure how to trim it)
LineNr := FindLine('Título Original:', Page, 0);
if LineNr<>-1 then
begin
Value := Page.GetString(LineNr);
BeginPos := pos('/b>',value);
EndPos := pos('</f',value);
nome_orig:=copy(value,BeginPos+3,EndPos);
nome_orig:=HTMLRemove(nome_orig);
//ano (not working at all)
ano:=copy(nome_orig,length(nome_orig)-5,4);
SetField(fieldYear, ano);
SetField(fieldOriginalTitle, nome_orig);
end;
//obter nome traduzido (it has to cut some info of the DVD)
LineNr := FindLine('<td align="left" valign="top"><font face="Arial, Helvetica, sans-serif" size="4" color="#000066"><b>', Page, 0);
Value := Page.GetString(LineNr);
nome_trad:=HTMLRemove(Value);
nome_trad:=UpFirstLetterWord(nome_trad);
SetField(fieldTranslatedTitle, nome_trad);
//realização (it seems ok)
LineNr := FindLine('Diretor:</b>', Page, 0);
if LineNr<>-1 then
begin
Value := Page.GetString(LineNr);
BeginPos := pos('/b>',value);
EndPos := pos('</f',value);
realizac:=copy(value,BeginPos+3,EndPos);
realizac:=HTMLRemove(realizac);
SetField(fieldDirector, realizac);
end;
//Intérpretes (it seems ok)
LineNr := FindLine('Atores: </b>', Page, 0);
if LineNr<>-1 then
begin
Value := Page.GetString(LineNr);
BeginPos := pos('/b>',value);
EndPos := pos('</f',value);
Interpretes:=copy(value,BeginPos+3,EndPos);
Interpretes:=HTMLRemove(Interpretes);
SetField(fieldActors, Interpretes);
end;
//descrição (it seems ok)
LineNr := FindLine('<b>Sinopse:</b>', Page, 0);
if LineNr<>-1 then
begin
Value := Page.GetString(LineNr);
BeginPos := pos('/b>',value);
EndPos := pos('</f',value);
descricao:=copy(value,BeginPos+3,EndPos);
descricao:=HTMLRemove(descricao);
SetField(fieldDescription, descricao);
end;
end;
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
Page: TStringList;
LineNr, StartPos, EndPos: Integer;
Line: string;
x:integer;
MovieAddress, findMovieName,linedown : string;
guardar,url, nome_filme:string;
begin
PickTreeClear;
Page := TStringList.Create;
Page.Text := GetPage(Address);
if (pos('títulos que contém a palavra chave', Page.Text)>0) then //search portuguese
// need a report when the seach doesn´t have ant result
begin
LineNr :=0;
repeat
LineNr := FindLine('+acha', Page, LineNr);
If LineNr >0 Then Begin
Line := Page.GetString(LineNr);
StartPos := pos('hts?+', Line)+1;
url:=(copy(line,StartPos+4,7));
EndPos := pos('</A>',Line)-1;
Line := copy(Line, StartPos+18, EndPos);
Line:= HTMLRemove(Line);
nome_filme:=Line;
PickTreeAdd(nome_filme, url);
LineNr := LineNr + 1;
End;
until (LineNr<1);
if PickTreeExec(Address) then begin
AnalyzeFilmPage(Address);
end;
Page.Free;
end;
DisplayResults;
end;
begin
PickListClear;
MovieName := GetField(fieldOriginalTitle);
if Input('Importar do DVDWorld', 'Escreva o nome do filme:', MovieName) then begin
//espaço não são permitidos
MovieName := StringReplace(MovieName, ' ', '%20');
AnalyzePage('http://dvdworld.com.br/dvdworld.hts?+se ... e+'+titulo');
end;
end.