FilmAffinity (ES): Fix in movie pictures server url

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.
Post Reply
aviloria
Posts: 24
Joined: 2006-11-08 11:52:28

FilmAffinity (ES): Fix in movie pictures server url

Post by aviloria »

Hi all,

FilmAffinity has changed the url of his movie cover server, and has included a hi-res picture for all of them.

This is the update for the script:

---------------------

Hola a todos

FilmAffinity ha cambiado la url del servidor de carátulas de las películas, y ha incluido muchas de ellas en una mayor resolución.

La actualización del script es la siguiente:

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.45
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>TITULO ORIGINAL</b>', Page, 0);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      MovieTitle := TextBetween (Line, '<td ><b>', '</b></td>');
      HTMLDecode(MovieTitle);
      PickTreeAdd(MovieTitle, Address);

       if(GetOption('DontAsk') = 0) then
            if PickTreeExec(Address) then AnalyzeMoviePage(Address);
       if(GetOption('DontAsk') = 1) then AnalyzeMoviePage(Address);
      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, iL, aux, Check: Integer;
  Line,LineAux: 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('http://pics2.filmaffinity.com/', Page, 0);
  if LineNr <> -1 then
  begin
     Line := Page.GetString(LineNr);
     Item := TextBetween (Line, '<a class="lightbox" href="', '"');
     GetPicture (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 + 3);
    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 + 3);
    Item := TextBetween (Line, 'title="', '" 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('MÚSICA', 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 := '';
   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('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;

   // Category
  Check := 0;
  LineNr := FindLine('GÉNERO Y CRÍTICA', Page, 0);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 6);
    Item := TextBetween (Line, ' / ', ' / ');
   if Length(Item)> 100 then
     begin
        Line := Page.GetString(LineNr + 6);
        Item := TextBetween (Line, '<td valign="top">', ' /');
        if Item <> '' then
          Check := 1;
     end;
    HTMLDecode(Item);
    SetField(fieldCategory, Trim (Item));
  end;

  // Critic
  LineNr := FindLine('GÉNERO Y CRÍTICA', Page, 0);
  if LineNr <> -1 then
  begin
    iL := 6;
    Line := Page.GetString(LineNr + iL);
    LineAux := Page.GetString(LineNr + iL+1);

      while  true do
      begin
        if Pos('</tr>', LineAux) > 0 then
         break;
          Line := Line+LineAux;
          iL := iL+1;
          LineAux := Page.GetString(LineNr + iL+1);
      end;

    HTMLDecode(Line);
    Line := StringReplace(Line, '<br />', #13#10);
    if Check = 1 then
      Item := TextBetween (Line, '/ ', '</td>')
    else
      Item := TextBetween (Line, '<td valign="top">','</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;

  // 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)=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('http://www.filmaffinity.com/es/search.php?stext=' + UrlEncode(MovieName)  + '&stype=Title');
end.
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks.
aas8051
Posts: 4
Joined: 2009-08-28 13:56:19

Post by aas8051 »

Hi,
Thanks for the upgrade.
There are two missing accents in lines 109 and 210 in "TÍTULO ORIGINAL". Add the accent and will get the original title again.

Hola,
Gracias por la actualizacion.
Faltan los acentos en "TÍTULO ORIGINAL" en las líneas 109 y 210. Añadiendolos vuelve a recuperar el título original.

Rgds.
Alberto
aviloria
Posts: 24
Joined: 2006-11-08 11:52:28

Post by aviloria »

You are right. Sorry for the inconvenience.

The fixed script is below (version also updated):

--------------------------------------

Tienes razón. Perdón por las molestias.

El script corregido es el siguiente (también se ha actualizado el número de versión):

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.46
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>TÍTULO ORIGINAL</b>', Page, 0);
   if LineNr <> -1 then
   begin
      Line := Page.GetString(LineNr + 1);
      MovieTitle := TextBetween (Line, '<td ><b>', '</b></td>');
      HTMLDecode(MovieTitle);
      PickTreeAdd(MovieTitle, Address);

       if(GetOption('DontAsk') = 0) then
            if PickTreeExec(Address) then AnalyzeMoviePage(Address);
       if(GetOption('DontAsk') = 1) then AnalyzeMoviePage(Address);
      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, iL, aux, Check: Integer;
  Line,LineAux: 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('TÍTULO 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('http://pics2.filmaffinity.com/', Page, 0);
  if LineNr <> -1 then
  begin
     Line := Page.GetString(LineNr);
     Item := TextBetween (Line, '<a class="lightbox" href="', '"');
     GetPicture (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 + 3);
    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 + 3);
    Item := TextBetween (Line, 'title="', '" 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('MÚSICA', 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 := '';
   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('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;

   // Category
  Check := 0;
  LineNr := FindLine('GÉNERO Y CRÍTICA', Page, 0);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 6);
    Item := TextBetween (Line, ' / ', ' / ');
   if Length(Item)> 100 then
     begin
        Line := Page.GetString(LineNr + 6);
        Item := TextBetween (Line, '<td valign="top">', ' /');
        if Item <> '' then
          Check := 1;
     end;
    HTMLDecode(Item);
    SetField(fieldCategory, Trim (Item));
  end;

  // Critic
  LineNr := FindLine('GÉNERO Y CRÍTICA', Page, 0);
  if LineNr <> -1 then
  begin
    iL := 6;
    Line := Page.GetString(LineNr + iL);
    LineAux := Page.GetString(LineNr + iL+1);

      while  true do
      begin
        if Pos('</tr>', LineAux) > 0 then
         break;
          Line := Line+LineAux;
          iL := iL+1;
          LineAux := Page.GetString(LineNr + iL+1);
      end;

    HTMLDecode(Line);
    Line := StringReplace(Line, '<br />', #13#10);
    if Check = 1 then
      Item := TextBetween (Line, '/ ', '</td>')
    else
      Item := TextBetween (Line, '<td valign="top">','</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;

  // 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)=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('http://www.filmaffinity.com/es/search.php?stext=' + UrlEncode(MovieName)  + '&stype=Title');
end. 
BittMan
Posts: 9
Joined: 2009-05-06 21:03:55

Post by BittMan »

Vuelve a no pillar los carteles... alguien lo puede solucionar?
un saludo y gracias

----------------------------------------------------------------------

Don't download the posters again... anyone can fix it?

Thank you and greetings
legrad
Posts: 109
Joined: 2006-02-11 09:46:06
Location: Lerida-Spain

Mi version filmaffinity

Post by legrad »

Esta es mi propia version de filmafinity

Code: Select all

(*************************************************** 

Ant Movie Catalog importation script 
www.antp.be/software/moviecatalog/ 

[Infos] 
Authors=Legrad 
Title=Filmaffinity Legrad's (ES) 
Description= 
Site=www.Filmaffinity.com 
Language=ES 
Version=1.0 
Requires=3.5.0 
Comments= 
License= 
GetInfo=1 

[Options] 

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

program FilmaffinityLegrads; 
var 
  MovieName: string; 
  MovieURL: string; 
  //------------------------------------------------------------------------------------ 
function UpFirstLetterWord(texto:string):string; 
var espaco:integer; 
sst:string; 
begin 
texto:=AnsiUpFirstLetter(AnsiLowerCase(texto)); 
repeat 
    espaco:=Pos(' ',texto); 
    sst:=AnsiUpperCase(Copy(texto,espaco+1,1)); 

texto:=Copy(texto,1,espaco-1)+'/|\'+sst+Copy(texto,espaco+2,length(texto)); 
until Pos(' ',texto)=0; 
texto := StringReplace(texto, '/|\', ' '); 
if Copy(texto,1,1)=' ' then 
  texto:=Copy(texto,2,length(texto)); 
result:=texto; 
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 Caracter(str1: string) :string; 
begin 
          str1 := StringReplace(str1, 'á' , 'à'); 
          str1 := StringReplace(str1, 'é' , 'é'); 
          str1 := StringReplace(str1, 'Ã',  'í'); 
          Str1 := StringReplace(Str1, 'ó', 'ó'); 
          str1 := StringReplace(str1, 'ú' , 'ú'); 
          str1 := StringReplace(str1, 'ñ' , 'ñ'); 
          str1 := StringReplace(str1, 'Ã�', 'Á'); 
          str1 := StringReplace(str1, 'É', 'É'); 
          str1 := StringReplace(str1, 'Ã�', 'Í'); 
          str1 := StringReplace(str1, 'Ó', 'Ó'); 
          str1 := StringReplace(str1, 'Ú', 'Ú'); 
          str1 := StringReplace(str1, 'Ñ', 'Ñ'); 
          str1 := StringReplace(str1, 'Â', ''); 

result := str1; 
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 , '">', '<'); 
          MovieTitle := Caracter(MovieTitle); 
          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 := ''; 

  // URL 
  SetField(fieldURL, Address); 
  Page := TStringList.Create; 
  Page.Text := GetPage(Address); 
  
  // Titulo traducido 
  LineNr := FindLine('<title>', Page, 0); 
  Line := Page.GetString(LineNr); 
  Line := UTF8Encode(Line); 
  Item := TextBetween (Line, '<title>', '('); 
  HTMLDecode(Item); 
  Item := Caracter(Item); 
  SetField(fieldTranslatedTitle, Trim (Item)); 

  // Titulo Original 
 LineNr := FindLine('<b>TÍTULO ORIGINAL</b></td>', Page, 0); 
  if LineNr <> -1 then 
  begin 
    Item := copy(Page.Text, pos('<b>TÍTULO ORIGINAL</b></td>',Page.Text), length(Page.Text)); 
    Item := TextBetween (Item, '<td ><b>', '</b></td>'); 
    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('<b>DURACIÓN</b></td>', Page, 0); 
  if LineNr <> -1 then 
  begin 
    Item := copy(Page.Text, pos('<b>DURACIÓN</b></td>',Page.Text), length(Page.Text)); 
    Item := TextBetween (Item, '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>', 'min.</td>'); 
    Item := TextBetween (Item, '<td>', 'min'); 
    HTMLDecode(Item); 
    SetField(fieldLength, Trim (Item)); 
  end; 

  // pais 
   LineNr := FindLine('<b>PAÍS</b></td>', Page, 0); 
  if LineNr <> -1 then 
  begin 
    Item := copy(Page.Text, pos('<b>PAÍS</b></td>',Page.Text), length(Page.Text)); 
    Item := TextBetween (Item, 'title="', '"'); 
    HTMLDecode(Item); 
     Item := Caracter(Item); 
    SetField(fieldCountry, Trim (Item)); 
  end; 
  
   // director 
   LineNr := FindLine('<b>DIRECTOR</b></td>', Page, 0); 
  if LineNr <> -1 then 
  begin 
    Item := copy(Page.Text, pos('<b>DIRECTOR</b></td>',Page.Text), length(Page.Text)); 
    Item := TextBetween (Item, 'href="search.php?stype=director&stext=', '"</td>'); 
    Item := TextBetween (Item, '">', '</a>'); 
    HTMLDecode(Item); 
     Item := Caracter(Item); 
    SetField(fieldDirector, Trim (Item)); 
  end; 
  
  // Reparto 
   LineNr := FindLine('<b>REPARTO</b></td>', Page, 0); 
  if LineNr <> -1 then 
  begin 
    Item := copy(Page.Text, pos('<b>REPARTO</b></td>',Page.Text), length(Page.Text)); 
    Item := TextBetween (Item, 'href="search.php?stype=', '</tr>'); 
    Item := TextBetween (Item, '">', '</a></td>'); 
    HTMLDecode(Item); 
    DeleteTags (Item); 
    Item := Caracter(Item); 
    SetField(fieldActors, Trim (Item)); 
  end; 
  
  // productor 
   LineNr := FindLine('<b>PRODUCTORA</b></td>', Page, 0); 
  if LineNr <> -1 then 
  begin 
    Item := copy(Page.Text, pos('<b>PRODUCTORA</b></td>',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('<b>GÉNERO Y CRÍTICA</b>', Page, 0); 
  if LineNr <> -1 then 
  begin 
    Item := copy(Page.Text, pos('<b>GÉNERO Y CRÍTICA</b>',Page.Text), length(Page.Text)); 
    Item := TextBetween (Item, '<td valign="top">', '/ SINOPSIS:'); 
    HTMLDecode(Item); 
    DeleteTags (Item); 
    Item := Caracter(Item); 
    SetField(fieldCategory, Trim (Item)); 
  end; 
  
  // sinopsis 
  LineNr := FindLine('<b>GÉNERO Y CRÍTICA</b>', Page, 0); 
  if LineNr <> -1 then 
  begin 
    Item := copy(Page.Text, pos('<b>GÉNERO Y CRÍTICA</b>',Page.Text), length(Page.Text)); 
    Item := TextBetween (Item, '/ SINOPSIS: ', '(FILMAFFINITY)'); 
    HTMLDecode(Item); 
    DeleteTags (Item); 
    Item := Caracter(Item); 
    SetField(fieldDescription, Trim (Item)); 
  end; 

  // Calificación 
  LineNr := FindLine('<tr><td align="center" style="color:#990000; font-size:22px; font-weight: bold;">', Page, 0); 
  if LineNr <> -1 then 
  begin 
    Item := copy(Page.Text, pos('<tr><td align="center" style="color:#990000; font-size:22px; font-weight: bold;">',Page.Text), length(Page.Text)); 
    Item := TextBetween (Item, '<tr><td align="center" style="color:#990000; font-size:22px; font-weight: bold;">', '</td></tr>'); 
    HTMLDecode(Item); 
    DeleteTags (Item); 
    SetField(fieldRating, Trim (Item)); 
  end; 
  
   // Guión 
LineNr := FindLine('<b>GUIÓN</b></td>', Page, 0); 
  if LineNr <> -1 then 
  begin 
    Item := copy(Page.Text, pos('<b>GUIÓN</b></td>',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('<b>FOTOGRAFÍA</b>', Page, 0); 
  if LineNr <> -1 then 
  begin 
    Item := copy(Page.Text, pos('<b>FOTOGRAFÍA</b>',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('<b>MÚSICA</b>', Page, 0); 
  if LineNr <> -1 then 
  begin 
    Item := copy(Page.Text, pos('<b>MÚSICA</b>',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('<b>GÉNERO Y CRÍTICA</b>', Page, 0); 
  if LineNr <> -1 then 
  begin 
    Item := copy(Page.Text, pos('<b>GÉNERO Y CRÍTICA</b>',Page.Text), length(Page.Text)); 
    Item := TextBetween (Item, '--<br />', '--</td>'); 
    HTMLDecode(Item); 
    DeleteTags (Item); 
    Item := Caracter(Item); 
    Item := StringReplace(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; 
//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.
Last edited by legrad on 2009-12-21 12:42:34, edited 1 time in total.
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

What is it compared to the other one? I mean, does it replace it?
legrad
Posts: 109
Joined: 2006-02-11 09:46:06
Location: Lerida-Spain

Post by legrad »

Is not necessary, simply another version belongs to filmaffinty, for that he need it.

thank
kreti
Posts: 12
Joined: 2005-07-19 01:20:36

Post by kreti »

Para corregir la importación de las carátulas, ir al código del script, y sustituir la parte //Picture por la siguiente:

Code: Select all

  // Picture
  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;
  if LineNr = -1 then
  begin
    LineNr := FindLine('<td align="center"><img src="http://pics.filmaffinity.com', Page, 0);
    if LineNr <> -1 then
    begin
      Item := copy(Page.Text, pos('<td align="center"><img src="http://pics.filmaffinity.com',Page.Text), length(Page.Text));
      Item := TextBetween (Item, '"http://pics.filmaffinity.com/', '.jpg');
      HTMLDecode(Item);
      GetPicture ('http://pics.filmaffinity.com/'+Item+'.jpg');
    end;
  end;
Se trata de una modificación del código de Legrad
kreti
Posts: 12
Joined: 2005-07-19 01:20:36

Post by kreti »

Otra cosa que falla en el script es que aún cuando la búsqueda solo devuelve un resultado, no importa directamente los datos, sino que te pide que selecciones el título.

Esto se puede corregir fácilmente si en la penúltima línea del script comentamos o borramos el stype=Title de la página de búsquedas.

Code: Select all

    AnalyzePage('http://www.filmaffinity.com/es/search.php?stext=' + UrlEncode(MovieName) (* + '&stype=Title'*));
Esto hace que busque también por director o actor, pero pocas veces va a coincidir el título de una película con el nombre de un director o actor.

Otra forma, manteniendo la búsqueda solo en el título es cambiar en el procedure AnalyzePage(Address: string); el siguiente bloque

Code: Select all

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

       if(GetOption('DontAsk') = 0) then
            if PickTreeExec(Address) then AnalyzeMoviePage(Address);
       if(GetOption('DontAsk') = 1) then AnalyzeMoviePage(Address);
      Page.Free;
      exit;
   end;
BittMan
Posts: 9
Joined: 2009-05-06 21:03:55

Post by BittMan »

La modificacion que han puesto para la caratula está bien... pero hay que añadirle una lina más:

end;

sin esto dará error.

Saludos
iosunoenlle
Posts: 5
Joined: 2010-02-20 12:55:13

Post by iosunoenlle »

Hello those of filmaffinity changed something of the page, I imagine, since now it does not load the script, so much one as other, the results of genre, synopsis and criticizes, if someone can correct it I would be very grateful, thank you.
crs1122
Posts: 2
Joined: 2010-02-20 13:10:27

Post by crs1122 »

Hello everyone. I am new to the forum. I have problems with the script (the last update I have is December 2009). All right until a few days, I do not care or "Class" or the "description", or "cover". Can anyone please could help me?. Thank you. I hit what I have:

Hola a todos. Soy nueva en el foro. Tengo problemas con el script (la última actualización que tengo es de diciembre del 2009. Todo correcto hasta hace unos días, que no me importa ni la "categoría", ni la "descripción", ni la "carátula". ¿Alguien por favor me podría ayudar?. Muchas gracias. Os pego lo que tengo:

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>TÍTULO ORIGINAL</b>', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 1);
MovieTitle := TextBetween (Line, '<td ><b>', '</b></td>');
HTMLDecode(MovieTitle);
PickTreeAdd(MovieTitle, Address);

if(GetOption('DontAsk') = 0) then
if PickTreeExec(Address) then AnalyzeMoviePage(Address);
if(GetOption('DontAsk') = 1) then AnalyzeMoviePage(Address);
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, iL, aux, Check: Integer;
Line,LineAux: 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('TÍTULO 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('http://pics2.filmaffinity.com/', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr);
Item := TextBetween (Line, '<a class="lightbox" href="', '"');
GetPicture (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 + 3);
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 + 3);
Item := TextBetween (Line, 'title="', '" 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('MÚSICA', 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 := '';
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('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;

// Category
Check := 0;
LineNr := FindLine('GÉNERO Y CRÍTICA', Page, 0);
if LineNr <> -1 then
begin
Line := Page.GetString(LineNr + 6);
Item := TextBetween (Line, ' / ', ' / ');
if Length(Item)> 100 then
begin
Line := Page.GetString(LineNr + 6);
Item := TextBetween (Line, '<td valign="top">', ' /');
if Item <> '' then
Check := 1;
end;
HTMLDecode(Item);
SetField(fieldCategory, Trim (Item));
end;

// Critic
LineNr := FindLine('GÉNERO Y CRÍTICA', Page, 0);
if LineNr <> -1 then
begin
iL := 6;
Line := Page.GetString(LineNr + iL);
LineAux := Page.GetString(LineNr + iL+1);

while true do
begin
if Pos('</tr>', LineAux) > 0 then
break;
Line := Line+LineAux;
iL := iL+1;
LineAux := Page.GetString(LineNr + iL+1);
end;

HTMLDecode(Line);
Line := StringReplace(Line, '<br />', #13#10);
if Check = 1 then
Item := TextBetween (Line, '/ ', '</td>')
else
Item := TextBetween (Line, '<td valign="top">','</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;

// 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)=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('http://www.filmaffinity.com/es/search.php?stext=' + UrlEncode(MovieName) + '&stype=Title');
end.
iosunoenlle
Posts: 5
Joined: 2010-02-20 12:55:13

Post by iosunoenlle »

For the mask only you have to eliminate 2 of pic and it goes out already for you but I generate that thing about, synopsis and you criticize even not as making it, sure that they changed something on the page of filmaffinity and the script, a greeting was not corrected yet.

Para la caratula solo tienes que eliminar el 2 de pic y ya te sale pero lo de genero, sinopsis y criticas aun no se como hacerlo, seguro que cambiaron algo en la pagina de filmaffinity y todavia no se corrigio el script, un saludo.
iosunoenlle
Posts: 5
Joined: 2010-02-20 12:55:13

Post by iosunoenlle »

// Picture
LineNr := FindLine('http://pics2.filmaffinity.com/', Page, 0);



// Picture
LineNr := FindLine('http://pics.filmaffinity.com/', Page, 0);



Asi lo hice yo, pero no se si hay otra forma
crs1122
Posts: 2
Joined: 2010-02-20 13:10:27

Post by crs1122 »

Perfecto! Muchísimas gracias por tu ayuda! Ya me carga la carátula.
En cuanto a "género" y "descripción" no encuentro la solución en ningún foro. :(

Perfect! Thank you for your help! I already load the cover.
As for "gender" and "description" I can not find the solution in any forum. : (
masterchipo
Posts: 99
Joined: 2010-02-22 23:15:05

No se puede corregir el script de Filmaffinity

Post by masterchipo »

Atento a los cambios en la página de filmaffinity, los cambios recientemente efectuados en los scripts tanto legrad como los anteriores, no funcionan debidamente en los campos: 1ºCATEGORIA, O género, o sea drama, comedia o lo que fuere, 2ºDESCRIPCION, o sea sinópsis, críticas, etc y 3º a veces no funciona ni el año ni la duración
Gracias.
Espero vuestra ayuda.
Ya que el script no serviría de nada.
Ps ¿se podría agregar el script nuevo o modificado en un plantilla para hacer más facil la tarea.
Agradezco desde ya.
masterchipo
klavatelli
Posts: 1
Joined: 2010-02-23 01:25:53

Hace un par de días que me trae loco

Post by klavatelli »

Hace un par de días que me trae loco, parece que han cambiado el ítem donde estaba la descripción, que ahora se llama SINOPSIS, antes incluía los Premios y el Género (ahora son categorías aparte) en la primera línea.
masterchipo
Posts: 99
Joined: 2010-02-22 23:15:05

Re: Hace un par de días que me trae loco

Post by masterchipo »

klavatelli wrote:Hace un par de días que me trae loco, parece que han cambiado el ítem donde estaba la descripción, que ahora se llama SINOPSIS, antes incluía los Premios y el Género (ahora son categorías aparte) en la primera línea.
Claro amigo, eso es lo que intento decir, pero la pregunta es ¿cómo se arregla?
En lo personal cuento: me comuniqué con el staff de Filmaffintiy y me contestaron textualmente, que ellos pueden ayudar, pero no a mí en lo particular sino a los administradores o el staff de Ant.be o Ant Movie Catalog. tema scripts.
Un saludo
iosunoenlle
Posts: 5
Joined: 2010-02-20 12:55:13

Post by iosunoenlle »

Intente editar el script variando nombre y cosas elementales y ahora si me detecta los apartados pero sigue sin marcarme la informacion,, pero de ahi no pase, un saludo.
Post Reply