[UPD ES] Filmaffinity 4.0

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
fulvio53s03
Posts: 763
Joined: 2007-04-28 05:46:43
Location: Italy

[UPD ES] Filmaffinity 4.0

Post by fulvio53s03 »

Updated in viewtopic.php?t=43147 : Actualización para las sinopsis de la serie.

Actualización con nueva búsqueda de títulos. Comprobado con algunos títulos, déjame saber cómo funciona.
Update with new title search. Checked with some titles, let me know how it works.

Code: Select all

 
 Updated  in viewtopic.php?t=43147 : Actualización para las sinopsis de la serie. 
 
Last edited by fulvio53s03 on 2025-02-09 09:58:55, edited 3 times in total.
fulvio53s03
Posts: 763
Joined: 2007-04-28 05:46:43
Location: Italy

Re: [UPD ES] Filmaffinity 4.0

Post by fulvio53s03 »

UPdated.
m2s
Posts: 18
Joined: 2010-02-27 17:46:48

Re: [UPD ES] Filmaffinity 4.0

Post by m2s »

Hola,
A mi no me funciona. Me da un error de ejecución "Error de script en Filmaffinity: unit is not found en la línea 2"

Intento adjuntar imagen (aunque no estoy seguro de cómo hacerlo):
https://mega.nz/file/S9VhGaRT#CQgCz3a9D ... e5rmcL1SGY

Gracias por el interés!
fulvio53s03
Posts: 763
Joined: 2007-04-28 05:46:43
Location: Italy

Re: [UPD ES] Filmaffinity 4.0

Post by fulvio53s03 »

StringUtils7552.pas is non included in your AMC distribution?
Download it!
:innocent:
m2s
Posts: 18
Joined: 2010-02-27 17:46:48

Re: [UPD ES] Filmaffinity 4.0

Post by m2s »

fulvio53s03 wrote: 2025-02-04 20:04:19 StringUtils7552.pas is non included in your AMC distribution?
Download it!
:innocent:
It works fine
Thanks!!!
cinecampillos
Posts: 22
Joined: 2009-04-06 15:51:36

Re: [UPD ES] Filmaffinity 4.0

Post by cinecampillos »

fulvio53s03 wrote: 2025-02-04 17:59:53 Actualización con nueva búsqueda de títulos. Comprobado con algunos títulos, déjame saber cómo funciona.
Update with new title search. Checked with some titles, let me know how it works.

Code: Select all

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

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

[Infos]
Authors=aviloria (aviloria@yahoo.com) modded by: rodpedja (rodpedja@gmail.com), kreti (bisoft@hotmail.com), MrK, gilistico, juliojs, Albher, Arturo, jacqlittle, AgustinG, Fulvio53s03
Title=FilmAffinity (ES)
Description=Movie importation script for FilmAffinity Spain
Site=https://www.filmaffinity.com
Language=ES
Version=4.0
Requires=4.2.2
Comments=adaptation for compatibility with 4.2 version. Added Extras capture. Changed Charset ISO-> utf8 - new searh page structure
License=The source code of the script can be used in another program only if full credits to script author and a link to Ant Movie Catalog website are given in the About box or in the documentation of the program.
GetInfo=1
RequiresMovies=1

[Options]
DontAsk=0|0|1=Método rápido: No te pregunta el titulo al principio, ni te pide confirmar si sólo hay un resultado|0=Método lento: Confirmas la información manualmente
ActorsInALine=0|0|1=Actores separados por comas|0=Actores en lineas independientes
Force350=0|0|1=force the behavior of 3.5.0 version|0=Version auto
DontWantExtras=1|1|1=No se recopilan extras|0=Se recopilan extras: enlaces, imágenes
GroupImages=1|1|1=Agrupa todas las imagenes en una misnma categoría 'Imagenes'|0=Divide las imágenes por categorias
SortByYear=0|0|1=Ordena lista de busqueda por año|0=Ordena lista de busqueda por relevancia
SearchByFromToYears=0|0|0=No buscar por año|1=Buscar dentro de un período de años
SearchByTitle=1|1|0=No buscar por título|1=Buscar por título
SearchByDirector=0|0|0=No buscar por director|1=Buscar por director
SearchByCast=0|0|0=No buscar por reparto|1=Buscar por reparto
SearchByScript=0|0|0=No buscar por guión|1=Buscar por guión
SearchByPhoto=0|0|0=No buscar por fotografía|1=Buscar por fotografía
SearchByMusic=0|0|0=No buscar por música|1=Buscar por música
SearchByProducer=0|0|0=No buscar por productor|1=Buscar por productor

[Parameters]
ExtraCriticsLimit=|99|Límite de criticas en Extras
ExtraImagesLimit=|99|Límite de imágenes en Extras
ExtraTrailersLimit=|99|Límite de Trailers en Extras

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

program FilmAffinity;
uses StringUtils7552;
const
  BaseURL = 'https://www.filmaffinity.com';
  folder  = 'c:\temp\';
  debug_search = false;
