[ES] Script en español para FilmAffinity
Well, I'm having problems with the last modification made by rodpedja. If I look for 'amor' the script does nothing, seems to hang and I have to stop it. Nevertheless, if I use aviloria's one (the last modification posted in this thread) it works OK and shows the correct titles. ??
Regards.
Español: Bueno, tengo problemas con la última modificación hecha por rodpedja. Si busco 'amor' el script no hace nada, parece colgarse y tengo que pararlo. Sin embargo, si uso el de aviloria (la última modificación posteada en este hilo), funciona OK y muestra los títulos correctos. ??
Saludos.
Regards.
Español: Bueno, tengo problemas con la última modificación hecha por rodpedja. Si busco 'amor' el script no hace nada, parece colgarse y tengo que pararlo. Sin embargo, si uso el de aviloria (la última modificación posteada en este hilo), funciona OK y muestra los títulos correctos. ??
Saludos.
Juanra
Replace in the script, the AnalyzePage procedure with the next code:
The latest script published crashes when
MovieTitle := TextBetween (Line, '.html">', '</a>');
is '' (nothing, didn't find it)
With my modified code, it asks that issue and depending on its values does something or it doesn't. So now it doesn't crash.
Now it works, but i think that script doesn't process correctly the page-result of searching, perhaps some minor changes on filmaffinity web page.
Regards, folgui.
Replace in the script, the AnalyzePage procedure with the next code:
Code: Select all
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
Line: string;
Count: Integer;
MovieTitle, MovieAddress: string;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
if Pos('<title>Busqueda de "', Page.Text) = 0 then
begin
ShowMessage('No se ha podido establecer la conexion.');
end else
begin
LineNr := FindLine('resultados.</b></td></tr>', Page, 0);
Line := Page.GetString(LineNr);
Count := StrToInt(TextBetween (Line, '<b>', ' resultados.</b>'), 0);
if Count = 0 then
begin
ShowMessage('No se han encontrado resultados para "' + MovieName + '"');
end else
begin
PickTreeClear;
PickTreeAdd('Encontrados ' + IntToStr(Count) + ' resultados para "' + MovieName + '"', '');
LineNr := LineNr + 7;
Line := Page.GetString(LineNr);
repeat
MovieTitle := TextBetween (Line, '.html">', '</a>');
if MovieTitle <> '' then
begin
HTMLDecode(MovieTitle);
Line := Page.GetString(LineNr);
MovieAddress := TextBetween (Line, '<b><a href="', '">');
PickTreeAdd(MovieTitle, BaseURL1 + MovieAddress);
end;
LineNr := LineNr + 10;
Line := Page.GetString(LineNr);
until Pos('</table>', Line) > 0;
if PickTreeExec(Address) then
AnalyzeMoviePage(Address);
end;
end;
Page.Free;
end;
MovieTitle := TextBetween (Line, '.html">', '</a>');
is '' (nothing, didn't find it)
With my modified code, it asks that issue and depending on its values does something or it doesn't. So now it doesn't crash.
Now it works, but i think that script doesn't process correctly the page-result of searching, perhaps some minor changes on filmaffinity web page.
Regards, folgui.
To fix year problem replace in the "AnalyzeMoviePage" procedure the code of year with the next one:
Change is in the first line after "begin", before was "LineNr+1" and now in the returned page, seems to be "LineNr+3".
Regards, folgui
Code: Select all
// Year
LineNr := FindLine('AÑO', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 3);
Item := TextBetween (Line, '<td >', '</td>');
HTMLDecode(Item);
SetField(fieldYear, Trim (Item));
end;
Regards, folgui
Hello!
antp, i've already sent it to you by email.
By the way i'm going to post it here for anyone interested in it.
Regards, folgui.
antp, i've already sent it to you by email.
By the way i'm going to post it here for anyone interested in it.
Regards, folgui.
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)
Title=FilmAffinity (ES)
Description=Movie importation script for FilmAffinity Spain
Site=http://www.filmaffinity.com
Language=ES
Version=1.25
Requires=3.5.0
Comments=Updated to the new beta version of the page | Previous version is unsupported.
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
[Options]
***************************************************)
program FilmAffinity;
const
SearchBaseURL = 'http://new.filmaffinity.com/es/res.php?stext=';
SearchPostFix = '&stype=tit';
BaseURL1 = 'http://new.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(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;
//------------------------------------------------------------------------------------
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
Line: string;
Count: Integer;
MovieTitle, MovieAddress: string;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
if Pos('<title>Busqueda de "', Page.Text) = 0 then
begin
ShowMessage('No se ha podido establecer la conexion.');
end else
begin
LineNr := FindLine('resultados.</b></td></tr>', Page, 0);
Line := Page.GetString(LineNr);
Count := StrToInt(TextBetween (Line, '<b>', ' resultados.</b>'), 0);
if Count = 0 then
begin
ShowMessage('No se han encontrado resultados para "' + MovieName + '"');
end else
begin
PickTreeClear;
PickTreeAdd('Encontrados ' + IntToStr(Count) + ' resultados para "' + MovieName + '"', '');
LineNr := LineNr + 7;
Line := Page.GetString(LineNr);
repeat
MovieTitle := TextBetween (Line, '.html">', '</a>');
if MovieTitle <> '' then
begin
HTMLDecode(MovieTitle);
Line := Page.GetString(LineNr);
MovieAddress := TextBetween (Line, '<b><a href="', '">');
PickTreeAdd(MovieTitle, BaseURL1 + MovieAddress);
end;
LineNr := LineNr + 10;
Line := Page.GetString(LineNr);
until Pos('</table>', Line) > 0;
if PickTreeExec(Address) then
AnalyzeMoviePage(Address);
end;
end;
Page.Free;
end;
//------------------------------------------------------------------------------------
procedure AnalyzeMoviePage(Address: string);
var
Page: TStringList;
LineNr, aux: Integer;
Line: string;
Item: string;
Comments: string;
Actors: string;
Directors: string;
begin
Comments := '';
Actors := '';
// URL
SetField(fieldURL, Address);
Page := TStringList.Create;
Page.Text := GetPage(Address);
// Translated Title
LineNr := FindLine('<div style="margin-bottom: 4; padding:1; text-align: left; border-bottom: 1px solid #990000;"><span style="color:#990000; font-size:16; font-weight: bold;">', Page, 0);
Line := Page.GetString(LineNr);
Item := TextBetween (Line, ' border="0"> ', '</span>');
HTMLDecode(Item);
SetField(fieldTranslatedTitle, Trim (Item));
// Original Title
LineNr := FindLine('TITULO ORIGINAL', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := TextBetween (Line, '<td ><b>', '</b></td>');
HTMLDecode(Item);
SetField(fieldOriginalTitle, Trim (Item));
end;
// Picture
LineNr := FindLine('owned by Studio', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr);
Item := TextBetween (Line, '<img src="', '">');
if Pos (BaseURL1, Item) <> 0 then
Item := TextBetween (Item, BaseURL1, '"');
GetPicture (BaseURL1 + Item);
end;
// Year
LineNr := FindLine('AÑO', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 3);
Item := TextBetween (Line, '<td >', '</td>');
HTMLDecode(Item);
SetField(fieldYear, Trim (Item));
end;
// Length
LineNr := FindLine('DURACIÓN', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := TextBetween (Line, '<td >', ' min.</td>');
HTMLDecode(Item);
SetField(fieldLength, Trim (Item));
end;
// Country
LineNr := FindLine('PAÍS', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := TextBetween (Line, 'alt="', '" border');
HTMLDecode(Item);
SetField(fieldCountry, Trim (Item));
end;
// Director
LineNr := FindLine('DIRECTOR', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Directors := '';
while Pos ('stype=director', Line) > 0 do
begin
Item := TextBetween (Line, '">', '</a>');
HTMLDecode(Item);
if Directors = '' then
Directors := Item
else
Directors := Directors + ', ' + Item;
end;
SetField(fieldDirector, Trim (Directors));
end;
// Script writer
LineNr := FindLine('GUIÓN', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := TextBetween (Line, '<td >', '</td>');
Comments := Comments + 'Guión: ' + Item + #13#10;
end;
// Composer
LineNr := FindLine('MUSICA', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := TextBetween (Line, '<td >', '</td>');
Comments := Comments + 'Música: ' + Item + #13#10;
end;
// Photography
LineNr := FindLine('FOTOGRAFÍA', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := TextBetween (Line, '<td >', '</td>');
Comments := Comments + 'Fotografía: ' + Item + #13#10;
end;
// Actors
LineNr := FindLine('REPARTO', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Actors := TextBetween (Line, '">', '</a>') + #13#10;
while Pos ('stype=cast', Line) > 0 do
Actors := Actors + TextBetween (Line, '"> ', '</a>') + #13#10;
HTMLDecode(Actors);
SetField(fieldActors, Actors);
end;
// Productor
LineNr := FindLine('PRODUCTORA', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Item := TextBetween (Line, '<td >', '</td>');
HTMLDecode(Item);
SetField(fieldProducer, Trim (Item));
end;
// Genere & Critic
LineNr := FindLine('GÉNERO Y CRÍTICA', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
HTMLDecode(Line);
Item := TextBetween (Line, '<td >', '</td>');
if Pos (' / ', Item) <> 0 then
begin
Line := Item;
Item := Copy (Item, 1, Pos (' / ', Item));
Line := TextBetween (Line, ' / ', '<br />');
if Pos (' / ', Line) <> 0 then
begin
Comments := Comments + Item + #13#10;
Item := Line;
Item := Copy (Item, 1, Pos (' / ', Item));
Line := TextBetween (Line, ' / ', '</td>');
SetField(fieldCategory, Trim(Item));
SetField(fieldDescription, Line);
end
else
begin
SetField(fieldCategory, Trim(Item));
SetField(fieldDescription, Line);
end
end
else
SetField(fieldCategory, Trim(Item));
end;
// Official Webpage
LineNr := FindLine('WEB OFICIAL', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
Comments := Comments + 'Web oficial: ' + TextBetween (Line, '<a href="', '" target="_blank">') + #13#10;
end;
// Rating
LineNr := FindLine('<td align="center" style="color:#990000; font-size:22px; font-weight: bold;">', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr);
Item := TextBetween (Line, '<td align="center" style="color:#990000; font-size:22px; font-weight: bold;">', '</td>');
HTMLDecode(Item);
SetField(fieldRating, Item);
end;
HTMLDecode(Comments);
SetField(fieldComments, Comments);
end;
//------------------------------------------------------------------------------------
begin
if CheckVersion(3,5,0) then
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
if Input('Importar de FilmAffinity', 'Introduzca el titulo de la pelicula:', MovieName) then
begin
AnalyzePage(SearchBaseURL + UrlEncode(MovieName) + SearchPostfix);
end;
end
else
ShowMessage('Este script requiere una version mas reciente de Ant Movie Catalog (por lo menos la version 3.5.0)');
end.
Las búsquedas no suelen funcionar si contienen más de una palabra, pero si funcionan si pones una sola de las palabras del título.
Por ejemplo, para buscar "El cielo de Octubre", probar a poner "octubre", y si saldrá. Mientras no haya alguien que lo arregle valdrá.
He modificado uno de los scripts posteados aquí para que incorpore toda la infomación que aparece en "GÉNERO Y CRÍTICA" y no solo la sinopsis de Filmaffinity. Si a alguien le interesa, que coja, que es gratis.
Por ejemplo, para buscar "El cielo de Octubre", probar a poner "octubre", y si saldrá. Mientras no haya alguien que lo arregle valdrá.
He modificado uno de los scripts posteados aquí para que incorpore toda la infomación que aparece en "GÉNERO Y CRÍTICA" y no solo la sinopsis de Filmaffinity. Si a alguien le interesa, que coja, que es gratis.
Code: Select all
// Genere & Critic
LineNr := FindLine('GÉNERO Y CRÍTICA', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
HTMLDecode(Line);
Line := Copy (Page.Text, 1, Length (Page.Text));
Line := StringReplace(Line, '<br />', #13#10);
Item := TextBetween (Line, 'GÉNERO Y CRÍTICA</b></td>', '</tr>');
Item := TextBetween (Item, '<td >', '</td>');
Item := StringReplace (Item, 'á','á');
Item := StringReplace (Item, 'é','é');
Item := StringReplace (Item, 'í','í');
Item := StringReplace (Item, 'ó','ó');
Item := StringReplace (Item, 'ú','ú');
Item := StringReplace (Item, 'Á','Á');
Item := StringReplace (Item, 'É','É');
Item := StringReplace (Item, 'Í','Í');
Item := StringReplace (Item, 'Ó','Ó');
Item := StringReplace (Item, 'Ú','Ú');
Item := StringReplace (Item, '"','');
Item := StringReplace (Item, 'ñ','ñ');
Item := StringReplace (Item, '¿','¿');
SetField(fieldDescription, Trim(Item));
end;