Page 1 of 2

[REL ITA] Filmup.it: new Release

Posted: 2010-08-11 16:55:55
by fulvio53s03
A new Release of the Script that can extract both old-formatted and new-formatted pages.
Images extraction is OK, too.
Let me know problems you could enconter.

Code: Select all

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

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

[Infos]
Authors=L. Francisco, Pivello, Zandal, Fulvio53s03
Title=FilmUP
Description=Get movie info from Leonardo.FilmUP.it and shows years in picklist (Fulvio53s03)
Site=http://filmup.leonardo.it
Language=IT
Version=1.0.6 - 11.08.2010
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)|03.10.2005 ABNormal: Big 

Posters and Comments again|14.01.2006 ABNormal: Trailer URL| Adeguamento a nuove modalità di lista Film ed estrazione locandine
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=0|0|0=Get Main Actors data (if present) otherwise get Cast field|1=Get Main Actors data (if present) and Cast data
TrailerURL=0|0|0=Normal URL page|1=Trailer URL page (if found)
Poster=0|0|1=Download full-res Poster|0=Download tiny Poster

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

program LeonardoFilmUP;
uses
  StringUtils1;

var
  MovieName, MovieToSearch, MovieTitle: string;
  TheMovieAddress, Pagestr: string;
  comm: String;

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

procedure AnalyzeMoviePage(Page: TStringList);
var
  Line, PreviousLine, NomeHtml, sTemp: string;
  AddrImage: 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
   SetField(fieldDate, DateToStr(Date));
    //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
        begin
        Field := fieldDescription
        end
      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;

   //Trailer
if GetOption('TrailerURL')=1 then begin
LineNr := FindLine('">Trailer</a>', Page, PrevLineNr);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    if Pos('size="2"><a', Line) <> 0 then Delete(Line,1,pos('size="2"><a',Line));
    //if Pos('DVD', Line) <> 0 then Delete(Line,1,pos('DVD',Line));
    Delete(Line,1,pos('href="',Line)+5);
    NomeHtml := Copy(Line,1,pos('"',Line)-1);
    if (copy(NomeHtml,1,1)<>'/') then
    begin
      NomeHtml := '/' + NomeHtml;
    end;
NomeHtml :='http://filmup.leonardo.it' + NomeHtml;
    comm := textbetween(GetPage(NomeHtml),'<EMBED SRC="','"');
//HTMLRemoveTags(comm);
//Fulvio  SetField(fieldURL,comm);
    PrevLineNr := LineNr;
  end;
end;

  //Comments
  LineNr := FindLine('">Recensione</a>', Page, PrevLineNr);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    if Pos('Scheda', Line) <> 0 then Delete(Line,1,pos('Scheda',Line));
    if Pos('DVD', Line) <> 0 then Delete(Line,1,pos('DVD',Line));
    Delete(Line,1,pos('href="',Line)+5);
    NomeHtml :=Copy(Line,1,pos('"',Line)-1);
    if (copy(NomeHtml,1,1)<>'/') then
    begin
      NomeHtml := '/' + NomeHtml;
    end;
    comm := textbetween(GetPage(NomeHtml),'<font face="arial,helvetica" size="2"><b>','<a class="filmup" href="opinioni.htm">');
    comm := TextAfter(comm,'</b><br>'+#13#10);
    HTMLRemoveTags(comm);
    SetField(fieldComments,comm);
    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('href="',Line)+5);
    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 // start fulvio53s03 Code
    LineNr := FindLine('<img src="locand/', Page, PrevLineNr);
  if LineNr > -1 then
    begin
      Line := Page.GetString(LineNr);
      AddrImage := TextBetween(Line, '<img src="', '" width="');
      AddrImage := 'http://filmup.leonardo.it/' + AddrImage;
      GetPicture(AddrImage);
    end;

  if GetOption('Poster')=1 then
  begin
    LineNr := FindLine('href="posters/locp/', Page, PrevLineNr);  //cerca Poster grande
    if LineNr > -1 then
    begin
      Line := Page.GetString(LineNr);
      AddrImage := TextBetween(Line, 'href="posters/locp/', '" target="_blank"');
      AddrImage := 'http://filmup.leonardo.it/posters/loc/500/' + AddrImage;
      AddrImage := StringReplace(AddrImage, '.htm', '.jpg');
      GetPicture(AddrImage);

//      http://filmup.leonardo.it/posters/locp/toystory2.htm
//      http://filmup.leonardo.it/posters/loc/500/toystory2.jpg

//      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;
  end;
//Picture // start fulvio53s03 Code
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;