var
  DUMMY, initchar, endchar : string;
  MovieName    : string;
  MovieURL     : string;
  MovieYear    : string;

  YearFrom     : string;
  YearTo       : string;

  AdvQuery     : string;

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

function LineDecode(S: string):string;
begin
  S:= UTF8Decode(S);
  HTMLDecode(S);
  Result := S;
end;

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

//
//  ConvertAlphaNum: Quita todo menos letras (mayusculas y minusculas) y numeros
//

Function ConvertAlphaNum(s: string) : string;
var
  i: Integer;
  s2, ch: string;
begin
  s2 := '';
  For i := 1 To Length(s) do
  begin
    ch := copy(s, i, 1);
    if ((ch >= 'a') and (ch <= 'z')) or ((ch >= '0') and (ch <= '9')) or ((ch >= 'A') and (ch <= 'Z'))  then
    s2 := s2 + ch;
  end;
  result := s2;
end;

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

function DeleteTags(S: string): string;
var
  n, len, tag: Integer;
  c, p: char;
begin
  len    := Length(S);
  tag    := 0;
  p      := ' ';
  Result := '';
  for n := 1 to len do
  begin
    c := Copy(S,n,1);

      // Eliminamos los tabuladores
    if c = #9 then c := ' ';

      // Los espacios redundantes no se procesan
    if (c <> ' ') or (p <> ' ') then
    begin
         // Eliminamos los tags de HTML
      if tag = 0 then
      begin
        if c <> '<' then
        begin
          Result := Result + c;
          p := c;
        end
        else tag := 1;
      end
      else if c = '>' then tag := 0;
    end;
  end
  if p = ' ' then Result := Copy(Result, 1, Length(Result) - 1);
end;
//------------------------------------------------------------------------------------

function Occurrences(Subtext: string; Text: string): integer;
var
  offset: Integer;
begin
  result := 0;
  while true do
  begin
    offset := Pos(Subtext, Text);
    if offset = 0 then break;
    Result := Result + 1;
    Text := TextAfter(Text, Subtext);
  end;
end;
//------------------------------------------------------------------------------------

procedure AnalyzeAdvPage(Address: string);
var
  Page: TStringList;
  Pagestr, Blockestr, Linestr : string;             //fs2025
  BeginChar, LastChar : string;
  LineNr,LineNrax,NextPageNr,Pages: Integer;
  Line, PageNr: string;
  Count: Integer;
  MoviesList, MovieTitle, MovieAddress, MovieDirector: string;
  MovieYear, PagSig:String;
  PickMessaggio2, PickMessaggio3 : string;

begin
  Count := 0;
  Page  := TStringList.Create;
  Page.Text := GetPage(Address);
  pagestr := GetPage(Address);
  if debug_search then
     DumpPage(folder + 'Filmaffinity_search.html', pagestr);                //fs2025.01.30

  Count := 0;
  PickTreeClear;
  initchar := '<div class="fa-card">';
  endchar := '<div class="text-center mt-3">';
  Blockestr := initchar + TextBetween(Pagestr, initchar, endchar) + endchar;            //fs2025.02.01 elenco dei film trovati
  if debug_search then
     DumpPage(folder + 'Filmaffinity_search_' + intToStr(count) + '.html', blockestr);                //fs2025.01.30

  PickTreeAdd('Resultados de búsqueda para "' + UrlDecode(MovieName) + '":', '');
  repeat
     initchar := '<a class="d-none d-md-inline-block" ';
     endchar  := '</a>';
     Linestr  := initchar + textbetween(Blockestr, initchar, endchar) + endchar;        //first movie title found
     MovieAddress := textbetween(Linestr,'href="', '"');
     MovieTitle := textbetween(Linestr,'>', endchar);
     MovieTitle := LineDecode(MovieTitle);
//     BlockEstr := StringReplace(BlockEstr, Linestr, '');
     BlockEstr := textafter(BlockEstr, Linestr);

     initchar := '<span class="mc-year ms-1">';
     endchar  := '</span>';
     MovieYear := initchar + textbetween(Blockestr, initchar, endchar) + endchar;       // movie year
//     BlockEstr := StringReplace(BlockEstr, MovieYear, '');
     BlockEstr := TextAfter(BlockEstr, MovieYear);

     HTMLremovetags(MovieYear);
     
     initchar := '<div class="mt-2 mc-director">';
     endchar  := '<div class="mt-2 mc-cast">';
     MovieDirector  := initchar + textbetween(Blockestr, initchar, endchar) + endchar;  // movie director
//     BlockEstr := StringReplace(BlockEstr, MovieDirector, '');
     BlockEstr := TextAfter(BlockEstr, MovieDirector);

     HTMLremovetags(MovieDirector);
     MovieDirector := LineDecode(MovieDirector);
     MovieDirector := fulltrim(MovieDirector);

     PickMessaggio2 := MovieTitle + ' (año ' + MovieYear + ' - ' + + MovieDirector + ')';
     if MovieTitle <> '' then
        begin
        PickTreeAdd(PickMessaggio2, MovieAddress);
        Count := Count + 1;
        end;
     DUMMY := DUMMY;
     if debug_search then
        DumpPage(folder + 'Filmaffinity_search_' + intToStr(count) + '.html', blockestr);     //2025.01.30

  until MovieTitle = '';
