FilmAffinity (ES) [Fix]: Oficial version v2.51

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
aviloria
Posts: 24
Joined: 2006-11-08 11:52:28

FilmAffinity (ES) [Fix]: Oficial version v2.51

Post by aviloria »

Hi all,

Thank you for the comments and the feedback from the previous release.
I have fixed a small bug: The script could not retrieve "Country filed" when there is no "Visual section" in the html code of the page.

You can find the new version at the bottom of the post.



Hola a todos,

Gracias por los comentarios y las aportaciones de la versión anterior.
He corregido un pequeño problema: El script no podía obtener el campo "País" cuando no existía una "Sección visual" en el código HTML de la página.

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.51
Requires=3.5.0
Comments=Updated: Script option for batch running (default disabled), and now it gets the category.
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]
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

***************************************************)

program FilmAffinity;
const
   BaseURL1 = '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(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);

      // quitamos los tabuladores
      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
   Page: TStringList;
   LineNr: Integer;
   Line,Line2: string;
   Count: Integer;
   MovieTitle, MovieAddress: string;

begin
   Count := 0;
   Page  := TStringList.Create;
   Page.Text := GetPage(Address);
     PickTreeClear;


   // Veamos si solo hay un solo resultado
   LineNr := FindLine('<b>1 resultados.</b>', Page, 0);
   if LineNr <> -1 then
   begin
      Line         := Page.GetString(LineNr + 7);
      Line2        := Line;
      MovieAddress := TextBetween(Line, '<b><a href="', '">');
      MovieTitle   := TextBetween(Line2, '.html">', '</a></b>');

      HTMLDecode(MovieTitle);
      DeleteTags(MovieTitle);

      if (MovieAddress <> '') AND (MovieTitle <> '') then
      begin
         MovieAddress := BaseURL1 + MovieAddress;
         PickTreeAdd(MovieTitle, MovieAddress);
         if GetOption('DontAsk') = 0 then
           if PickTreeExec(MovieAddress) then
              AnalyzeMoviePage(MovieAddress);
         if GetOption('DontAsk') = 1 then
           AnalyzeMoviePage(MovieAddress);
      end
      Page.Free;
      exit;
   end;

   // Veamos cuantos resultados se han encontrado
   LineNr := FindLine('resultados.</b></td></tr>', Page, 0);
   if LineNr <> -1 then
   begin
      Line  := Page.GetString(LineNr);
      Count := StrToInt(TextBetween(Line, '<b>', ' resultados.</b>'), 0);
   end;


   // Si no hemos encontrado ningún resultado, abandonamos
   if Count = 0 then
   begin
      ShowMessage('No se ha encontrado ningún registro');
      Page.Free;
      exit;
   end;

   LineNr := 0;

   while TRUE do
   begin

      LineNr := FindLine('<b><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);
         Address   := TextBetween(Line, '<a href="', '">');
         Page.Text := GetPage(Address);
         LineNr    := 0;
         continue;
      end;

      Line         := Page.GetString(LineNr);
      Line2        := Line;
      MovieAddress := TextBetween(Line, '<b><a href="', '">');
      MovieTitle   := TextBetween(Line2, '.html">', '</td>');

      HTMLDecode(MovieTitle);
      DeleteTags(MovieTitle);

      if (MovieAddress <> '') AND (MovieTitle <> '') then
         PickTreeAdd(MovieTitle, BaseURL1 + MovieAddress);
   end;

   if PickTreeExec(Address) then
      AnalyzeMoviePage(Address);

   Page.Free;
end;

//------------------------------------------------------------------------------------

procedure AnalyzeMoviePage(Address: string);
var
   Page: TStringList;
   LineNr: 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: 4px; padding:1px; text-align: left; border-bottom: 1px solid #990000;"><span style="color:#990000; font-size:16px; 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('<th>TÍTULO ORIGINAL</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      Item := TextBetween(Line, '<td><strong>', '</strong></td>');
      HTMLDecode(Item);
      SetField(fieldOriginalTitle, Trim(Item));
   end;

   // Year
   LineNr := FindLine('<th>AÑO</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 2);
      if (Pos('</div>', Line) > 0) then
        Item := TextBetween(Line, '</div>', '</td>')
      else
        Item := TextBetween(Line, ' ', '</td>');
      HTMLDecode(Item);
      SetField(fieldYear, Trim(Item));
   end;

   // Length
   LineNr := FindLine('<th>DURACIÓN</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 5);
      Item := TextBetween(Line, ' ', ' min.');
      HTMLDecode(Item);
      SetField(fieldLength, Trim(Item));
   end;

   // Country
   LineNr := FindLine('<th valign="baseline" align="right" ><b>PAÍS</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 2);
      if (Pos ('title="', Line) <= 0) then
        Line := Page.GetString(LineNr + 3);
      Item := TextBetween(Line, 'title="', '" border');
      HTMLDecode(Item);
      SetField(fieldCountry, Trim(Item));
   end;

   // Director
   LineNr := FindLine('<th>DIRECTOR</th>', Page, LineNr);
   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('<th>GUIÓN</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      Item := TextBetween(Line, '<td>', '</td>');
      Comments := Comments + 'Guión: ' + Item + #13#10 + #13#10;
   end;

   // Composer
   LineNr := FindLine('<th>MÚSICA</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      Item := TextBetween(Line, '<td>', '</td>');
      Comments := Comments + 'Música: ' + Item + #13#10 + #13#10;
   end;

   // Photography
   LineNr := FindLine('<th>FOTOGRAFÍA</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      Item := TextBetween(Line, '<td>', '</td>');
      Comments := Comments + 'Fotografía: ' + Item + #13#10 + #13#10;
   end;

   // Actors
   LineNr := FindLine('<th>REPARTO</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
     Line := '';
     while TRUE do
     begin
        LineNR := LineNR + 1;
        Line   := Line + Page.GetString(LineNr);
        if Pos('</td>', Line) > 0 then
           break;
     end;

     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('<th>PRODUCTORA</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      Item := TextBetween(Line, '<td>', '</td>');
      HTMLDecode(Item);
      SetField(fieldProducer, Trim(Item));
   end;

   // Official Webpage
   LineNr := FindLine('<th>WEB OFICIAL</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      Comments := Comments + 'Web oficial: ' + TextBetween(Line, '<a href="', '" target="_blank">') + #13#10 + #13#10;
   end;

   // Awards
   LineNr := FindLine('<th>PREMIOS</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      LineNr   := LineNr + 1;
      Line     := Page.GetString(LineNr);
      Comments := Comments + 'Premios: ' + #13#10;
      while Pos('<a href="/es/awards.php', Line) > 0 do
      begin
        Item := DeleteTags(Line);
        Comments := Comments + '  - ' + Trim(Item) + #13#10;
        LineNr   := LineNr + 1;
        Line     := Page.GetString(LineNr);
      end;
      Comments := Comments + #13#10;
   end;

   // Category
   LineNr := FindLine('<th>GÉNERO</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 2);
      Item := DeleteTags(Line);
      HTMLDecode(Item);
      SetField(fieldCategory, Trim(Item));
   end;

   // Synopsis
   LineNr := FindLine('<th>SINOPSIS</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      Item := TextBetween(Line, '<td>', '</td>');
      HTMLDecode(Item);
      SetField(fieldDescription, Trim(Item));
   end;

   // Critic
   LineNr := FindLine('<th>CRÍTICAS</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Comments := Comments + 'Críticas: ' + #13#10;
      LineNr := LineNr + 3;
      Item := Page.GetString(LineNr);
      while Pos ('</tr>', Item) = 0 do
      begin
         while Pos('<br>', Item) <> 0 do
            Item := StringReplace(Item, '<br>', #13#10);
         while Pos('</br>', Item) <> 0 do
            Item := StringReplace(Item, '</br>', #13#10);
         while Pos('  ', Item) <> 0 do
            Item := StringReplace(Item, '  ', ' ');
         Comments := Comments + DeleteTags(Item);
         LineNr := LineNr + 1;
         Item := Page.GetString(LineNr);
      end;
   end;

   // 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="', '"');
      if Length(Item) = 0 then
         Item := TextBetween(Line, '<img src="', '"');
      GetPicture(Item);
   end;

   // Rating
   LineNr := FindLine('<div style="margin: 4px 0; color:#990000; font-size:22px; font-weight: bold;">', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr);
      Item := TextBetween(Line, '<div style="margin: 4px 0; color:#990000; font-size:22px; font-weight: bold;">', '</div>');
      HTMLDecode(Item);
      SetField(fieldRating, Item);
   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 MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);

   if GetOption('DontAsk') = 0 then
      Input('FilmAffinity', 'Pelicula:', MovieName);

   if Pos('filmaffinity.com', MovieName) > 0 then
      AnalyzeMoviePage(MovieName)
   else
      AnalyzePage(BaseURL1 +'/es/search.php?stext=' + UrlEncode(MovieName)  + '&stype=Title');
end.
Last edited by aviloria on 2011-11-13 11:20:36, edited 2 times in total.
Protasio
Posts: 7
Joined: 2011-11-08 00:07:57

Post by Protasio »

Muchas gracias
Carlos Burgas
Posts: 1
Joined: 2011-11-14 17:55:05

Post by Carlos Burgas »

Uso AMC hace años pero soy nuevo en cuanto a problemas.
Filmaffinity llevaba varios dias que solo importaba 4 o 5 campos y a partir de hoy no encuentra ningun titulo de pelicula.
Por otra parte me gustaría aprender la programación de scripts para resolver los problemas localmente.
¿Me podeis ayudar?
Protasio
Posts: 7
Joined: 2011-11-08 00:07:57

Post by Protasio »

Ayer 14 por la mañana funcionaba perfectamente y por la tarde al realizar la búsqueda no encontraba ninguna película.
pedigree
Posts: 2
Joined: 2011-11-15 13:46:07

Post by pedigree »

Muchas gracias por el script, pero parece que sigue sin funcionar, no encuentra ninguna película.
rodpedja
Posts: 5
Joined: 2005-06-05 19:16:42

Changes in the HTML

Post by rodpedja »

Parece que han cambiado el HTML de la pagina: Estoy revisando el script:
Por ejemplo donde pone ahora

LineNr := FindLine('<b>1 resultados.</b>', Page, 0);

Deberia cambiarse por:

LineNr := FindLine('<strong>1</strong> resultados.', Page, 0);


Pero hay mas cambios.. Cuando lo finalice lo posteo aqui al completo
rodpedja
Posts: 5
Joined: 2005-06-05 19:16:42

Post by rodpedja »

Aqui está el script corregido:

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.53
Requires=3.5.0
Comments=Updated: Script option for batch running (default disabled), and now it gets the category.
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]
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

***************************************************)

program FilmAffinity;
const
   BaseURL1 = '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(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);

      // quitamos los tabuladores
      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
   Page: TStringList;
   LineNr: Integer;
   Line,Line2: string;
   Count: Integer;
   MovieTitle, MovieAddress: string;

begin
   Count := 0;
   Page  := TStringList.Create;
   Page.Text := GetPage(Address);
     PickTreeClear;


   // Veamos si solo hay un solo resultado
   LineNr := FindLine('<strong>1</strong> resultados.', Page, 0);
   if LineNr <> -1 then
   begin
      Line         := Page.GetString(LineNr + 7);
      Line2        := Line;
      MovieAddress := TextBetween(Line, '<b><a href="', '">');
      MovieTitle   := TextBetween(Line2, '.html">', '</td>');

      HTMLDecode(MovieTitle);
      DeleteTags(MovieTitle);

      if (MovieAddress <> '') AND (MovieTitle <> '') then
      begin
         MovieAddress := BaseURL1 + MovieAddress;
         PickTreeAdd(MovieTitle, MovieAddress);
         if GetOption('DontAsk') = 0 then
           if PickTreeExec(MovieAddress) then
              AnalyzeMoviePage(MovieAddress);
         if GetOption('DontAsk') = 1 then
           AnalyzeMoviePage(MovieAddress);
      end
      Page.Free;
      exit;
   end;

   // Veamos cuantos resultados se han encontrado
   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;


   // Si no hemos encontrado ningún resultado, abandonamos
   if Count = 0 then
   begin
      ShowMessage('No se ha encontrado ningún registro');
      Page.Free;
      exit;
   end;

   LineNr := 0;

   while TRUE do
   begin

      LineNr := FindLine('<b><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);
         Address   := TextBetween(Line, '<a href="', '">');
         Page.Text := GetPage(Address);
         LineNr    := 0;
         continue;
      end;

      Line         := Page.GetString(LineNr);
      Line2        := Line;
      MovieAddress := TextBetween(Line, '<b><a href="', '">');
      MovieTitle   := TextBetween(Line2, '.html">', '</td>');

      HTMLDecode(MovieTitle);
      DeleteTags(MovieTitle);

      if (MovieAddress <> '') AND (MovieTitle <> '') then
         PickTreeAdd(MovieTitle, BaseURL1 + MovieAddress);
   end;

   if PickTreeExec(Address) then
      AnalyzeMoviePage(Address);

   Page.Free;
end;

//------------------------------------------------------------------------------------

procedure AnalyzeMoviePage(Address: string);
var
   Page: TStringList;
   LineNr: 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('<img src="http://www.filmaffinity.com/images/movie.gif" border="0">', Page, 0);
   Line := Page.GetString(LineNr);
   Item := TextBetween(Line, ' border="0"> ', '</span>');
   HTMLDecode(Item);
   SetField(fieldTranslatedTitle, Trim(Item));

   // Original Title
   LineNr := FindLine('<th>TÍTULO ORIGINAL</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      Item := TextBetween(Line, '<td><strong>', '</strong></td>');
      HTMLDecode(Item);
      SetField(fieldOriginalTitle, Trim(Item));
   end;

   // Year
   LineNr := FindLine('<th>AÑO</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 2);
      Item := TextBetween(Line, ' ', '</td>');
      HTMLDecode(Item);
      SetField(fieldYear, Trim(Item));
   end;

   // Length
   LineNr := FindLine('<th>DURACIÓN</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 5);
      Item := TextBetween(Line, ' ', ' min.');
      HTMLDecode(Item);
      SetField(fieldLength, Trim(Item));
   end;

   // Country
   LineNr := FindLine('<b>PAÍS</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 3);
      Item := TextBetween(Line, 'title="', '" border');
      HTMLDecode(Item);
      SetField(fieldCountry, Trim(Item));
   end;

   // Director
   LineNr := FindLine('<th>DIRECTOR</th>', Page, LineNr);
   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('<th>GUIÓN</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      Item := TextBetween(Line, '<td>', '</td>');
      Comments := Comments + 'Guión: ' + Item + #13#10 + #13#10;
   end;

   // Composer
   LineNr := FindLine(' <th>MÚSICA</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      Item := TextBetween(Line, '<td>', '</td>');
      Comments := Comments + 'Música: ' + Item + #13#10 + #13#10;
   end;

   // Photography
   LineNr := FindLine('<th>FOTOGRAFÍA</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      Item := TextBetween(Line, '<td>', '</td>');
      Comments := Comments + 'Fotografía: ' + Item + #13#10 + #13#10;
   end;

   // Actors
   LineNr := FindLine('<th>REPARTO</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
     Line := '';
     while TRUE do
     begin
        LineNR := LineNR + 1;
        Line   := Line + Page.GetString(LineNr);
        if Pos('</td>', Line) > 0 then
           break;
     end;

     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('<th>PRODUCTORA</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      Item := TextBetween(Line, '<td>', '</td>');
      HTMLDecode(Item);
      SetField(fieldProducer, Trim(Item));
   end;

   // Official Webpage
   LineNr := FindLine('<th>WEB OFICIAL</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      Comments := Comments + 'Web oficial: ' + TextBetween(Line, '<a href="', '" target="_blank">') + #13#10 + #13#10;
   end;

   // Awards
   LineNr := FindLine('<th>PREMIOS</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      LineNr   := LineNr + 1;
      Line     := Page.GetString(LineNr);
      Comments := Comments + 'Premios: ' + #13#10;
      while Pos('<a href="/es/awards.php', Line) > 0 do
      begin
        Item := DeleteTags(Line);
        Comments := Comments + '  - ' + Trim(Item) + #13#10;
        LineNr   := LineNr + 1;
        Line     := Page.GetString(LineNr);
      end;
      Comments := Comments + #13#10;
   end;

   // Category
   LineNr := FindLine('<th>GÉNERO</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 2);
      Item := DeleteTags(Line);
      HTMLDecode(Item);
      SetField(fieldCategory, Trim(Item));
   end;

   // Synopsis
   LineNr := FindLine('<th>SINOPSIS</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      Item := TextBetween(Line, '<td>', '</td>');
      HTMLDecode(Item);
      SetField(fieldDescription, Trim(Item));
   end;

   // Critic
   LineNr := FindLine('<th>CRÍTICAS</th>', Page, LineNr);
   if LineNr <> -1 then
   begin
      Comments := Comments + 'Críticas: ' + #13#10;
      LineNr := LineNr + 3;
      Item := Page.GetString(LineNr);
      while Pos ('</tr>', Item) = 0 do
      begin
         while Pos('<br>', Item) <> 0 do
            Item := StringReplace(Item, '<br>', #13#10);
         while Pos('</br>', Item) <> 0 do
            Item := StringReplace(Item, '</br>', #13#10);
         while Pos('  ', Item) <> 0 do
            Item := StringReplace(Item, '  ', ' ');
         Comments := Comments + DeleteTags(Item);
         LineNr := LineNr + 1;
         Item := Page.GetString(LineNr);
      end;
   end;

   // 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="', '"');
      if Length(Item) = 0 then
         Item := TextBetween(Line, '<img src="', '"');
      GetPicture(Item);
   end;

   // Rating
   LineNr := FindLine(' <div style="margin: 4px 0; color:#990000; font-size:22px; font-weight: bold;">', Page, LineNr);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr);
      Item := TextBetween(Line, ' <div style="margin: 4px 0; color:#990000; font-size:22px; font-weight: bold;">', '</div>');
      HTMLDecode(Item);
      SetField(fieldRating, Item);
   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 MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);

   if GetOption('DontAsk') = 0 then
      Input('FilmAffinity', 'Pelicula:', MovieName);

   if Pos('filmaffinity.com', MovieName) > 0 then
      AnalyzeMoviePage(MovieName)
   else
      AnalyzePage(BaseURL1 +'/es/search.php?stext=' + UrlEncode(MovieName)  + '&stype=Title');
end.
Que lo disfruten ;)
Protasio
Posts: 7
Joined: 2011-11-08 00:07:57

Post by Protasio »

No aparece "País"

Gracias
javienigma
Posts: 21
Joined: 2011-11-08 12:06:48

Post by javienigma »

Gracias con la última modificación del script añadida ya vuelve a funcionar. A mi también me pasaba que no me encontraba ninguna película. Ahora con el aporte de rodpedja todo vuelve a la normalidad.

Protasio, no te aparece el país? yo acabo de hacer dos busquedas y si me detecta ok el país...

Una duda, porque si el script es en español, las carátulas salen con los títulos en inglés? hay alguna manera de encontrar la carátula en español, ya sea con filmaffinity u otro script que me recomendeis?

GRACIAS!
pedigree
Posts: 2
Joined: 2011-11-15 13:46:07

Post by pedigree »

Muchas gracias rodpejda, el script vuelve a funcionar :)
ChessPlayer
Posts: 15
Joined: 2005-05-23 14:16:39

Post by ChessPlayer »

Protasio wrote:No aparece "País"

Gracias
En efecto, en algunas películas no aparece el país :??:
rodpedja
Posts: 5
Joined: 2005-06-05 19:16:42

Post by rodpedja »

Habría que cambiar lo siguiente, para que siempre encuentre el país:

Code: Select all

 // Country 
   LineNr := FindLine('<img src="/imgs/countries', Page, LineNr); 
   if LineNr <> -1 then 
   begin 
      Line := Page.GetString(LineNr); 
      Item := TextBetween(Line, 'title="', '" border'); 
      HTMLDecode(Item); 
      SetField(fieldCountry, Trim(Item)); 
   end; 
A ver si saco tiempo para actualizar el script completo..
aas8051
Posts: 4
Joined: 2009-08-28 13:56:19

Post by aas8051 »

Acabo de actualizar el script a la versión 3.53 y no carga el año de la pélicula. He modificado la linea 227 y parece que ya la carga.

I've just upgrade this script to ver. 3.53 and it doesn't load the field "year"·. I've modify line no. 227 and it seems to work fine.



227 Item := TextBetween(Line, '</a></div>', '</td>');



Regards
Alberto

Edito: En determinadas películas funciona la versión modificada y en otras la versión sin modificar. :/
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks, I updated version number to 2.54 then.
ChessPlayer
Posts: 15
Joined: 2005-05-23 14:16:39

Post by ChessPlayer »

Pues ahora lo que ocurre es que cuando encuentra sólo una película no pregunta, pero tampoco baja nada. No da error, pero se queda en blanco. He probado.
Con la película "Sophie Scholl: los últimos días", si pones el título completo no devuelve nada, pero si pones sólo "últimos" te encuentra varias películas, seleccionas la correcta y entonces baja todos los datos.
masterchipo
Posts: 99
Joined: 2010-02-22 23:15:05

Post by masterchipo »

dejaron de funcionar para cualquier película todos los scripts, nuevos y viejos de Filmaffinity. Y para ninguna película, ya no se trata del año, ni del país, ni nada, ningun dato te pone, es como si no encontrara nada.
A ver si nos dan una mano que ya están dando bastantes problemas estos scripts.
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Sorry but I do not understand Spanish, and the result of Google Translation is not really good :D

For me the current script (2.54) works, at least on the few movies I tested.

@ChessPlayer > you mention "Sophie Scholl: los últimos días" -> that does not give any result on the FilmAffinity website so it is normal that the script does not find it either.
z3us
Posts: 86
Joined: 2008-02-19 17:36:53

Post by z3us »

antp wrote:Sorry but I do not understand Spanish, and the result of Google Translation is not really good :D

For me the current script (2.54) works, at least on the few movies I tested.

@ChessPlayer > you mention "Sophie Scholl: los últimos días" -> that does not give any result on the FilmAffinity website so it is normal that the script does not find it either.
Antp, they are talking about the spanish version of filmaffinity:
http://www.filmaffinity.com/es

This is the film:
http://www.filmaffinity.com/es/film368669.html
Protasio
Posts: 7
Joined: 2011-11-08 00:07:57

Post by Protasio »

En la página web han colgado el siguiente cartel:

"Estamos trabajando en el rediseño de la página
Próximamente en las mejores pantallas :) "

Deberiamos esperar a ver si terminan.

Saludos
masterchipo
Posts: 99
Joined: 2010-02-22 23:15:05

Post by masterchipo »

antp wrote:Sorry but I do not understand Spanish, and the result of Google Translation is not really good :D

For me the current script (2.54) works, at least on the few movies I tested.

@ChessPlayer > you mention "Sophie Scholl: los últimos días" -> that does not give any result on the FilmAffinity website so it is normal that the script does not find it either.
Try you film London Boulevard
The script 2.54 don't work
El nuevo script no funciona, y me refiero al 2.54. Hay películas que están en la base de datos y no las encuentra.
Me parece que como la página de FilmAffinity se ha modificado, también hay que volver a modificar el nuevo script, que estaba hecho y pensado por el diseño de la página anterior
Gracias
Post Reply