The post change the characters.
in previous post change the string on line 57
change this ' for is '
then the script not run
Solucionado
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=Legrad
Title=AnimeFrozen(ES)
Description=cine
Site=www.frozen-layer.com
Language=es
Version=1.0
Requires=3.5.0
Comments=
License=
GetInfo=1
[Options]
***************************************************)
program AnimeFrozen;
var
MovieName: string;
MovieURL: string;
//---------------------------------------
function UpFirstLetterWord(texto:string):string;
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
texto:=Copy(texto,2,length(texto));
result:=texto;
end;
//------------------------------------------------------------------------------------
function BorraComillas(var S: string): string;
var
n,len, tag: Integer;
c: char;
t: String;
begin
tag := 0;
t := '';
len := length(s);
for n :=1 to len do
begin
c := Copy(s,n,1);
// quitamos las comillas
if c = '''' then
c := ' ';
t := t + c;
end
s := t;
result := t;
end;
//---------------------------------------------------------------------
function Acentos(str1: string) :string;
begin
str1 := StringReplace(str1, 'Ö' , 'Ö');
str1 := StringReplace(str1, 'ö' , 'ö');
str1 := StringReplace(str1, 'Ã' , 'À');
str1 := StringReplace(str1, 'É' , 'É');
str1 := StringReplace(str1, 'é' , 'é');
str1 := StringReplace(str1, 'Ã', 'Í');
str1 := StringReplace(str1, 'Ó' , 'Ó');
str1 := StringReplace(str1, 'Ñ' , 'Ñ');
str1 := StringReplace(str1, 'á' , 'à');
Str1 := StringReplace(Str1, ''', '');
Str1 := StringReplace(Str1, 'Ñ©', 'é');
Str1 := StringReplace(Str1, '&', '&');
Str1 := StringReplace(Str1, 'ó', 'ó');
Str1 := StringReplace(Str1, 'Ú', 'ú');
Str1 := StringReplace(Str1, 'ë', 'ë');
Str1 := StringReplace(Str1, '-', ' ');
Str1 := StringReplace(Str1, '()', '');
Str1 :=UpFirstLetterWord(Str1);
result := str1;
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;
//------------------------------------------------------------------------------------
function TextBetween(var S: string; StartTag: string; EndTag: string): string;
var
InitialPos: Integer;
begin
InitialPos := Pos(StartTag, S);
if InitialPos = 0 then
result := ''
else
begin
Delete(S, 1, InitialPos + Length(StartTag) - 1);
InitialPos := Pos(EndTag, S);
if InitialPos = 0 then
result := S
else
begin
result := copy(S, 1, InitialPos - 1);
Delete(S, 1, InitialPos + 1);
end;
end;
end;
//------------------------------------------------------------------------------------
function DeleteTags(var S: string): string;
var
n,len, tag: Integer;
c: char;
t: String;
begin
tag := 0;
t := '';
len := length(s);
for n :=1 to len do
begin
c := Copy(s,n,1);
if c = #9 then
c := ' ';
if(tag=1) then
begin
if(c='>') then tag := 0;
continue;
end
else
begin
if(c='<') then
begin
tag := 1;
continue;
end;
t := t + c;
end;
end
s := t;
result := t;
end;
//------------------------------------------------------------------------------------
procedure AnalyzePage(Address: string);
var
strPage, MovieAddr, MovieTitle, MovieDate, MovieID, Movie: string;
BeginPos, EndPos: Integer;
BeginPoss, EndPoss: Integer;
begin
strPage := GetPage(Address);
BeginPos := Pos('Resultado de la búsqueda', strPage);
if(BeginPos > -1)then
begin
PickTreeClear;
Delete(strPage, 1, BeginPos);
BeginPos := Pos('href="/infoanime/anime/', strPage);
EndPos := 1;
while ((BeginPos > 0) and (EndPos > 0)) do
begin
Delete(strPage, 1, BeginPos);
EndPos := Pos('" onmouseover', strPage);
MovieId := Copy(strPage,+23, EndPos-23);
MovieAddr := 'http://www.frozen-layer.com/infoanime/anime/' + MovieId;
BeginPoss := Pos('hideTooltip()"',strPage);
EndPoss := Pos('</li>', strPage);
MovieTitle := Copy(strPage,BeginPoss, EndPoss);
DeleteTags(MovieTitle);
MovieTitle := TextBetween (MovieTitle, '">', '</a>');
MovieTitle := Acentos(MovieTitle);
MovieTitle := StringReplace(MovieTitle , #13#10, '');
PickTreeAdd(MovieTitle, MovieAddr);
BeginPos := Pos('href="/infoanime/anime/', strPage);
if(Pos('</body>', strPage) < BeginPos) then
BeginPos := -1;
end;
end;
PickTreeExec(Address)
AnalyzeMoviePage(Address);
end;
//------------------------------------------------------------------------------------
procedure AnalyzeMoviePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
Line: string;
Item: string;
Comments: string;
Actors: string;
Directors: string;
Description: string;
begin
Comments := '';
Description := '';
// URL
SetField(fieldURL, Address);
Page := TStringList.Create;
Page.Text := GetPage(Address);
// Original
LineNr := FindLine('<h1 class="an">', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr);
Item := TextBetween (Line, '<h1 class="an">', '</h1>');
DeleteTags (Item);
HTMLDecode(Item);
Item :=UpFirstLetterWord(Item);
SetField(fieldOriginalTitle, Trim (Item));
end;
// Traducido
LineNr := FindLine('<li><strong>Título en castellano:</strong>', Page, 0);
Line := Page.GetString(LineNr);
Item := TextBetween (Line, '<li><strong>Título en castellano:</strong>', '</li>');
Item := StringReplace(Item, 'á', ',a');
Item := StringReplace(Item, 'é', 'é');
Item := StringReplace(Item, 'Ã', 'í');
Item := StringReplace(Item, 'ó', 'ó');
Item := StringReplace(Item, 'ó', 'ó');
Item := StringReplace(Item, 'ú', 'ú');
Item := StringReplace(Item, 'ú', 'ú');
Item :=UpFirstLetterWord(Item);
HTMLDecode(Item);
SetField(fieldTranslatedTitle, Trim (Item));
// Año
LineNr := FindLine('<li><strong>Año:', Page, 0);
if LineNr > 0 then
begin
Item := copy(Page.Text, pos('<li><strong>Año:',Page.Text), length(Page.Text));
Item := TextBetween (Item, '</strong> ', '</li>');
Item := StringReplace(Item , #13#10, '');
Item := StringReplace(Item , ' ', '');
DeleteTags (Item);
Item := Trim(Item );
SetField(fieldYear, Trim (Item));
end;
// Productor
LineNr := FindLine('<li><strong>Estudio:</strong>', Page, 0);
if LineNr > 0 then
begin
Item := copy(Page.Text, pos('<li><strong>Estudio:</strong>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<a href="#">', '</a></li>');
Item := StringReplace(Item , #13#10, '');
Item := StringReplace(Item , ' ', '');
DeleteTags (Item);
Item := AnsiUpFirstLetter(Item );
Item := Trim(Item );
SetField(fieldProducer, Trim (Item));
end;
// Género
LineNr := FindLine('<li><strong>Género:', Page, 0);
if LineNr > 0 then
begin
Item := copy(Page.Text, pos('<li><strong>Género:',Page.Text), length(Page.Text));
Item := TextBetween (Item, '</strong>', '</li>');
Item := StringReplace(Item , #13#10, '');
Item := StringReplace(Item , ' ', '');
DeleteTags (Item);
Item := AnsiUpFirstLetter(Item );
Item := Trim(Item );
HTMLDecode(Item);
SetField(fieldCategory, Trim (Item));
end;
// Sinopsis
LineNr := FindLine('<li><strong>Mostrada:</strong>', Page, 0);
if LineNr > 0 then
begin
Item := copy(Page.Text, pos('<li><strong>Mostrada:</strong>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<p class="desc">', '</p>');
Item := StringReplace(Item , #13#10, '');
Item := StringReplace(Item , ' ', '');
DeleteTags (Item);
Item := Trim(Item );
HTMLDecode(Item);
SetField(fieldDescription, Trim (Item));
end;
// Comentario1
LineNr := FindLine('<li><strong>Licenciada:</strong>', Page, 0);
if LineNr > 0 then
begin
Item := copy(Page.Text, pos('<li><strong>Licenciada:</strong>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '">', '</a></li>');
DeleteTags (Item);
Item := StringReplace(Item, 'á', ',a');
Item := StringReplace(Item, 'é', 'é');
Item := StringReplace(Item, 'Ã', 'í');
Item := StringReplace(Item, 'ó', 'ó');
Item := StringReplace(Item, 'ó', 'ó');
Item := StringReplace(Item, 'ú', 'ú');
Item := StringReplace(Item, 'ú', 'ú');
Item := Trim(Item );
HTMLDecode(Item);
Comments := Comments + 'Licenciada: ' + Item + #13#10;
end;
// Comentario2
LineNr := FindLine('<li><strong>Saga:</strong>', Page, 0);
if LineNr > 0 then
begin
Item := copy(Page.Text, pos('<li><strong>Saga:</strong>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '"">', '</a></li>');
DeleteTags (Item);
Item := Trim(Item );
HTMLDecode(Item);
Comments := Comments + 'Saga: ' + Item + #13#10;
end;
SetField(fieldComments, Comments);
// Picture
LineNr := FindLine('<div id="datlef"><img src="/infoanime/avatars/', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr);
Item := TextBetween (Line, '<div id="datlef"><img src="/infoanime/avatars/', '" class');
GetPicture ('http://www.frozen-layer.com/infoanime/avatars/'+Item);
end;
end;
//-------------------------------------------------------------------------
begin
if (CheckVersion(3,5,0)=FALSe) then
begin
ShowMessage('Se requiere Ant Movie Catalog versión 3.5 o superior');
exit;
end;
MovieName := GetField(fieldTranslatedTitle);
if MovieName = '' then
MovieName := GetField(fieldOriginalTitle);
Input('AnimeFrozen', 'Buscar:', MovieName);
if(GetOption('Sin resultado') = 0) then Input('AnimeFrozen', 'Buscar', MovieName);
AnalyzePage('http://www.frozen-layer.com/infoanime/busqueda/' + UrlEncode(MovieName));
end.