//  until linestr = (BeginChar + LastChar);

  DUMMY := DUMMY;
  if Count = 0  then
     begin
     showmessage ('No film found');
     exit;
     end;
  if Count = 1  then
     AnalyzeMoviePage(Address);
//  if Count > 1  then
//     PickTreeExec(Address);
   //-------------------------------------
    if ((Count = 1) and (GetOption('') = 1)) then
      AnalyzeMoviePage(MovieAddress)
    else
      PickTreeExec(Address);            //no movie found
    AnalyzeMoviePage(Address)
//    end

  Page.Free;
end;

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

procedure AnalyzePage(Address: string);
var
  Page: TStringList;
  LineNr,LineNrax: Integer;
  Line: string;
  Count: Integer;
  MovieTitle, MovieAddress, MovieDirector, MovieYear: string;
  YearAnt: string;
  PagSig:String;

begin
  Count := 0;
  Page  := TStringList.Create;
  Page.Text := GetPage(Address);
  PickTreeClear;
   // Get how much search results have been found

   // No encuentra las palabras "Resultados por título"¿?, busco la
   // linea anterior, y cojo la siguiente linea, le quito los espacios
   // y me quedo con el numerode peliculas.

  LineNr := FindLine('<div class="sub-header-search">', Page, 0);
  if LineNr <> -1 then
  begin
    LineNr := LineNr + 1;
    Line   := Page.GetString(LineNr);
    Line   := DeleteTags(Line);
    Line   := ConvertAlphaNum(Line);
    Count  := StrToInt(Line, 0);
  end;
   // Add the results to the PickTree
  if Count = 0 then
  ShowMessage('No se ha encontrado ningún registro')
  else
  begin
    LineNr := 0;
    while true do
    begin
      LineNr := FindLine('<div class="mc-title"><a', Page, LineNr + 1);
      if LineNr = -1 then
      begin
        LineNr := FindLine('siguientes >>', Page, 0);
        if LineNr = -1 then
        break;
        Line      := Page.GetString(LineNr);

        PagSig:=  'https://www.filmaffinity.com/es/search.php' + TextBetween(Line, '<a href="search.php', '"><div class="' );
        PagSig:=StringReplace(PagSig,'&amp;','&');
        Page.Text := GetPage(PagSig);

        LineNr    := 0;
        continue;
      end;

      Line         := Page.GetString(LineNr);
      MovieAddress := TextBetween(Line, 'href="', '.html"') + '.html';
      MovieTitle   := TextBetween(Line, 'title="', '"');
      MovieTitle   := DeleteTags(MovieTitle);
      MovieTitle   := LineDecode(MovieTitle);

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

      Line:= Page.GetString(LineNr-9);
      MovieYear := TextBetween(Line, 'ye-w">', '</div>');
      if MovieYear = '' Then MovieYear := YearAnt
      else YearAnt := MovieYear;

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

      LineNrax := FindLine('div class="mc-director">', Page, LineNr);
      if LineNrax <> -1 then
      begin
        Line:= Page.GetString(LineNrax+1);
        MovieDirector:= TextBetween(Line, 'title="', '"');
        MovieDirector:= DeleteTags(MovieDirector);
        MovieDirector:= LineDecode(MovieDirector);
      end;
         //------------------------------------
      if (Length(MovieAddress) <> 0) and (Length(MovieTitle) <> 0) then
      PickTreeAdd(MovieTitle+'     ('+MovieYear+')'+'        -<'+MovieDirector+'>-', BaseURL + MovieAddress);
    end;
    if ((Count = 1) and (GetOption('DontAsk') = 1)) then
    AnalyzeMoviePage(MovieAddress)
    else
    begin

//
//         PickTreeSort;      // Si se quiere clasificar por orden alfabetico hay que activar el PickTreeSort, quitar las 2
//                            // las 2 barras "//" que hay a la izquierda la instrucción PickTreeSort y ya esta.
//
      PickTreeExec(Address);
      AnalyzeMoviePage(Address)
    end
  end;
  Page.Free;
end;

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

procedure AnalyzeMoviePage(Address: string);
var
  Page: TStringList;
  LineNr, LineInc: Integer;
  Line: string;
  Item: string;
  Comments: string;
  CharStar: string;
  auxItem: string;