function MyTrim(Value: string):string;
var
  ExitLoop: Boolean;
  NewField, OldField: String;
  OldLgthValue, NewLgthValue: integer;
begin
    NewField := ' ';
    OldField := #9;
    value := StringReplace(Value, OldField, NewField);
    OldField := #10;
    value := StringReplace(Value, OldField, NewField);
    OldField := #13;
    value := StringReplace(Value, OldField, NewField);
    OldField := '  ';
    value := StringReplace(Value, OldField, NewField);
    Newfield := '&';
    OldField := '&';
    value := StringReplace(Value, OldField, NewField);
    ExitLoop := False;
    OldLgthValue := length(Value);
    repeat
      value := StringReplace(Value, OldField, NewField);
      NewLgthValue := length(Value);
    if  OldLgthValue = NewLgthValue then
        ExitLoop := True
    else
        OldLgthValue := NewLgthValue;
    until ExitLoop;

  Result := '';
  HTMLRemoveTags(Value);
  Result := Value;
end;


//
procedure AddMoviesTitles;
var
  LineNr, CharToDelete: Integer;
  Line, Blocco: string;
  MovieAddress, MovieAnno: string;
  BeginPos, EndPos: Integer;
  begin
//fulvio  LineNr := FindLine('FilmUP - Scheda: ',Page,LineNr);
    Pagestr := '<DL>' + Textbetween(Pagestr, '<DL>', 'Risultati della ricerca:<br>');     //estrae tabella dei risultati
    Blocco := Textbetween(Pagestr, '<DL>', '</DL>');         //estrae elemento della tabella
    CharToDelete := Length(Blocco) + 9;    //lgth dati estratti + lgth delimiters estrazione
  while CharToDelete > 9 do
    begin
    MovieAddress := TextBetween(Blocco, '<a class="filmup" href="', '" TARGET="_blank">');
    MovieTitle := '<span' + TextBetween(Blocco, '<span', '</a>') + '</a>';
    MovieTitle := Mytrim(MovieTitle);
//    HTMLRemoveTags(MovieTitle);
//    HTMLDecode(Movietitle);
//**************
  MovieAnno := TextBetween(Blocco, 'Anno: ', ' Genere');
  MovieTitle := MovieTitle + ' [' + MovieAnno + ']';
  MovieTitle := StringReplace(MovieTitle, 'FilmUP - Scheda: ', '');
  MovieTitle := StringReplace(MovieTitle, ' / FilmUP.com ', '');
  If Length(MovieAnno) > 0 then
     PickTreeAdd(MovieTitle, MovieAddress);
  if TheMovieAddress='*' then
     TheMovieAddress := MovieAddress
  else
     TheMovieAddress := '';
//**************

    delete(Pagestr, 1, CharTodelete)
    Blocco := Textbetween(Pagestr, '<DL>', '</DL>');
    CharToDelete := Length(Blocco) + 9;    //lgth dati estratti + lgth delimiters estrazione
//    delete(Pagestr, 1, CharTodelete)
//  end;

  end;
//Fulvio  LineNr := FindLine('Successivo',Page,LineNr);
//Fulvio  Line := Page.GetString(LineNr);
//Fulvio  BeginPos := pos('HREF',Line);
//Fulvio  if BeginPos>0 then
//Fulvio  begin
//Fulvio    Delete(Line,1,BeginPos + 5);
//Fulvio    EndPos := pos('"',Line);
//Fulvio    MovieAddress := copy(Line,1,EndPos-1);
//Fulvio    PickTreeMoreLink(MovieAddress);
//Fulvio  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
    MovieToSearch:=StringReplace(MovieName, ' ', '+');
//Fulvio  ricerca per 'Termini contenuti':
// &ul=%25%2Fsc_%25&x=60&y=11&m=all&wf=0020&wm=sub&sy=0
    AnalyzePage('http://filmup.leonardo.it/cgi-bin/search.cgi?ps=100&fmt=long&q='+MovieToSearch+'&ul=%25%2Fsc_%25&x=60&y=11&m=all&wf=0020&wm=sub&sy=0');
//Fulvio  ricerca per 'Termini esatti':
//    AnalyzePage('http://filmup.leonardo.it/cgi-bin/search.cgi?ps=100&fmt=long&q='+MovieToSearch+'&ul=%25%2Fsc_%25&x=31&y=12&m=all&wf=0020&wm=wrd&sy=0');
    end;
   end
  else
    ShowMessage('Questo script richiede una versione più nuova di Ant Movie Catalog (almeno la versione 3.5.0)');
end.
:)

Posted: 2010-08-11 19:42:57
by antp
From which version did you start? The current one had a version number of 1.0.5 :??:

