He visto que el script no funcionaba con los nuevos cambios en la web y me he tomado la libertad de editarlo.
Tan sólo he modificado un par de líneas y parece que ya funciona correctamente.
Os dejo el script completo. Un saludo!
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=aviloria (aviloria@yahoo.com) modded by: rodpedja (rodpedja@gmail.com), kreti (bisoft@hotmail.com), MrK, gilistico
Title=FilmAffinity (ES)
Description=Movie importation script for FilmAffinity Spain
Site=http://www.filmaffinity.com
Language=ES
Version=2.64
Requires=3.5.0
Comments=Updated to 2013/04/16 version of the web-page. Added an option to choose Actor list format (ActorsInALine).
License=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.|
GetInfo=1
RequiresMovies=1
[Options]
DontAsk=0|0|1=Método rápido: No te pregunta el titulo al principio, ni te pide confirmar si sólo hay un resultado|0=Método lento: Confirmas la información manualmente
ActorsInALine=0|0|1=Actores separados por comas|0=Actores en lineas independientes
[Parameters]
***************************************************)
program FilmAffinity;
const
BaseURL = 'http://www.filmaffinity.com';
var
MovieName: string;
MovieURL: 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;
//------------------------------------------------------------------------------------
function TextBetween(S: string; StartTag: string; EndTag: string): string;
var
ini, fin: Integer;
begin
Result := '';
ini := Pos(StartTag, S);
if ini <> 0 then
begin
ini := ini + Length(StartTag);
fin := Pos(EndTag, S);
if (fin <> 0) and (fin > ini) then
begin
Result := Copy(S, ini, fin - ini);
end;
end;
end;
//------------------------------------------------------------------------------------
function DeleteTags(S: string): string;
var
n, len, tag: Integer;
c, p: char;
begin
HTMLDecode(S);
len := Length(S);
tag := 0;
p := ' ';
Result := '';
for n := 1 to len do
begin
c := Copy(S,n,1);
// Eliminamos los tabuladores
if c = #9 then c := ' ';
// Los espacios redundantes no se procesan
if (c <> ' ') or (p <> ' ') then
begin
// Eliminamos los tags de HTML
if tag = 0 then
begin
if c <> '<' then
begin
Result := Result + c;
p := c;
end
else tag := 1;
end
else if c = '>' then tag := 0;
end;
end
if p = ' ' then Result := Copy(Result, 1, Length(Result) - 1);
end;
//------------------------------------------------------------------------------------
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
Line: string;
Count: Integer;
MovieTitle, MovieAddress: string;
begin
Count := 0;
Page := TStringList.Create;
Page.Text := GetPage(Address);
PickTreeClear;
// Get how much search results have been found
LineNr := FindLine('</strong> resultados.</div>', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr);
Count := StrToInt(TextBetween(Line, '<div style="text-align:right;"><strong>', '</strong> resultados.</div>'), 0);
end;
// Add the results to the PickTree
if Count = 0 then
ShowMessage('No se ha encontrado ningún registro')
else
begin
LineNr := 0;
while true do
begin
LineNr := FindLine('<div class="mc-title"><a href="', Page, LineNr + 1);
if LineNr = -1 then
begin
LineNr := FindLine('<b>siguientes >></b>', Page, 0);
if LineNr = -1 then
break;
Line := Page.GetString(LineNr);
Page.Text := GetPage(TextBetween(Line, '<a href="', '">'));
LineNr := 0;
continue;
end;
Line := Page.GetString(LineNr);
MovieAddress := TextBetween(Line, '<div class="mc-title"><a href="', '.html">') + '.html';
MovieTitle := DeleteTags(TextBetween(Line, '.html">', '<img src="'));
if (Length(MovieAddress) <> 0) and (Length(MovieTitle) <> 0) then
PickTreeAdd(MovieTitle, BaseURL + MovieAddress);
end;
if ((Count = 1) and (GetOption('DontAsk') = 1)) or PickTreeExec(Address) then
AnalyzeMoviePage(Address);
end;
Page.Free;
end;
//------------------------------------------------------------------------------------
procedure AnalyzeMoviePage(Address: string);
var
Page: TStringList;
LineNr, LineInc: Integer;
Line: string;
Item: string;
Comments: string;
begin
Comments := '';
// URL
SetField(fieldURL, Address);
Page := TStringList.Create;
Page.Text := GetPage(Address);
// Translated Title
LineNr := FindLine('<h1 id="main-title">', Page, 0);
Line := Page.GetString(LineNr);
Item := DeleteTags(TextBetween(Line, '<h1 id="main-title">', '</h1>'));
SetField(fieldTranslatedTitle, Item);
// Picture
LineNr := FindLine('http://pics.filmaffinity.com/', Page, LineNr);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr);
Item := TextBetween(Line, '<a class="lightbox" href="', '" title="');
if Length(Item) = 0 then
Item := TextBetween(Line, '" src="', '"></a>');
GetPicture(Item);
end;
// Rating
LineNr := FindLine('<div id="movie-rat-avg">', Page, LineNr);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := DeleteTags(Line);
SetField(fieldRating, StringReplace(Item, ',', '.'));
end;
// Original Title
LineNr := FindLine('<dt>Título original</dt>', Page, LineNr);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := DeleteTags(TextBetween(Line, '<dd>', '</dd>'));
SetField(fieldOriginalTitle, Item);
end;
// Year
LineNr := FindLine('<dt>Año</dt>', Page, LineNr);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := DeleteTags(TextBetween(Line, '<dd>', '</dd>'));
SetField(fieldYear, Item);
end;
// Length
LineNr := FindLine('<dt>Duración</dt>', Page, LineNr);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := DeleteTags(TextBetween(Line, '<dd>', 'min.</dd>'));
SetField(fieldLength, Item);
end;
// Country
LineNr := FindLine('<dt>País</dt>', Page, LineNr);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := DeleteTags(TextBetween(Line, 'title="', '" border'));
SetField(fieldCountry, Item);
end;
// Director
LineNr := FindLine('<dt>Director</dt>', Page, LineNr);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := DeleteTags(TextBetween(Line, '<dd>', '</dd>'));
SetField(fieldDirector, Item);
end;
// Script writer
LineNr := FindLine('<dt>Guión</dt>', Page, LineNr);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := TextBetween(Line, '<dd>', '</dd>');
Comments := Comments + 'Guión: ' + Item + #13#10 + #13#10;
end;
// Composer
LineNr := FindLine('<dt>Música</dt>', Page, LineNr);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := TextBetween(Line, '<dd>', '</dd>');
Comments := Comments + 'Música: ' + Item + #13#10 + #13#10;
end;
// Photography
LineNr := FindLine('<dt>Fotografía</dt>', Page, LineNr);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := TextBetween(Line, '<dd>', '</dd>');
Comments := Comments + 'Fotografía: ' + Item + #13#10 + #13#10;
end;
// Actors
LineNr := FindLine('<dt>Reparto</dt>', Page, LineNr);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := DeleteTags(TextBetween(Line, '<dd>', '</dd>'));
if GetOption('ActorsInALine') = 0 then Item := StringReplace(Item, ', ', #13#10);
SetField(fieldActors, Item);
end;
// Productor
LineNr := FindLine('<dt>Productora</dt>', Page, LineNr);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := DeleteTags(TextBetween(Line, '<dd>', '</dd>'));
SetField(fieldProducer, Item);
end;
// Category
LineNr := FindLine('<dt>Género</dt>', Page, LineNr);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 2);
Item := DeleteTags(Line);
Item := StringReplace(Item, ' | ', ', ');
Item := StringReplace(Item, '. ', ', ');
SetField(fieldCategory, Item);
end;
// Official Webpage
LineNr := FindLine('<dt>Web Oficial</dt>', Page, LineNr);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := DeleteTags(TextBetween(Line, ' href="', '">'));
Comments := Comments + 'Web oficial: ' + Item + #13#10 + #13#10;
end;
// Synopsis
LineNr := FindLine('<dt>Sinopsis</dt>', Page, LineNr);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := DeleteTags(Line);
SetField(fieldDescription, Item);
end;
// Awards
LineNr := FindLine('<dt>Premios</dt>', Page, LineNr);
if LineNr <> -1 then
begin
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
Comments := Comments + 'Premios: ' + #13#10;
while Pos ('</dd>', Line) = 0 do
begin
if Pos ('<span id="show-all-awards">', Line) = 0 then
begin
Item := DeleteTags(Line);
if (Length(Item) <> 0) then
begin
Comments := Comments + ' - ' + Item + #13#10;
end;
end;
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
end;
Comments := Comments + #13#10;
end;
// Critic
LineNr := FindLine('<dt>Críticas</dt>', Page, LineNr);
if LineNr <> -1 then
begin
Comments := Comments + 'Críticas: ' + #13#10 + #13#10;
LineNr := FindLine('<div class="pro-review">', Page, LineNr + 1);
while LineNr <> -1 do
begin
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
LineInc := 2;
if Pos ('<a title="Leer crítica completa" href=', Line) <> 0 then
begin
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
LineInc := 3;
end;
Item := DeleteTags(Line);
if (Length(Item) <> 0) then
begin
Comments := Comments + Item + #13#10;
LineNr := LineNr + LineInc;
Line := Page.GetString(LineNr);
Item := DeleteTags(Line);
if (Length(Item) <> 0) then
begin
Comments := Comments + Item + #13#10;
end;
Comments := Comments + '________________________________________' + #13#10 + #13#10;
end;
LineNr := FindLine('<div class="pro-review">', Page, LineNr + 1);
end;
end;
HTMLDecode(Comments);
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(fieldOriginalTitle);
if Length(MovieName) = 0 then
MovieName := GetField(fieldTranslatedTitle);
if GetOption('DontAsk') = 0 then
Input('FilmAffinity', 'Pelicula:', MovieName);
if Pos('filmaffinity.com', MovieName) > 0 then
AnalyzeMoviePage(MovieName)
else
AnalyzePage(BaseURL +'/es/search.php?stext=' + UrlEncode(MovieName) + '&stype=Title');
end.