begin
  Comments := '';

   // URL
  SetField(fieldURL, Address);

  Page := TStringList.Create;
  Page.Text := GetPage(Address);

   // Translated Title
  LineNr := FindLine('<h1 id="main-title">', Page, 0);
  Line   := Page.GetString(LineNr+1);
  Item   := DeleteTags(TextBetween(Line, '<span itemprop="name">', '</span>'));
  Item   := LineDecode(Item);
  SetField(fieldTranslatedTitle, Item);

   // Picture
  LineNr := FindLine('href="https://pics.filmaffinity.com/', Page, LineNr);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr);
    Item := TextBetween(Line, '<a class="lightbox" style="display: block;" href="', '" title="');
    if Length(Item) = 0 then
    Item := TextBetween(Line, '" src="', '"></a>');
    GetPicture(Item);
  end;

   // Rating
  LineNr := FindLine('<div id="movie-rat-avg" itemprop="ratingValue"', Page, LineNr);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    Item := DeleteTags(Line);
    Item := LineDecode(Item);
    SetField(fieldRating, StringReplace(Item, ',', '.'));
  end;

   // Original Title
  LineNr := FindLine(UTF8Encode('<dt>Título original</dt>'), Page, LineNr);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 1);

      // Eliminar aka
    if Pos('>aka <',Line) <>0 then
    Line:= StringReplace(Line,'>aka <','');

    Item := DeleteTags(TextBetween(Line, '<dd>', '</dd>'));
    Item := LineDecode(Item);
    if Length(Item) = 0 then
    begin
      Line := Page.GetString(LineNr + 2);

      // Eliminar aka
      if Pos('>aka <',Line) <>0 then
      Line:= StringReplace(Line,'>aka <','');

      Item := DeleteTags(Line);
      Item := LineDecode(Item);
    end;
    SetField(fieldOriginalTitle, Item);
  end;

   // Year
  LineNr := FindLine(UTF8Encode('<dt>Año</dt>'), Page, LineNr);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    Item := DeleteTags(TextBetween(Line, '">', '</dd>'));
    Item := LineDecode(Item);
    SetField(fieldYear, Item);
  end;

   // Length
  LineNr := FindLine(UTF8Encode('<dt>Duración</dt>'), Page, LineNr);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    Item := DeleteTags(TextBetween(Line, 'duration">', 'min.</dd>'));
    Item := LineDecode(Item);
    SetField(fieldLength, Item);
  end;

   // Country
  LineNr := FindLine(UTF8Encode('<dt>País</dt>'), Page, LineNr);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    Item := DeleteTags(TextBetween(Line, 'alt="', '"></span'));
    Item := LineDecode(Item);
    SetField(fieldCountry, Item);
  end;

   // Director
  LineNr := FindLine(UTF8Encode('class="directors">'), Page, LineNr);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    Item := TextBetween(Line, '<span itemprop="name">', '</div>');
    Item := LineDecode(Item);
    Item := DeleteTags(Item);
    SetField(fieldDirector, Item);
  end;

   // Script writer
  LineNr := FindLine(UTF8Encode('<dt>Guion</dt>'), Page, LineNr);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    Item := TextBetween(Line, '<span class="nb">', '</div>');
    Item := LineDecode(Item);
    Item := DeleteTags(Item);
    if ((CheckVersion(4,2,0) = true) and (GetOption('Force350') = 0)) then SetField(fieldWriter, Item)
    else   Comments := Comments + 'Guión: ' + Item + #13#10 + #13#10;
  end;

   // Actors
  LineNr := FindLine(UTF8Encode('<div class="cast-wrapper">'), Page, LineNr);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    Item := LineDecode(Line);
    Item := StringReplace(Item, '</li>', ', ');
    Item := DeleteTags(Item);
    Item := Trim(StringReplace(Item, ' Ver todos los créditos', ''));
    while StrGet(Item, Length(Item)) = ',' do
    begin
      Item := Copy(Item, 1, Length(Item) - 1);
    end;
    if GetOption('ActorsInALine') = 0 then
      Item := StringReplace(Item, ', ', #13#10);
    SetField(fieldActors, Item);
  end;

   // Composer
  LineNr := FindLine(UTF8Encode('<dt>Música</dt>'), Page, LineNr);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    Item := TextBetween(Line, '<span class="nb">', '</div>');
    Item := LineDecode(Item);
    Item := DeleteTags(Item);
    if ((CheckVersion(4,2,0) = true) and (GetOption('Force350') = 0)) then SetField(fieldComposer, Item)
    else Comments := Comments + 'Música: ' + Item + #13#10 + #13#10;
  end;

   // Photography
  LineNr := FindLine(UTF8Encode('<dt>Fotografía</dt>'), Page, LineNr);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    Item := TextBetween(Line, '<span class="nb">', '</div>');
    Item := LineDecode(Item);
    Item := DeleteTags(Item);
    Comments := Comments + 'Fotograf&iacute;a: ' + Item + #13#10 + #13#10;
  end;

// Productor
  LineNr := FindLine(UTF8Encode('<dt>Compañías</dt>'), Page, LineNr);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 2);
    Item := TextBetween(Line, '<span class="nb">', '</div>');
    Item := LineDecode(Item);
    Item := DeleteTags(Item);
    SetField(fieldProducer, Item);
  end;

   // Category
  LineNr := FindLine(UTF8Encode('<dt>Género</dt>'), Page, LineNr);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 2);
    Item := DeleteTags(Line);
    Item := LineDecode(Item);
    Item := StringReplace(Item, ' | ', ', ');
    Item := StringReplace(Item, '. ', ', ');
    SetField(fieldCategory, Item);
  end;

   // Official Webpage
  LineNr := FindLine(UTF8Encode('<dt>Web oficial</dt>'), Page, LineNr);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    Item := DeleteTags(TextBetween(Line, ' href="', '">'));
    Item := LineDecode(Item);
    Comments := Comments + 'Web oficial: ' + Item + #13#10 + #13#10;
  end;

   // Synopsis
  LineNr := FindLine(UTF8Encode('<dt>Sinopsis</dt>'), Page, LineNr);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr + 1);
    Item := DeleteTags(Line);
    Item := LineDecode(Item);
    SetField(fieldDescription, Item);
  end;

   // Awards
  LineNr := FindLine(UTF8Encode('<dt>Premios</dt>'), Page, LineNr);
  if LineNr <> -1 then
  begin
    LineNr   := LineNr + 1;
    Line     := Page.GetString(LineNr);
    Comments := Comments + 'Premios: ' + #13#10;
    while Pos ('</dd>', Line) = 0 do
    begin
      if Pos ('<span id="show-all-awards">', Line) = 0 then
      begin
        Item := DeleteTags(Line);
        Item := LineDecode(Item);
        if (Length(Item) <> 0) then
        begin
          Comments := Comments + '  - ' + Item + #13#10;
        end;
      end;
      LineNr := LineNr + 1;
      Line   := Page.GetString(LineNr);
    end;
    Comments := Comments + #13#10;
  end;

   // Critic
  LineNr := FindLine(UTF8Encode('<dt>Críticas</dt>'), Page, LineNr);
  if LineNr <> -1 then
  begin
      // El unico objeto de esta linea es poder presentar en el foro el listado
      // del script sin que se produzca la conversión del caracter estrella

    CharStar       := '&'+'#9733;';
    Comments := Comments + 'Críticas: ' + #13#10 + #13#10;
    LineNr := FindLine('<div class="pro-review"', Page, LineNr + 1);
    while LineNr <> -1 do
    begin
      LineNr := LineNr + 2;
      Line := Page.GetString(LineNr);
      if Pos (UTF8Encode('<a title="Leer crítica completa" href='), Line) <> 0 then
      begin
        LineNr := LineNr + 1;
        Line := Page.GetString(LineNr);
      end;
      Line:= StringReplace(Line, CharStar, '*');
      Item := DeleteTags(Line);
      Item := LineDecode(Item);
      if (Length(Item) <> 0) then
      begin
        Comments := Comments + Item + #13#10;
        LineNr := FindLine('div class="pro-crit-med"', Page, LineNr + 1);
        Line := Page.GetString(LineNr);
        Item := DeleteTags(TextBetween(Line, ' itemprop="author">', '<i'));
        Item := LineDecode(Item);
        if (Length(Item) <> 0) then
        begin
          Comments := Comments + Item + #13#10;
        end;
        Comments := Comments + '________________________________________' + #13#10 + #13#10;
      end;
      LineNr := FindLine('<div class="pro-review"', Page, LineNr + 1)
    end;
  end;

  HTMLDecode(Comments);
  SetField(fieldComments, Comments);
  if GetOption('DontWantExtras') = 0 then
  AnalyzeExtras(Page,Address);