Posted: 2010-08-11 20:12:34
by fulvio53s03
Sorry, Maybe my starting version was not the last one but, any way, this one is going well....
I hope someone else could verify it, I looked on more than 15 movies and my new version is OK... :ha:

P.S.
I found a way to verify differences from the version I used (1.02) and the Last one (1.05) (using superc of SPFPC).
All differences are now updated and/or renewed in this new version.
I change the version in 1.06 (instead of 1.03) and now, I think, it's all OK.
:)

Bye and thanks for your attention (I'm always the solito pasticcione) :ha:

Posted: 2010-08-12 08:42:53
by antp
Thanks for your work :)

Posted: 2010-08-12 12:24:37
by DjDiabolik
Fulvio are great :)

Now appears to working all :)

I have try to found the difference between version 1.0.5 but it's not simple especially when you do not know the language of script.

I have try to found on internet some information about how make a new script but i have not found nothing :(

Posted: 2010-08-13 11:58:30
by DjDiabolik
I have downloaded the news script from the updated script but now i can see it with other script...

Come dicevo dall'altra parte... ora non compare + nella lista tra gli altri script... perchè ?

Posted: 2010-08-13 13:09:01
by fulvio53s03
DjDiabolik wrote:I have downloaded the news script from the updated script but now i can see it with other script...

Come dicevo dall'altra parte... ora non compare + nella lista tra gli altri script... perchè ?
What do you mean?
please, give us more details

Da dove l'hai scaricato?
non compare più? in quale lista? quella caricata con f6?
Che significa? per cortesia, fornisci maggiori dettagli.
:/

Posted: 2010-08-13 13:27:54
by antp
As I said on the other topic, it is my fault: there was an empty line at the top of the script why I copy/pasted it from here.
I re-uploaded it on the server.

Posted: 2010-08-13 18:42:48
by DjDiabolik
Posted problems in PM.

Now the script appear on the list... but i obtain error in line 3.

unit it's not found linea 3 .

*EDIT*
I have the same error with others script! Azz...

*EDIT 2*
Resolved with a Full reinstallation :)

Posted: 2010-08-13 23:32:13
by antp
Your file 'stringutils1.pas' was probably missing/damaged/outdated?

Posted: 2010-08-14 16:22:00
by DjDiabolik
antp wrote:Your file 'stringutils1.pas' was probably missing/damaged/outdated?
No.. i have deleted it... i'm wrong.

Full working after reinstalling all programs :)

Posted: 2010-09-06 10:43:27
by otreux
don't work correctly, it import the thumbnail but not the bigger pic.

Non funziona correttamente, importa la foto piccola e non quella grande

Posted: 2010-09-06 10:48:08
by fulvio53s03
otreux wrote:don't work correctly, it import the thumbnail but not the bigger pic.

Non funziona correttamente, importa la foto piccola e non quella grande
Fornisci ulteriori informnazioni, per cortesia: con quale film?

More informations, plese: which Movie?

Posted: 2010-09-06 16:31:18
by otreux

Posted: 2010-09-06 17:19:06
by fulvio53s03
Sicuro che stai usando lo script con l'opzione 'Poster = 1' ? ;) :??:
Il default è 0 (piccolo poster) ma basta cambiarlo... :hihi:

Posted: 2010-09-06 18:12:16
by otreux
Nello script io ho
In the script I have:

Poster=0|0|1=Download full-res Poster|0=Download tiny Poster

Cosa devo cambiare?
What I must change?

Posted: 2010-09-06 19:06:53
by fulvio53s03
otreux wrote: Poster=0|0|1=Download full-res Poster|0=Download tiny Poster
puoi cambiare in:
Poster=1|0|1=Download full-res Poster|0=Download tiny Poster

ma non è questo il metodo giusto: devi guardare nella parte desta della pagina di esecuzione degli script e li' modificare l'opzione di esecuzione.
ciao.
;)

Posted: 2010-09-06 19:51:37
by otreux
Fantastico, non avevo vista questa opzione.

Fantastic, It work perfectly, many thank's :)

Posted: 2010-12-30 07:52:49
by Nobody72
Ciao Fulvio. grazie per tutto. Il mio script di filmup continua ad estrarre l'immagine con pessima risoluzione. non so cosa fare. Se puoi dammi una mano. ciao

Posted: 2010-12-30 08:15:04
by Nobody72
Riciao Fulvio! finalmente ho capito cosa non andava. mi è bastato cambiare l'1 con lo 0 nello script del poster ed ora l'immagine viene scaricata in formato più grande. Nello script c'è l'1 ..io ho messo lo zero ed ora funziona. Spero di essermi spiegato. ciao