[IT] FilmUp (IT): updated.

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
P
Posts: 1
Joined: 2005-09-16 09:17:22

[IT] FilmUp (IT): updated.

Post by P »

Hi there,
I have updated the FilmUp (IT) script to support the new "Main Actors" (in italian "Attori protagonisti") data field, wich appair on some new pages before the "Cast" data field.

For this case I have added the "ActorsPlusCast" script option:

0: If exist use Main Actors data, otherwise use Cast data.
1: Use Main Actors data (if exist) joined with Cast data.

Regards
P

Code: Select all

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

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

[Infos]
Authors=L. Francisco
Title=FilmUP
Description=Get movie info from LeoFilmUP.it
Site=http://filmup.leonardo.it
Language=IT
Version=1.0.2 - 16.09.2005
Requires=3.5.0
Comments=**Changes**|Pivello: query URL changed|Zandal:  sistemato puntamento a COMMENTS|Pivello: Film site URL selectable instead of FilmUp page URL|dinolib: adapted to v.3.5.0 and little bugfix | ABNormal restarted...|14.04.2005: Fixed infinite loop if description field missing (Pivello)|16.09.2005: Look for new Main Actors data into page; if present select this instead of Cast data (P)|16.09.2005: Added ActorPlusCast option (P)
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]
AlternateURL=0|0|0=Use the FilmUP web site for FieldURL|1=Try to use ufficial movie web site for FieldURL
MezzoVoto=1|1|0=Integer Ratings|1=Ratings with ,5
ActorsPlusCast=1|0|0=Get Main Actors data (if present) otherwise get Cast field|1=Get Main Actors data (if present) and Cast data

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

program LeonardoFilmUP;
uses
  StringUtils1;

var
  MovieName: string;
  TheMovieAddress: string;

procedure AnalyzePage(Address: string);
var
  Page: TStringList;
  LineNr: integer;
  BeginPos: integer;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  LineNr := FindLine('Ordina risultati per', Page, 0);
  if LineNr = -1 then
  begin
    SetField(fieldURL, Address);
    AnalyzeMoviePage(Page);
  end
  else
  begin
    PickTreeClear;
    AddMoviesTitles(Page);
    if TheMovieAddress='' then
    begin
      if PickTreeExec(Address) then AnalyzePage(Address);
    end
    else
    begin
      SetField(fieldURL, TheMovieAddress);
      Page.Text := GetPage(TheMovieAddress);
      AnalyzeMoviePage(Page);
    end;
  end;
  Page.Free;
end;

procedure AnalyzeMoviePage(Page: TStringList);
var
  Line, PreviousLine, NomeHtml, sTemp: string;
  LineNr,PrevLineNr, BeginPos, EndPos, Field: Integer;
  IsMainActors: boolean;