end;

//------------------------------------------------------------------------------------
// Extras
procedure AnalyzeExtras(Page: TStringList; Address: string);
var
  LineNr,NumImages,NumTrailers, i,CountC: Integer;
  Line: string;
  TrailersAddress: string;
  ImagesAddress: string;
  ImageTitle: string;
  ExtraIndex: Integer;
  ExtraString: string;
  ExtraURL: string;
  ExtraTagBase: string;
  LimitImages,LimitTrailers,LimitCritics: Integer;

begin
  ExtraTagBase :=  'FA'+TextBetween(Address, '/film', '.html');
  ClearExtrasOfScript;
  LimitImages := StrtoInt (GetParam('ExtraImagesLimit'),0);
  if LimitImages < 0 then LimitImages := 0;
  LimitTrailers := StrtoInt (GetParam('ExtraTrailersLimit'),0);
  if LimitTrailers < 0 then LimitTrailers := 0;
  LimitCritics := StrtoInt (GetParam('ExtraCriticsLimit'),0);
  if LimitCritics < 0 then LimitCritics := 0;

// Enlaces a Criticas
  LineNr := FindLine(UTF8Encode('<dt>Críticas</dt>'), Page, LineNr);
  CountC := 0;
  if LineNr <> -1 then
  begin
    LineNr := FindLine('<div class="pro-review"', Page, LineNr + 1);
    while LineNr <> -1 do
    begin
      LineNr := LineNr + 2;
      Line := Page.GetString(LineNr);
      if Pos (UTF8Encode('<a title="Leer crítica completa" href='), Line) <> 0 then
      begin
        Line := Page.GetString(LineNr);
        ExtraURL:= TextBetween(Line, 'href="', '" ');
        if (Length(ExtraURL))>0 then
        begin
          ExtraIndex := AddExtra();
          SetExtraField(ExtraIndex, extraFieldURL, ExtraURL);
          SetExtraField(ExtraIndex, extraFieldCategory, 'Críticas');
          SetExtraField(ExtraIndex, extraFieldTitle, TextBetween(ExtraURL, '//', '/'));
          SetExtraField(ExtraIndex, extraFieldTag, ExtraTagBase+'C'+IntToStr(ExtraIndex));
        end;
        LineNr := LineNr + 1;
        Line := Page.GetString(LineNr);
      end;
      LineNr := FindLine('<div class="pro-review"', Page, LineNr + 1);
      CountC := CountC+1;
      if CountC = LimitCritics then
      break;
    end;
  end;

   // Imágenes  y Trailers
  NumTrailers := 0;
  NumImages := 0;

  LineNr := FindLine(UTF8Encode('>Tráilers&nbsp;<em>'), Page, 0);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr);
    NumTrailers := StrToInt(TextBetween(Line, '<em>[', ']</em>'),0);
    TrailersAddress := TextBetween(Line, 'href="', '"');
  end

  LineNr := FindLine(UTF8Encode('>Imágenes&nbsp;<em>'), Page, LineNr+1);
  if LineNr <> -1 then
  begin
    Line := Page.GetString(LineNr);
    NumImages := StrToInt(TextBetween(Line, '<em>[', ']</em>'),0);
    ImagesAddress := TextBetween(Line, 'href="', '"');
  end

   // Imágenes
  If NumImages > LimitImages then NumImages := LimitImages;
  if NumImages >0 then
  begin
    Page.Text := GetPage(ImagesAddress);
    LineNr := FindLine(UTF8Encode('<span>Posters</span>'), Page,0);
    if LineNr = -1 then
    LineNr := FindLine(UTF8Encode('<span>Movie Posters</span>'), Page,0);
    if LineNr =-1 then
    LineNr := FindLine(UTF8Encode('<span>Fotogramas</span>'), Page,0);
    if LineNr =-1 then
    LineNr := FindLine(UTF8Encode('span>Otros</span>'), Page,0);
    if LineNr <> -1 then
    begin
      Line := Page.GetString(LineNr);
      for i := 1 to NumImages do
      begin
        LineNr := FindLine('<a href="', Page, LineNr + 1);
        if LineNr <> -1 then
        begin
          Line := Page.GetString(LineNr);
          ExtraString := TextBetween(Line, 'href="', '"');
          ImageTitle := TextBetween(Line, 'Tipo: </strong>', '</div>');
          ExtraIndex := AddExtra();
          if GetOption('GroupImages') = 1 then
          begin
            SetExtraField(ExtraIndex, extraFieldCategory, 'Imágenes');
            SetExtraField(ExtraIndex, extraFieldTitle, ImageTitle);
          end
          else
          begin
            SetExtraField(ExtraIndex, extraFieldCategory, ImageTitle);
            SetExtraField(ExtraIndex, extraFieldTitle, 'Imágenes')
          end;

          SetExtraField(ExtraIndex, extraFieldTag, ExtraTagBase+'I'+IntToStr(ExtraIndex));
          GetExtraPicture(ExtraIndex, ExtraString);
        end;
      end;
    end;
  end;

  If NumTrailers > LimitTrailers then NumTrailers := LimitTrailers;
  if NumTrailers > 0 then
  begin
    Page.Text := GetPage(TrailersAddress);
    LineNr := FindLine(UTF8Encode('>Mostrar video<'),Page,0);
    if LineNr <> -1 then
    begin
      Line := Page.GetString(LineNr);
      for i:= 1 to NumTrailers do
      begin
        LineNr := FindLine('src="', Page,LineNr + 1);
        if LineNr <> -1 then
        begin
          Line := Page.GetString(LineNr);
          ExtraString := TextBetween(Line, 'src="', '"');
          ExtraURL := TextAfter(ExtraString, '//');
          ExtraIndex := AddExtra();
          SetExtraField(ExtraIndex, extraFieldURL, ExtraURL);
          SetExtraField(ExtraIndex, extraFieldCategory, 'Trailers');
          SetExtraField(ExtraIndex, extraFieldTitle, TextBetween(ExtraString, '//', '/'))
          SetExtraField(ExtraIndex, extraFieldTag, ExtraTagBase+'T'+IntToStr(ExtraIndex));
          LineNr := FindLine(UTF8Encode('Mostrar video'), Page,LineNr + 1);
        end;
      end;
    end;
  end;
