No entiendo los problemas del script Filmaffinity, la verdad que yo uso mi propio script desde hace un par de años y solo he visto una actualizacion de la web la cual la hicieron hara ya un año, solo he retocado mi script en una ocasion que yo recuerde, el film "Sophie Scholl: los últimos días" que se comenta en el foro yo la encuentro sin problemas, los problemas mencionados en ocasiones por el campo país u otros la verdad a mi nunca me ha pasado. No pretendo molestar a otros compañeros que hacen scripts, pero para el que le pueda interesar este es mi script
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=Legrad
Title=Filmaffinity
Description=
Site=www.filmaffinity.com
Language=ES
Version=1.1
Requires=3.5.0
Comments=
License=
GetInfo=1
[Options]
***************************************************)
program filmaffinity;
var
MovieName: string;
MovieURL: string;
//------------------------------------------------------------------------------------
function Caracter(str1: string) :string;
begin
str1 := StringReplace(str1, 'á' , 'à');
str1 := StringReplace(str1, 'é' , 'é');
str1 := StringReplace(str1, 'Ã', 'í');
Str1 := StringReplace(Str1, 'ó', 'ó');
str1 := StringReplace(str1, 'ú' , 'ú');
str1 := StringReplace(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('resultados.</b></td></tr>', strPage);
if(BeginPos > -1)then
begin
PickTreeClear;
Delete(strPage, 1, BeginPos);
BeginPos := Pos('<b><a href="/es/film', strPage);
EndPos := 1;
while ((BeginPos > 0) and (EndPos > 0)) do
begin
Delete(strPage, 1, BeginPos);
EndPos := Pos('.html', strPage);
MovieId := Copy(strPage,+20, EndPos-20);
MovieAddr := 'http://www.filmaffinity.com/es/film' + MovieId+'.html';
BeginPoss := Pos('">',strPage);
EndPoss := Pos('<img src=', strPage);
MovieTitle := Copy(strPage,BeginPoss, EndPoss);
MovieTitle := TextBetween(MovieTitle , '">', '<img');
DeleteTags(MovieTitle);
PickTreeAdd(MovieTitle, MovieAddr);
PickTreeSort;
BeginPos := Pos('<b><a href="/es/film', 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;
Busca: integer;
begin
Description := '';
Comments := '';
SetField(fieldURL, Address);
Page := TStringList.Create;
Page.Text := GetPage(Address);
// Titulo traducido
LineNr := FindLine('<title>', Page, 0);
Line := Page.GetString(LineNr);
Item := TextBetween (Line, '<title>', '(');
HTMLDecode(Item);
Item := Caracter(Item);
SetField(fieldTranslatedTitle, Trim (Item));
// Titulo Original
LineNr := FindLine('TULO ORIGINAL</th>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('TULO ORIGINAL</th>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<strong>', '</strong>');
HTMLDecode(Item);
Item := Caracter(Item);
SetField(fieldOriginalTitle, Trim (Item));
end;
// año
LineNr := FindLine('<title>', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr);
Item := TextBetween (Line, '(', ')');
DeleteTags (Item);
HTMLDecode(Item);
SetField(fieldYear, Trim (Item));
end;
// Duracion
LineNr := FindLine('<th>DURACI', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<th>DURACI',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<th>DURACI', '<tr>');
Item := TextBetween (Item, '</div>', 'min.');
Item := StringReplace (Item, #13#10, '');
HTMLDecode(Item);
SetField(fieldLength, Trim (Item));
end;
// pais
LineNr := FindLine('imgs/countries/', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('imgs/countries/',Page.Text), length(Page.Text));
Item := TextBetween (Item, 'title="', '"');
HTMLDecode(Item);
Item := Caracter(Item);
SetField(fieldCountry, Trim (Item));
end;
// director
LineNr := FindLine('<th>DIRECTOR</th>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<th>DIRECTOR</th>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '/search.php?stype=director&stext=', '</a></td>');
Item := TextBetween (Item, '">', '');
HTMLDecode(Item);
Item := Caracter(Item);
SetField(fieldDirector, Trim (Item));
end;
// Reparto
LineNr := FindLine('<th>REPARTO</th>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<th>REPARTO</th>',Page.Text), length(Page.Text));
Item := TextBetween (Item, 'search.php?stype=cast&stext=', '</a></td>');
Item := TextBetween (Item, '">', '');
HTMLDecode(Item);
DeleteTags (Item);
Item := Caracter(Item);
SetField(fieldActors, Trim (Item));
end;
// productor
LineNr := FindLine('<th>PRODUCTORA</th>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<th>PRODUCTORA</th>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<td>', '</td>');
HTMLDecode(Item);
DeleteTags (Item);
Item := Caracter(Item);
SetField(fieldProducer, Trim (Item));
end;
// Categoria
LineNr := FindLine('NERO</th>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('NERO</th>',Page.Text), length(Page.Text));
Item := TextBetween (Item, 'style="text-decoration:none">', '|');
Item := StringReplace (Item, '.', ', ');
Item := StringReplace (Item, ' ', '');
HTMLDecode(Item);
DeleteTags (Item);
Item := Caracter(Item);
SetField(fieldCategory, Trim (Item));
end;
// sinopsis
LineNr := FindLine('<th>SINOPSIS</th>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<th>SINOPSIS</th>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<td>', '(FILMAFFINITY)');
HTMLDecode(Item);
DeleteTags (Item);
Item := Caracter(Item);
SetField(fieldDescription, Trim (Item));
end;
// Calificación
LineNr := FindLine('<div style="margin: 4px 0; color:#990000; font-size:22px; font-weight: bold;">', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<div style="margin: 4px 0; color:#990000; font-size:22px; font-weight: bold;">',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<div style="margin: 4px 0; color:#990000; font-size:22px; font-weight: bold;">', '</div>');
HTMLDecode(Item);
DeleteTags (Item);
SetField(fieldRating, Trim (Item));
end;
// Guión
LineNr := FindLine('<th>GUI', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<th>GUI',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<td>', '</td>');
HTMLDecode(Item);
DeleteTags (Item);
Item := Caracter(Item);
Comments := Comments + 'Guión: ' + Item +#13#10;
end;
// fotografia
LineNr := FindLine('<th>FOTOGRAF', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<th>FOTOGRAF',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<td>', '</td>');
HTMLDecode(Item);
DeleteTags (Item);
Item := Caracter(Item);
Comments := Comments + 'Fotografía: ' + Item +#13#10;
end;
// Musica
LineNr := FindLine('SICA</th>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('SICA</th>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<td>', '</td>');
HTMLDecode(Item);
DeleteTags (Item);
Item := Caracter(Item);
Comments := Comments + 'Música: ' + Item +#13#10#13#10;
end;
// Critica
LineNr := FindLine('TICAS</th>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('TICAS</th>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<td>', '</td>');
HTMLDecode(Item);
DeleteTags (Item);
Item := StringReplace(Item, '-', '');
Item := StringReplace(Item, ' ', '');
Item := StringReplace(Item, ' ', '');
Item := StringReplace(Item, ' ', '');
Item := Caracter(Item);
Comments := Comments + 'CRITICAS: ' + Item +#13#10;
end;
// Caratula
LineNr := FindLine('src="/images/enlarge.gif"', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('src="/images/enlarge.gif"',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<a class="lightbox" href="http://pics.filmaffinity.com/', '.jpg');
HTMLDecode(Item);
GetPicture ('http://pics.filmaffinity.com/'+Item+'.jpg');
end;
SetField(fieldComments, Comments);
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('Filmaffinity', 'Buscar:', MovieName);
if(GetOption('Sin resultado') = 0) then Input('Filmaffinity', 'Buscar:', MovieName);
AnalyzePage('http://www.filmaffinity.com/es/search.php?stext=' + UrlEncode(MovieName) + '&stype=Title');
end.