begin
  IsMainActors := false;
  sTemp := '';
  LineNr := FindLine('<font face="arial, helvetica" size="3"><b>', Page, 0);
  if LineNr > -1 then
  begin
    //Translated Title
    Line := Page.GetString(LineNr);
    HTMLRemoveTags(Line);
    SetField(fieldTranslatedTitle, Line);

    repeat
      //Look for next info
      repeat
        LineNr := LineNr + 1;
        Line := Page.GetString(LineNr);
        HTMLRemoveTags(Line);
      until (Line<>'')  or (LineNr > Page.Count);
     
      // Test if 'Trama:' missing
      if ((PreviousLine = 'Data di uscita: ')
      or  (PreviousLine = 'Uscita prevista: ')) and (Line <> 'Trama:') then
        if (copy(Line,1,6)<>'Trama:') then
          Line := 'Trama:' + Line;
      PreviousLine := Line;
     
      //Look for type of line
      if Line = 'Titolo originale: ' then
        Field := fieldOriginalTitle
      else if Line = 'Regia: ' then
        Field := fieldDirector
      else if Line = 'Produzione: ' then
        Field := fieldProducer
      else if Line = 'Nazione: ' then
        Field := fieldCountry
      else if Line = 'Genere: ' then
        Field := fieldCategory
      else if Line = 'Anno: ' then
        Field := fieldYear
      else if Line = 'Durata: ' then
        Field := fieldLength //Special case: get number only
      else if Line = 'Sito ufficiale: ' then
        Field := fieldURL
      else if Line = 'Attori protagonisti: ' then
      begin
        Field := fieldActors;
        IsMainActors := true;
      end
      else if Line = 'Cast: ' then
        Field := fieldActors
      else if Line = 'Trama:' then
        Field := fieldDescription
      else
        Field := 0;

      // I have to add this test, for sometimes the description
      // is on the same line as the tag 'Trama'
      if (copy(Line,1,6)='Trama:') and (length(Line)>6) then
       begin
        Field := fieldDescription;
        Delete(Line,1,6);
        HTMLDecode(Line);
       end
      else
       begin
        //Get values
        LineNr := LineNr + 1;
        Line := Page.GetString(LineNr);
        HTMLRemoveTags(Line);
        HTMLDecode(Line);

        //Special case: Length
        if Field = fieldLength then Line := copy(Line,1,length(Line)-1);
       end;

       //Alternative URL case
       if (field = fieldURL) then
       begin
         if (Length(Line) = 0) or (GetOption('AlternateURL')=0) then      // if WEB url missing or explicitly requested...
           Line := GetField(fieldURL)  // ...restore FilmUp URL
         else
           Line := 'http://'+Line;
       end;

      if Field<>0 then
      begin
       if Field = fieldActors then
       begin
         if IsMainActors then // Remember Main Actors (if present)
         begin
           sTemp := Line;
           IsMainActors := false;
         end
         else
         begin
           if ((GetOption('ActorsPlusCast')=1) and (sTemp<>'')) then
             Line := sTemp + ' Cast: ' + Line
           else
             if sTemp <> '' then
               Line := sTemp;
           SetField(Field,Line);
         end;
       end
       else
         SetField(Field,Line);
      end;
      
    until (Field=fieldDescription) or (LineNr > Page.Count);
  end;

  PrevLineNr := LineNr;
 
  //Comments
  LineNr := FindLine('">Recensione</a>', Page, PrevLineNr);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    if Pos('DVD', Line) <> 0 then Delete(Line,1,pos('DVD',Line));
    if Pos('Scheda', Line) <> 0 then Delete(Line,1,pos('Scheda',Line));
    Delete(Line,1,pos('<a href="',Line)+8);
    NomeHtml :=Copy(Line,1,pos('"',Line)-1);
    if (copy(NomeHtml,1,1)<>'/') then
    begin
      NomeHtml := '/' + NomeHtml;
    end;
    GetComments('http://filmup.leonardo.it'+NomeHtml);
    PrevLineNr := LineNr;
  end;

  //Rating
  LineNr := FindLine('">Opinioni</a>', Page, PrevLineNr);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    Delete(Line,1,pos('Recensione',Line));
    Delete(Line,1,pos('<a href="',Line)+8);
    Line := GetLineFromOtherPage(Copy(Line,1,pos('"',Line)-1),'</b> - <img src="');
    if Line <> '' then
    begin
      Line := Copy(Line,1,pos('</b> - <img src="',Line)-1);
      if GetOption('MezzoVoto')=0 then
 if pos('.',Line)>0 then Line := Copy(Line,1,pos('.',Line)-1);
      SetField(fieldRating,Line);
    end;
    PrevLineNr := LineNr;
  end;

  //Picture
  LineNr := FindLine('<a href="posters/locp/', Page, PrevLineNr);
  if LineNr = -1 then
  begin
    LineNr := FindLine('<img src="locand', Page, PrevLineNr);
    if LineNr > -1 then
    begin
      Line := Page.GetString(LineNr);
      Delete(Line,1,pos('<img src="locand', Line)+9);
      GetPicture('http://filmup.leonardo.it/'+Copy(Line,1,pos('"',Line)-1));
    end;
  end
  else
  begin
    Line := Page.GetString(LineNr);
    Delete(Line,1,pos('<a href="posters/locp/',Line)+8);
    Line := GetLineFromOtherPage('http://filmup.leonardo.it/'+Copy(Line,1,pos('"',Line)-1),'<img src="../loc/500/');
    if Line <> '' then
    begin
      Delete(Line,1,pos('<img src="../',Line)+12);
      GetPicture('http://filmup.leonardo.it/posters/'+Copy(Line,1,pos('"',Line)-1));
    end;
  end;
  //DisplayResults;
end;

function GetLineFromOtherPage(address: string; hint: string): string;
var
  Page: TStringList;
  LineNr: integer;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  LineNr := FindLine(hint, Page, 0);
  if LineNr > -1 then result := Page.GetString(LineNr);
  Page.Free;
end;