end;


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

begin
  if (CheckVersion(4,2,2) = false) then
  begin
    if ShowWarning('This script requires a newer version of Ant Movie Catalog, at least the version 4.2.2, currently available as beta - do you wish to open the link to download it?)') = true then
    begin
      Launch('https://forum.antp.be/phpbb3/viewtopic.php?f=6&t=6862', '');
    end;
    exit;
  end;

  MovieName     := GetField(fieldOriginalTitle);
  MovieYear     := GetField(fieldYear);

  YearFrom      := MovieYear;
  YearTo        := MovieYear;

  AdvQuery      := '/es/advsearch.php';

  if Length(MovieName) = 0 then
  MovieName := GetField(fieldTranslatedTitle);

  if GetOption('DontAsk') = 0 then
  Input('FilmAffinity', 'Título: ' + GetField(fieldFilePath), MovieName);

  if Pos('filmaffinity.com', MovieName) > 0 then
  AnalyzeMoviePage(MovieName)
  else
  begin
    //MovieName := UTF8Encode(MovieName);
    AdvQuery := AdvQuery + '?stext=' + UrlEncode(MovieName);

    if GetOption('SearchByFromToYears') = 1 then
    begin
      if GetOption('DontAsk') = 0 then
      begin
        Input('FilmAffinity', 'Desde el año: ', YearFrom);
        Input('FilmAffinity', 'Hasta el año: ', YearTo);
      end;
      AdvQuery := AdvQuery + '&fromyear=' + YearFrom;
      AdvQuery := AdvQuery + '&toyear=' + YearTo;
    end;

    {
    stype[]=title         Título
    stype[]=director      Director
    stype[]=cast          Reparto
    stype[]=script        Guión
    stype[]=photo         Fotografía
    stype[]=music         Música
    stype[]=producer      Productor
    }

    if GetOption('SearchByTitle') = 1 then
    AdvQuery := AdvQuery + '&stype[]=title';

    if GetOption('SearchByDirector') = 1 then
    AdvQuery := AdvQuery + '&stype[]=director';

    if GetOption('SearchByCast') = 1 then
    AdvQuery := AdvQuery + '&stype[]=cast';

    if GetOption('SearchByScript') = 1 then
    AdvQuery := AdvQuery + '&stype[]=script';

    if GetOption('SearchByPhoto') = 1 then
    AdvQuery := AdvQuery + '&stype[]=photo';

    if GetOption('SearchByMusic') = 1 then
    AdvQuery := AdvQuery + '&stype[]=music';

    if GetOption('SearchByProducer') = 1 then
    AdvQuery := AdvQuery + '&stype[]=producer';

    if GetOption('SortByYear') = 1 then
    AdvQuery := AdvQuery + '&orderby=year';

    AnalyzeAdvPage(BaseURL + AdvQuery);
  end;
