Posted: 2013-04-26 08:40:41
Muchas gracias
Saludos
Saludos
Official Forum
https://forum.antp.be/phpbb3/
Añade ésta línea a la búsqueda de la carátula:Huginn wrote:Muchas gracias por el nuevo script.
¿Alguien sabe como modificarlo para que me descargue la versión pequeña de la carátula?
Gracias por adelantado ;-)
---------------------
Thanks a lot for the new script.
How can i modify the script to download the small cover?
Thanks in advance
Code: Select all
Item := StringReplace(Item, 'large', 'main');
Code: Select all
// 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>');
Item := StringReplace(Item, 'large', 'main');
GetPicture(Item);
end;
¡Va perfecto!juliojs wrote:Añade ésta línea a la búsqueda de la carátula:Huginn wrote:Muchas gracias por el nuevo script.
¿Alguien sabe como modificarlo para que me descargue la versión pequeña de la carátula?
Gracias por adelantado ;-)
---------------------
Thanks a lot for the new script.
How can i modify the script to download the small cover?
Thanks in advanceSi buscas "Picture" en el script lo encontrarás, esa parte tendría que quedar tal que así:Code: Select all
Item := StringReplace(Item, 'large', 'main');
Code: Select all
// 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>'); Item := StringReplace(Item, 'large', 'main'); GetPicture(Item); end;
Espero que te sirva.
Saludos!
What should be considered? The page numbers? With the "find more" button it is possible to go to the next page, but the script has to provide the URL for the next page and handle that propetly, maybe it is not the case of this script?AARON8888 wrote: I think this should be considered into next AMC version, doesn´t it?
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, juliojs
Title=FilmAffinity (ES)
Description=Movie importation script for FilmAffinity Spain
Site=http://www.filmaffinity.com
Language=ES
Version=2.66
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('siguientes >>', Page, 0);
if LineNr = -1 then
break;
Line := Page.GetString(LineNr);
Page.Text := GetPage('http://www.filmaffinity.com/es/search.php' + TextBetween(Line, '<a href="search.php', '"><div class="'));
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.
Thanks, I'll wait for confirmation from others and then I'll put it on the serverjuliojs wrote:@antp:
There was a bug in the script since the web design changed but we didn't notice it. Now it should work as spected, let a couple of users to confirm if it's working for them and then update it on the server if you like.
Thank you for your work, it's really an amazing application!!!