procedure GetComments(address: string);
var
  Page: TStringList;
  BeginLine: integer;
  EndLine: integer;
  i: integer;
  Line, Comments: string;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  BeginLine := FindLine('RECENSIONI', Page, 0);
  BeginLine := FindLine('<font face="arial,helvetica" size="2"><b>', Page, BeginLine);
  EndLine := FindLine('<a href="opinioni.htm">Scrivi la tua recensione!</a></font><br><br>', Page, BeginLine);
  for i:= BeginLine+1 to EndLine-1 do
  begin
    Line := Page.GetString(i);
    Line := StringReplace(Line, '<br>', #13#10);
    Line := StringReplace(Line, #13#10#32, #13#10);
    HTMLRemoveTags(Line);
    HTMLDecode(Line);
    Comments := Comments + Line;
  end;
  SetField(fieldComments, Comments);
  Page.Free;
end;

procedure AddMoviesTitles(Page: TStringList);
var
  LineNr: Integer;
  Line: string;
  MovieTitle, MovieAddress: string;
  BeginPos, EndPos: Integer;
  begin
  LineNr := 0;
  LineNr := FindLine('FilmUP - Scheda: ',Page,LineNr);
while LineNr > -1 do
  begin
  MovieAddress := 'http://filmup.leonardo.it/sc_' + TextBetween((Page.GetString(LineNr-1)), '_', '.') + '.htm';
    Line := Page.GetString(LineNr);
  MovieTitle := TextAfter(Page.GetString(LineNr), 'Scheda: ');
      While pos ('<span', MovieTitle) > 0 Do begin
      MovieTitle := TextBefore(MovieTitle, '<span', '') + TextAfter(MovieTitle, 'bold;">');
      end;
      While pos ('</span', MovieTitle) > 0 Do begin
      MovieTitle := TextBefore(MovieTitle, '</span', '') + TextAfter(MovieTitle, '/span>');
      end;
    HTMLRemoveTags(MovieTitle);
    HTMLDecode(Movietitle);
    LineNr := FindLine('FilmUP - Scheda:',Page,LineNr+1);
    PickTreeAdd(MovieTitle, MovieAddress);
    if TheMovieAddress='*' then
      TheMovieAddress := MovieAddress
    else
      TheMovieAddress := '';
  end;
  LineNr := FindLine('Successivo',Page,LineNr);
  Line := Page.GetString(LineNr);
  BeginPos := pos('HREF',Line);
  if BeginPos>0 then
  begin
    Delete(Line,1,BeginPos + 5);
    EndPos := pos('"',Line);
    MovieAddress := copy(Line,1,EndPos-1);
    PickTreeMoreLink(MovieAddress);
  end;
  if TheMovieAddress='*' then TheMovieAddress := '';
end;

// -----------------------------
// Questo è il main dello script
// -----------------------------
begin
  if CheckVersion(3,5,0) then
   begin
    TheMovieAddress := '*';
    MovieName := StringReplace(GetField(fieldTranslatedTitle), '.', ' ');
    if MovieName = '' then
      MovieName := StringReplace(GetField(fieldOriginalTitle), '.', ' ');
While pos ('[', MovieName) > 0 Do begin
  MovieName := TextBefore(MovieName, '[', '') + TextAfter(MovieName, ']');
end;
    if Input('FilmUP Import', 'Digita il titolo del film:', MovieName) then
    begin
      AnalyzePage('http://filmup.leonardo.it/cgi-bin/search.cgi?q='+UrlEncode(MovieName)+'&ul=%25%2Fsc_%25');
    end;
   end
  else
    ShowMessage('Questo script richiede una versione più nuova di Ant Movie Catalog (almeno la versione 3.5.0)');
end.
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks ;)
rampage2
Posts: 4
Joined: 2005-01-04 23:49:57

Post by rampage2 »

Hi, I know I'm a little dumb, but what's the exact name to give to the script?
I tried several ones but they're not recognized by the prog
Thnx
Ramp
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

FilmUP (IT).ifs

You can also directly download it from http://www.antp.be/temp/scripts/
rampage2
Posts: 4
Joined: 2005-01-04 23:49:57

Post by rampage2 »

Thank you
Is it just for version 3.5.0.2 or for the 3.5.0.0 as well?
Ramp
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

It should work in both, but why not upgrade to version 3.5.0.2?
bruzz666
Posts: 1
Joined: 2005-09-29 09:36:24

not work

Post by bruzz666 »

ho scaricato l'ultima versione del programma (3.5.0.2) e l'ultimo aggiornamento di questo script come da primo post, ma ottengo un errore che prima non avevo mai avuto...avvio lo scripy, e durante la ricerca delle informazioni, mi dà per due volte errore "HTTP// 1 BAD REQUEST", supero l'errore e mi vengono date cmq le informazioni relative al film richiesto, ma senza il commento e senza l'immagine grande (me la dà sempre piccola).
sono andato a verificare anke nel sito per lo stesso film, e vedo che il commento è presente e anche l'immagine grande, quindi non è un fatto che quei campi manchino proprio nel sito...anche perchè questo tipo di errore avviene per qualsiasi film io prova a richiedere.

spero in un vostro aiuto.

saluti

Luca
Gioggiolo
Posts: 2
Joined: 2005-10-04 15:26:37

Post by Gioggiolo »

unknow identifier: FINDLINE :??: :??: :??:

---------------------------
Info
---------------------------
MovieCatalog.exe : versione 3.5.0.2 (creata il 29/05/2005 12.51.42)
AMCExchange.dll : versione 1.0.1.6 (creata il 26/06/2004 23.39.24)
AMCReport.exe : versione 1.0.2.2 (creata il 15/01/2005 16.13.58)
MediaInfo.dll : versione 0.6.0.0 (creata il 18/05/2005 23.45.58)
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

This maybe means that your StringUtils1.pas file is too old.
Get it here: http://www.antp.be/temp/scripts/StringUtils1.pas
ABNormal
Posts: 135
Joined: 2005-01-08 08:33:38

Post by ABNormal »

i tried this script, comparing with mine.
i think that some problems remains: during comment infos a error message remains, and picture is the small one.

i worked (in the same days) on these problems, but now my update perfectly works.

error appear because now comments page has some things before that the real comment starts.

picture has no more <a href=" before the link, so no big picture is taken anymore.

i kept your ActorPlusCast option so nothing is lost, everything has only been updated

best reguards
ABNormal
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

And a link to your script:
viewtopic.php?t=2579
So other people can test it too ;)
Post Reply