end.
Muchas gracias fulvio53s03. Funciona perfectamente.

Imprescindible que en la carpeta Scripts estén los ficheros StringUtils1.pas y StringUtils7552.pas. Si alguien no los tiene, que descargue el fichero RAR directamente de https://update.antp.be/amc/amc_full.rar y los copie de la carpeta Scripts a la suya.
fulvio53s03
Posts: 763
Joined: 2007-04-28 05:46:43
Location: Italy

Re: [UPD ES] Filmaffinity 4.0

Post by fulvio53s03 »

cinecampillos wrote: 2025-02-05 18:04:29 Imprescindible que en la carpeta Scripts estén los ficheros StringUtils1.pas y StringUtils7552.pas. Si alguien no los tiene, que descargue el fichero RAR directamente de https://update.antp.be/amc/amc_full.rar y los copie de la carpeta Scripts a la suya.
Gracias. lo explicaste perfectamente. :clapping:
Rubendis
Posts: 2
Joined: 2025-02-02 16:07:38

Re: [UPD ES] Filmaffinity 4.0

Post by Rubendis »

Muchísimas Gracias!!

Pero en mi caso probé y llega a pocas busquedas.
Por ejemplo, buscas Superman y llega al 2020 y Batman y llega al 2018 , cuando hay muchas versiones anteriores.
Last edited by Rubendis on 2025-02-06 18:42:52, edited 3 times in total.
antp
Site Admin
Posts: 9647
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Re: [UPD ES] Filmaffinity 4.0

Post by antp »

Thanks for the help and the update!
It is updated on my server now

I really did not had time this week, so it is good that you could work on it.
Radagast
Posts: 19
Joined: 2016-04-22 16:07:15

Re: [UPD ES] Filmaffinity 4.0

Post by Radagast »

fulvio53s03 wrote: 2025-02-04 17:59:53 Actualización con nueva búsqueda de títulos. Comprobado con algunos títulos, déjame saber cómo funciona.
Update with new title search. Checked with some titles, let me know how it works.
Muchísimas gracias Fulvio!!!

Creo haber detectado un pequeño fallo que quizás sea fácil de solucionar en próximas versiones.
Cuando hay un punto y aparte en la sinopsis solo importa hasta el punto y aparte ignorando el resto de la sinopsis.

Me ha pasado en esta serie Star Wars: La remesa mala
Last edited by Radagast on 2025-02-08 20:21:45, edited 1 time in total.
Radagast
Posts: 19
Joined: 2016-04-22 16:07:15

Re: [UPD ES] Filmaffinity 4.0

Post by Radagast »

Rubendis wrote: 2025-02-06 14:06:28 Pero en mi caso probé y llega a pocas busquedas.
Por ejemplo, buscas Superman y llega al 2020 y Batman y llega al 2018 , cuando hay muchas versiones anteriores.
Creo recordar que esto ya viene de antes, tenia un limite en cuanto al número de resultados.
Cuando me pasaba utilizaba la dirección de la película en la casilla de búsqueda del script
yaya2023
Posts: 6
Joined: 2023-03-24 14:37:35

Re: [UPD ES] Filmaffinity 4.0

Post by yaya2023 »

Thanks a lot!
fulvio53s03
Posts: 763
Joined: 2007-04-28 05:46:43
Location: Italy

Re: [UPD ES] Filmaffinity 4.0

Post by fulvio53s03 »

Radagast wrote: 2025-02-08 19:36:43 Creo haber detectado un pequeño fallo que quizás sea fácil de solucionar en próximas versiones.
Cuando hay un punto y aparte en la sinopsis solo importa hasta el punto y aparte ignorando el resto de la sinopsis.

Me ha pasado en esta serie Star Wars: La remesa mala
Updated in viewtopic.php?t=43147 : Actualización para las sinopsis de la serie.
fulvio53s03
Posts: 763
Joined: 2007-04-28 05:46:43
Location: Italy

Re: [UPD ES] Filmaffinity 4.0

Post by fulvio53s03 »

Rubendis wrote: 2025-02-06 14:06:28 Pero en mi caso probé y llega a pocas busquedas.
Por ejemplo, buscas Superman y llega al 2020 y Batman y llega al 2018 , cuando hay muchas versiones anteriores.
¿Has probado a usar la opción
SearchByFromToYears=0|0|0=Sin búsqueda por un año|1=Bus dentro de un período de años
??? :??:
Rubendis
Posts: 2
Joined: 2025-02-02 16:07:38

Re: [UPD ES] Filmaffinity 4.0

Post by Rubendis »

Bueno, pero nio te enojes....... :lol: .No sabia de esa opción ( aparte no entendí la respuesta ) . Como encontrarías la película "Fuego contra Fuego" de 1995? Como Fuego contra Fuego, no existe y como Heat llega a 2020...De Todos modos Gracias Totales, solo traté de avanzar en la solución, cuando sugerían probarlo. Saludos
fulvio53s03
Posts: 763
Joined: 2007-04-28 05:46:43
Location: Italy

Re: [UPD ES] Filmaffinity 4.0

Post by fulvio53s03 »

Rubendis wrote: 2025-02-14 15:07:41 Bueno, pero nio te enojes....... :lol:... Saludos
¡No estoy enojado, por supuesto! :innocent: :hihi:
Buscando lo que me cuentas en la versión española de filmaffinity, encuentro:
https://www.filmaffinity.com/es/search.php?stext=heat
o
https://www.filmaffinity.com/es/search. ... ntra+fuego
¿La película que buscas es una de estas?
raulsara01
Posts: 4
Joined: 2024-09-18 08:26:59

Re: [UPD ES] Filmaffinity 4.0

Post by raulsara01 »

Hola, he instalado el ultimo script y en la busqueda enseña muy pocas peliculas, antes mostraba muchas mas. Se puede hacer algo para que vuelva a mostrar mas peliculas. Gracias
fulvio53s03
Posts: 763
Joined: 2007-04-28 05:46:43
Location: Italy

Re: [UPD ES] Filmaffinity 4.0

Post by fulvio53s03 »

raulsara01 wrote: 2025-02-15 11:17:23 Hola, he instalado el ultimo script y en la busqueda enseña muy pocas peliculas, antes mostraba muchas mas. Se puede hacer algo para que vuelva a mostrar mas peliculas. Gracias
what film and whatyear are you looking for?
raulsara01
Posts: 4
Joined: 2024-09-18 08:26:59

Re: [UPD ES] Filmaffinity 4.0

Post by raulsara01 »

Gracias por responder fulvio53s03. No se trata de encontrar una pelicula en concreto, ya he visto que se puede buscar por años, me interesaría que salieran el máximo de peliculas. Cuando documento las peliculas en la base de datos, selecciono 50 o 100 o mas peliculas y las voy buscando y cumplimentando, no puedo estar poniendo en cada pelicula el año. Normalmente con las peliculas que muestra ya es suficiente si el titulo es indicativo pero a veces es simple y aparecen muchas peliculas que lo cumplen. Se podría arreglar el script para que salgan mas peliculas?. Gracias
raulsara01
Posts: 4
Joined: 2024-09-18 08:26:59

Re: [UPD ES] Filmaffinity 4.0

Post by raulsara01 »

Hola, he modificado el programa para que se puedan ver todas las peliculas que cumplan con el titulo introducido. Sean las que sean salvo si se pone un titulo generico como "amor" u "hombre" etc que tienen miles de entradas y da un error de time out. En el 99% no habra problema ya que aguanta mas de 1000 resultados.

Antp, te envio por correo el fichero filmaffinity.ifr.

Un saludo
Post Reply