Page 2 of 2

Posted: 2003-02-27 06:50:27
by Saatchi
In genere uso solo lo script IMb e ha sempre funzionato, temo sia un problema del mio computer visto che a te ed altri funziona, perciò ho annunciato l'uscita dello script sul forum di quelli che il pc http://www.quellicheilpc.net/, un importante sito italiano dedicato al Divx.
Ciao e Grazie x la disponibilità.

Posted: 2003-03-03 11:37:51
by stilegojo
Ork, innanzi tutto sei un grande!

Il tuo script funziona molto bene, ma in molti film, la locandina anche se presente, non viene prelevata!

Es: Dragonfly - locandina - NO
Ritorno al futuro - locandina - NO
Aida degli alberi - locandina - NO
La sottile linea rossa- locandina - NO

ecc.

Penso forse che le locandine stiano in diverse Directory e non soltanto in "posters".

Volevo anche dirti, che molti film (Anche se non tutti), hanno le RECENSIONI, che potrebbero essere inserite nel campo "COMMENTI"

Se hai un pò di tempo per perfezionare questo bellissimo Script che hai fatto, te ne sarò riconoscente.

Grazie comunque per lo splendido lavoro che hai fatto fino adesso!

stilegojo

Posted: 2003-03-06 23:48:22
by Ork
[FR] Merci pour les compliments. Les affiches pour les films dont tu parles sont de petites images (150 x 212). C'est dans ces cas-là que mon script ne les importe pas. Je vais le modifier. Pour les commentaires, je pense que ça sera un peu plus long.

[IT] Grazie per i complimenti. Le locandine per i film dei quali parli sono piccole immagini (150 x 212). È in quei casi che mio script non li importa. Sto per modificarlo. Per i recensioni, penso che ci vorrà un po' più tempo.

Posted: 2003-03-07 00:20:38
by Ork
[FR] Pour importer aussi les petites images, j'ai modifié AnalyzeMoviePage. Remplacer les lignes de '//Picture' à 'DisplayResults;' par celles-ci.

[IT] Per importare anche le piccole immagini, ho modificato AnalyzeMoviePage. Sostituire le linee da '//Picture' a 'DisplayResults;' con queste :

Code: Select all

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

Posted: 2003-03-07 09:33:05
by stilegojo
Ork,

sono sempre più sorpreso e compiaciuto per la tua disponibilità e la competenza che dimostri di avere, nel campo della programmazione informatica.

Nel ringraziarti nuovamente, voglio dirti che sei una persona rara, perchè sono poche le persone che mettono il loro lavoro ed il loro tempo, a disposizione degli altri, in maniera così completamente altruistica.

Per le RECENSIONI, fai con calma, sono sicuro che farai un ottimo lavoro.

stilegojo

Posted: 2003-03-08 17:52:55
by stilegojo
Ciao Ork,

ho messo il tuo script nel forum di Divx-Ita, e stà riscuotendo un enorme successo.

Se vuoi visionarlo vai su:

http://membres.lycos.fr/divxita/phpBB2/ ... =2903#2903

Non essendo il sito di Film-Up completo, perchè mancano tanti films, mi hanno chiesto se potresti fare uno script per :

http://it.movies.yahoo.com

Questo naturalmente, se vuoi farlo e se hai un pò di tempo a disposizione.

Ti ringrazio ancora immensamente, il tuo lavoro è prezioso per noi!

stilegojo

Posted: 2003-03-09 03:04:50
by Guest
[FR] Et voici la modification pour obtenir les commentaires. Ca me fait plaisir d'aider et ça me fait travailler mon italien (c'est ici que je l'ai utilisé pour la première fois).

[IT] Ecco la modificazione per ottenere le recensioni. Mi piace aiutare e mi fa esercitarmi al italiano (è qui che l'ho usato per la prima volta).

Code: Select all

// GETINFO SCRIPTING
// FilmUP (IT) import

(***************************************************
 *  Movie importation script for:                  *
 *      FilmUP (IT), http://www.filmup.com         *
 *                                                 *
 * (c) 2003 Louis Francisco ork@everydayangels.net *
 *                                                 *
 *  For use with Ant Movie Catalog 3.4.1           *
 *  www.ant.be.tf/moviecatalog ··· www.buypin.com  *
 *                                                 *
 *  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               *
 ***************************************************)

program FilmUP;
var
  MovieName: string;
  TheMovieAddress: 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;

procedure AnalyzePage(Address: string);
var
  Page: TStringList;
  LineNr: integer;
  BeginPos: integer;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  LineNr := FindLine('<title>FilmUP - Cerca: ', 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: string;
  LineNr,PrevLineNr: Integer;
  BeginPos, EndPos: Integer;
  Field: integer;
begin
  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<>'';

      //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 = '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;

      if Field<>0 then SetField(Field,Line);

    until Field=fieldDescription;
  end;
  
  PrevLineNr := LineNr;
  //Comments
  LineNr := FindLine('">Recensione</a>', Page, PrevLineNr);
  if LineNr > -1 then
  begin
    Line := Page.GetString(LineNr);
    Delete(Line,1,pos('DVD',Line));
    Delete(Line,1,pos('<a href="',Line)+8);
    GetComments('http://www.filmup.com/'+Copy(Line,1,pos('"',Line)-1));
    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('http://www.filmup.com/'+Copy(Line,1,pos('"',Line)-1),'</b> - <img src="/img/star/');
    if Line <> '' then
    begin
      Line := Copy(Line,1,pos('</b> - <img src="/img/star/',Line)-1);
      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://www.filmup.com/'+Copy(Line,1,pos('"',Line)-1), False);
    end;
  end
  else
  begin
    Line := Page.GetString(LineNr);
    Delete(Line,1,pos('<a href="posters/locp/',Line)+8);
    Line := GetLineFromOtherPage('http://www.filmup.com/'+Copy(Line,1,pos('"',Line)-1),'<img src="../loc/500/');
    if Line <> '' then
    begin
      Delete(Line,1,pos('<img src="../',Line)+12);
      GetPicture('http://www.filmup.com/posters/'+Copy(Line,1,pos('"',Line)-1), False);
    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);
    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
    Line := Page.GetString(LineNr);
    BeginPos := pos('<a href="',Line)+9;
    EndPos := pos('" TARGET="_blank"><b>FilmUP - Scheda: ',Line);
    MovieAddress := copy(Line,BeginPos,EndPos-BeginPos);
    Delete(Line,1,EndPos);
    BeginPos := pos('Scheda: ',Line)+8;
    EndPos := pos('</a>',Line);
    MovieTitle := copy(Line,BeginPos,EndPos-BeginPos);
    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('http://www.filmup.com'+MovieAddress);
  end;
  if TheMovieAddress='*' then TheMovieAddress := '';
end;

begin
  if CheckVersion(3,4,1) then
  begin
    TheMovieAddress := '*';
    MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);
    if Input('FilmUP Import', 'Enter the title of the movie:', MovieName) then
    begin
      AnalyzePage('http://www.filmup.com/cgi-bin/search.cgi?q='+UrlEncode(MovieName)+'&ul=%25%2Fsc_%25');
    end;
  end else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.1)');
end.

Posted: 2003-03-09 03:24:32
by Ork
[FR] Légère modification de GetComments pour éviter les blancs en début de ligne.

[IT] Lieve modificazione di GetComments per evitare i bianchi in inizio di riga.

Code: Select all

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;

Posted: 2003-03-09 04:41:23
by Ork
Non essendo il sito di Film-Up completo, perchè mancano tanti films, mi hanno chiesto se potresti fare uno script per :

http://it.movies.yahoo.com
Quel sito mi sembra un po' più complicato di FilmUp. Ma tenterò fare il script.

Posted: 2003-03-09 10:06:39
by antp
Anonymous wrote:[FR] Et voici la modification pour obtenir les commentaires.
Le script est nettement plus compact que la version précédente (8 ko au lieu de 14), c'est normal ou bien il manque un bout ? :D

Posted: 2003-03-09 17:47:01
by stilegojo
Ciao Ork,

ho notato che sei venuto a farci visita nel nostro Forum! :wink:

Avevo dimenticato di dirti che in quel Forum il mio Nick è Gojor, perchè essendo un istruttore di Karate che pratica lo stile Gojo-Ryu (Gojor), ho usato quel nick, mentre nel tuo Forum uso stilegojo (Stile Gojo - Ryu).

Come avrai visto, il tuo script, sta riscuotendo molto successo, e mi fanno continue richieste.

Nel Display Message ho inserito (da usare dalla versione 3.4.1, in poi).

Grazie per gli sforzi ed il lavoro che stai facendo per noi Italiani. :wink:

stilegojo alias Gojor alias Riccardo

Posted: 2003-03-09 19:40:48
by Ork
Le script est nettement plus compact que la version précédente (8 ko au lieu de 14), c'est normal ou bien il manque un bout ?
C'est normal : j'ai dû appuyer un peu trop sur Ctrl-V et le script y était deux fois. Je l'avais remarqué et corrigé mais tu es sûrement passé le récupérer avant.

Posted: 2003-03-12 08:25:28
by stilegojo
Ciao Ork,

scrivo per dirti che un User del nostro Forum "Andrea Cristaudo alias chris), ha redatto lo script per Yahoo Cinema e per Cinematografo.it"

Script per Yahoo Cinema:

Code: Select all

// GETINFO SCRIPTING
// Yahoo!Cinema

(***************************************************
*  Movie importation script for:                  *
*  Yahoo!Cinema (IT), http://it.movies.yahoo.com  *
*                                                 *
* (c) 2003 Andrea Cristaudo achris@tiscalinet.it  *
*                                                 *
*  For use with Ant Movie Catalog 3.4.1           *
*  www.ant.be.tf/moviecatalog ··· www.buypin.com  *
*                                                 *
*  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               *
***************************************************)

program YahooCinema;
var
  MovieName: string;
  TheMovieAddress: 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;

procedure AnalyzePage(Address: string);
var
  Page: TStringList;
  LineNr: integer;
  BeginPos: integer;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  LineNr := FindLine('<font face=arial,helvetica><b>Risulati Film</b>', 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
      begin
        SetField(fieldURL, Address);
        Page.Text := GetPage(Address);
        AnalyzeMoviePage(Page);
      end;
    end
    else
    begin
      SetField(fieldURL, TheMovieAddress);
      Page.Text := GetPage(TheMovieAddress);
      AnalyzeMoviePage(Page);
    end;
  end;
  Page.Free;
end;

procedure AnalyzeMoviePage(Page: TStringList);
var
  Fine: Integer;
  Line: string;
  LineNr: Integer;
  BeginPos, EndPos: Integer;
  Field: integer;
begin
  Fine := 0;
    LineNr := FindLine('<td><font face=arial size=+1 color="#333366"><b>', Page, 0);
  if LineNr > -1 then
  begin
    //Translated Title
    Line := Page.GetString(LineNr);
    HTMLRemoveTags(Line);

    SetField(fieldTranslatedTitle, copy(Line, 1, pos(' (', Line)));
    Delete(Line, 1, pos(' (', Line) + 1);
    Delete(Line, pos(')', Line), pos(')', Line) + 1);
    SetField(fieldYear, Line);

    repeat
      LineNr := LineNr + 1;
      Line := Page.GetString(LineNr);

      if pos('<b>Genere: </b>', Line) = 1 then
        begin
          HTMLRemoveTags(Line);
          Delete(Line, 1, 8);
          SetField(fieldCategory, Line);
        end
      else if pos('<b>Durata: </b>', Line) = 1 then
        begin
          HTMLRemoveTags(Line);
          Delete(Line, 1, 8);
          BeginPos := pos(' - ', Line);

          SetField(fieldLength, copy(Line, 1, BeginPos - 1));

          Delete(Line, 1, BeginPos + 11);
          SetField(fieldCountry, Line);

          LineNr := LineNr + 1;
          Line := Page.GetString(LineNr);
          HtmlRemoveTags(Line);
          SetField(fieldDescription, Line);
        end
      else if pos('<b>Titolo Originale: </b>', Line) = 1 then
        begin
          HTMLRemoveTags(Line);
          Delete(Line, 1, 18);
          SetField(fieldOriginalTitle, Line);
        end
      else if pos('<b>Regia:</b>', Line) <> 0 then
        begin
          LineNr := LineNr + 1;
          Line := Page.GetString(LineNr);
          HtmlRemoveTags(Line);
          SetField(fieldDirector, Line);
        end
      else if pos('<b>Prodotto da:</b>', Line) <> 0 then
        begin
          LineNr := LineNr + 1;
          Line := Page.GetString(LineNr);
          HtmlRemoveTags(Line);
          SetField(fieldProducer, Line);
        end
      else if pos('<b>Attori:</b>', Line) <> 0 then
        begin
          LineNr := LineNr + 1;
          Line := Page.GetString(LineNr);
          HtmlRemoveTags(Line);
          SetField(fieldActors, Line);
        end
      else if pos('alt="Immagine"', Line) <> 0 then
        begin
          Delete(Line, 1, pos('<img ', Line) + 10);
          Delete(Line, pos('" width=', Line), pos('>', Line) + 1);
          GetPicture(Line, False);
        end

      else if Line = '</html>' then
        Fine := 1;
    until Fine = 1;
  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 AddMoviesTitles(Page: TStringList);
var
  LineNr: Integer;
  NewLineNr: Integer;
  Line: string;
  MovieTitle, MovieAddress: string;
  BeginPos, EndPos: Integer;
begin
  TheMovieAddress := '*';
  LineNr := 0;
  LineNr := FindLine('<font face=arial,helvetica><b>Risulati Film</b>',Page,LineNr);
  LineNr := LineNr + 3;
  while LineNr > -1 do
  begin
    Line := Page.GetString(LineNr);
    BeginPos := pos('<li><b><a href="',Line)+16;
    EndPos := pos('">',Line);
    MovieAddress := copy(Line,BeginPos,EndPos-BeginPos);
    Delete(Line,1,EndPos + 1);
    BeginPos := 1;
    EndPos := -1;
    MovieTitle := Line;
    HTMLRemoveTags(MovieTitle);
    HTMLDecode(Movietitle);
    PickTreeAdd(MovieTitle, MovieAddress);

    NewLineNr := FindLine('<li><b><a href="',Page,LineNr+1);
    if NewLineNr <> (LineNr + 1) then
      LineNr := -1
    else
      LineNr := NewLineNr;

    if TheMovieAddress='*' then
      TheMovieAddress := MovieAddress
    else
      TheMovieAddress := '';
  end;
  if TheMovieAddress='*' then TheMovieAddress := '';
end;

begin
  if CheckVersion(3,4,1) then
  begin
    MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);
    if Input('Yahoo!Cinema Import', 'Enter the title of the movie:', MovieName) then
    begin
      AnalyzePage('http://it.search.movies.yahoo.com/search/movies_db_it?mt='+UrlEncode(MovieName));
    end;
  end else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.1)');
end.

Script per Cinematografo.it

Code: Select all

// GETINFO SCRIPTING
// Cinematografo.it

(***************************************************
*  Movie importation script for:                  *
*  Cinematografo.it, http://www.cinematografo.it  *
*                                                 *
* (c) 2003 Andrea Cristaudo achris@tiscalinet.it  *
*                                                 *
*  For use with Ant Movie Catalog 3.4.1           *
*  www.ant.be.tf/moviecatalog ··· www.buypin.com  *
*                                                 *
*  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               *
***************************************************)

program Cinematografo;
var
  MovieName: string;
  TheMovieAddress: string;

function RemoveTabs(Pattern: string): string;
begin
  repeat
    Delete(Pattern, 1, 1);
  until ord(copy(Pattern, 1, 1)) <> 9;

  result := Pattern;
end;

function Space2html(Url: string): string;
var
  Temp : string;
  SpacePos : Integer;
begin
  repeat
    SpacePos := pos(' ', Url);
    if SpacePos <> 0 then
      begin
        Temp := copy(Url, 1, SpacePos -1);
        Delete(Url, 1, SpacePos);
        Temp := Temp + '%20' + Url;
        Url := Temp;
      end;
  until pos(' ', Url) = 0;

  result := Url;
end;

function FillInput(Page: TStringList; LineNr: Integer; Salto: Integer; Field: Integer): Integer;
var
  Line: string;
begin
  LineNr := LineNr + Salto;
  Line := Page.GetString(LineNr);
  HTMLRemoveTags(Line);
  HTMLDecode(Line);
  Line := RemoveTabs(Line);
  SetField(Field, Line);

  result := LineNr;
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;

procedure AnalyzePage(Address: string);
var
  Page: TStringList;
  LineNr: integer;
  BeginPos: integer;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);

  LineNr := FindLine('<font face="Verdana,sans-serif" size="3" color="#FFFFFF"><strong>Titolo film</strong></font>', Page, 0);
  if LineNr = -1 then
  begin
    LineNr := FindLine('<b>La vostra richiesta non trova risposta nell''archivio.</b>', Page, 0);
    if LineNr = -1 then
    begin
      SetField(fieldURL, Address);
      AnalyzeMoviePage(Page);
    end
    else
    begin
      ShowMessage('Nessun film trovato');
    end;
  end
  else
  begin
    PickTreeClear;
    AddMoviesTitles(Page);
    if TheMovieAddress='' then
    begin
      if PickTreeExec(Address) then
      begin
        SetField(fieldURL, Address);
        Page.Text := GetPage(Address);
        AnalyzeMoviePage(Page);
      end;
    end
    else
    begin
      SetField(fieldURL, TheMovieAddress);
      Page.Text := GetPage(TheMovieAddress);
      AnalyzeMoviePage(Page);
    end;
  end;
  Page.Free;
end;

procedure AnalyzeMoviePage(Page: TStringList);
var
  Fine: Integer;
  Line: string;
  LineNr: Integer;
  BeginPos, EndPos: Integer;
  Field: integer;
begin
  Fine := 0;
  LineNr := FindLine('<strong>Titolo Film</strong>', Page, 0);
  if LineNr > -1 then
  begin
    //Translated Title
    LineNr := LineNr + 1;
    Line := Page.GetString(LineNr);
    HTMLRemoveTags(Line);
    Line := RemoveTabs(Line);
    SetField(fieldTranslatedTitle, Line);

    repeat
      LineNr := LineNr + 1;
      Line := Page.GetString(LineNr);

      if pos('<strong>Anno</strong>', Line) <> 0 then
        LineNr := FillInput(Page, LineNr, 2, fieldYear)
      else if pos('<strong>Titolo originale</strong>', Line) <> 0 then
        LineNr := FillInput(Page, LineNr, 1, fieldOriginalTitle)
      else if pos('<strong>Durata</strong>', Line) <> 0 then
        LineNr := FillInput(Page, LineNr, 1, fieldLength)
      else if pos('<strong>Origine</strong>', Line) <> 0 then
        LineNr := FillInput(Page, LineNr, 1, fieldCountry)
      else if pos('<strong>Genere</strong>', Line) <> 0 then
        LineNr := FillInput(Page, LineNr, 1, fieldCategory)
      else if pos('<strong>Produzione</strong>', Line) <> 0 then
        LineNr := FillInput(Page, LineNr, 1, fieldProducer)
      else if pos('<strong>Regia</strong>', Line) <> 0 then
        LineNr := FillInput(Page, LineNr, 1, fieldDirector)
      else if pos('<strong>Trama</strong>', Line) <> 0 then
        LineNr := FillInput(Page, LineNr, 1, fieldDescription)
      else if pos('<strong>Critica</strong>', Line) <> 0 then
        LineNr := FillInput(Page, LineNr, 1, fieldComments)
      else if pos('<strong>Attori</strong>', Line) <> 0 then
        LineNr := FillInput(Page, LineNr, 1, fieldActors)
      else if pos('<img align="right" border="0"', Line) <> 0 then
        begin
          BeginPos := pos('<img align="right" border="0" src="', Line);
          Delete(Line, 1, BeginPos + 35);
          EndPos := pos('">', Line);
          Line := copy(Line, 1, EndPos - 1);
          Line := 'http://www.cinematografo.it/' + Line;
          Line := Space2html(Line);
          GetPicture(Line, False);
        end
      else if pos('<strong>Note</strong>', Line) <> 0 then
        Fine := 1;

    until Fine = 1;
  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 AddMoviesTitles(Page: TStringList);
var
  LineNr: Integer;
  Line: string;
  MovieTitle, MovieAddress: string;
  BeginPos, EndPos: Integer;
begin
  TheMovieAddress := '*';
  LineNr := 0;
  LineNr := FindLine('<a href="/dati/scheda.asp?sch=',Page,LineNr);
  while LineNr > -1 do
  begin
    Line := Page.GetString(LineNr);
    BeginPos := pos('<a href="',Line)+9;
    EndPos := pos('">',Line);
    MovieAddress := 'http://www.cinematografo.it' + copy(Line,BeginPos,EndPos-BeginPos);

    LineNr := LineNr + 1;
    Line := Page.GetString(LineNr);
    MovieTitle := Line;
    HTMLRemoveTags(MovieTitle);
    HTMLDecode(MovieTitle);
    MovieTitle := RemoveTabs(MovieTitle);

    LineNr := LineNr + 5;
    Line := Page.GetString(LineNr);
    HTMLRemoveTags(Line);
    Line := RemoveTabs(Line);

    MovieTitle := MovieTitle + ' (' + Line + ')';

    PickTreeAdd(MovieTitle, MovieAddress);
    LineNr := FindLine('<a href="/dati/scheda.asp?sch=',Page,LineNr+1);

    if TheMovieAddress='*' then
      TheMovieAddress := MovieAddress
    else
      TheMovieAddress := '';
  end;
  if TheMovieAddress='*' then TheMovieAddress := '';
end;

begin
  if CheckVersion(3,4,1) then
  begin
    MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);
    if Input('Cinematografo.it', 'Enter the title of the movie:', MovieName) then
    begin
      AnalyzePage('http://www.cinematografo.it/dati/QUERY.ASP?ty=CONTIENEPAROLE&fi='+UrlEncode(MovieName)+'&submit1=++Cerca++');
    end;
  end else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.1)');
end.
A presto!

stilegojo

Posted: 2003-03-12 09:00:50
by antp
Merci / Thanks ;)

Posted: 2003-03-14 23:57:14
by Ork
[FR] Dans les 2 scripts, la fonction GetLineFromOtherPage est inutile.

[IT] In entrambi gli script, la funzione GetLineFromOtherPage è inutile.

Posted: 2003-03-15 00:27:44
by Ork
[FR] Dans le script pour Yahoo, j'ai repéré deux petits bugs pour les cas où le film n'est pas trouvé.

[IT] Nello script per Yahoo, ho scoperto due errori nei casi che lo film non é trovato.

Code: Select all

// GETINFO SCRIPTING 
// Yahoo!Cinema 

(*************************************************** 
 * Movie importation script for:                   *
 * Yahoo!Cinema (IT), http://it.movies.yahoo.com   *
 *                                                 *
 * (c) 2003 Andrea Cristaudo achris@tiscalinet.it  *
 *                                                 *
 * For use with Ant Movie Catalog 3.4.1            *
 * www.ant.be.tf/moviecatalog ··· www.buypin.com   *
 *                                                 *
 * 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                * ***************************************************) 

program YahooCinema; 
var 
 MovieName: string; 
 TheMovieAddress: 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; 

procedure AnalyzePage(Address: string); 
var 
 Page: TStringList; 
 LineNr: integer; 
 BeginPos: integer; 
begin 
 Page := TStringList.Create; 
 Page.Text := GetPage(Address); 
 LineNr := FindLine('<font face=arial,helvetica size=+1><b>Risultati ricerca</b></font>', 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 
   begin 
    SetField(fieldURL, Address);
    Page.Text := GetPage(Address); 
    AnalyzeMoviePage(Page); 
   end; 
  end 
  else 
  begin 
   SetField(fieldURL, TheMovieAddress); 
   Page.Text := GetPage(TheMovieAddress); 
   AnalyzeMoviePage(Page);
  end; 
 end; 
 Page.Free; 
end; 

procedure AnalyzeMoviePage(Page: TStringList); 
var 
 Fine: Integer; 
 Line: string; 
 LineNr: Integer; 
 BeginPos, EndPos: Integer; 
 Field: integer; 
begin 
 Fine := 0; 
  LineNr := FindLine('<td><font face=arial size=+1 color="#333366"><b>', Page, 0); 
 if LineNr > -1 then 
 begin 
  //Translated Title 
  Line := Page.GetString(LineNr); 
  HTMLRemoveTags(Line); 

  SetField(fieldTranslatedTitle, copy(Line, 1, pos(' (', Line))); 
  Delete(Line, 1, pos(' (', Line) + 1); 
  Delete(Line, pos(')', Line), pos(')', Line) + 1); 
  SetField(fieldYear, Line); 

  repeat 
   LineNr := LineNr + 1; 
   Line := Page.GetString(LineNr); 

   if pos('<b>Genere: </b>', Line) = 1 then 
    begin 
     HTMLRemoveTags(Line); 
     Delete(Line, 1, 8); 
     SetField(fieldCategory, Line); 
    end 
   else if pos('<b>Durata: </b>', Line) = 1 then 
    begin 
     HTMLRemoveTags(Line); 
     Delete(Line, 1, 8); 
     BeginPos := pos(' - ', Line); 

     SetField(fieldLength, copy(Line, 1, BeginPos - 1)); 

     Delete(Line, 1, BeginPos + 11); 
     SetField(fieldCountry, Line); 

     LineNr := LineNr + 1; 
     Line := Page.GetString(LineNr); 
     HtmlRemoveTags(Line); 
     SetField(fieldDescription, Line); 
    end 
   else if pos('<b>Titolo Originale: </b>', Line) = 1 then 
    begin 
     HTMLRemoveTags(Line); 
     Delete(Line, 1, 18); 
     SetField(fieldOriginalTitle, Line); 
    end 
   else if pos('<b>Regia:</b>', Line) <> 0 then 
    begin 
     LineNr := LineNr + 1; 
     Line := Page.GetString(LineNr); 
     HtmlRemoveTags(Line); 
     SetField(fieldDirector, Line); 
    end 
   else if pos('<b>Prodotto da:</b>', Line) <> 0 then 
    begin 
     LineNr := LineNr + 1; 
     Line := Page.GetString(LineNr); 
     HtmlRemoveTags(Line); 
     SetField(fieldProducer, Line); 
    end 
   else if pos('<b>Attori:</b>', Line) <> 0 then 
    begin 
     LineNr := LineNr + 1; 
     Line := Page.GetString(LineNr); 
     HtmlRemoveTags(Line); 
     SetField(fieldActors, Line); 
    end 
   else if pos('alt="Immagine"', Line) <> 0 then 
    begin 
     Delete(Line, 1, pos('<img ', Line) + 10); 
     Delete(Line, pos('" width=', Line), pos('>', Line) + 1); 
     GetPicture(Line, False); 
    end 

   else if Line = '</html>' then 
    Fine := 1; 
  until Fine = 1; 
 end; 
 DisplayResults; 
end; 

procedure AddMoviesTitles(Page: TStringList); 
var 
 LineNr: Integer; 
 NewLineNr: Integer; 
 Line: string; 
 MovieTitle, MovieAddress: string; 
 BeginPos, EndPos: Integer; 
begin 
 TheMovieAddress := '*'; 
 LineNr := 0; 
 LineNr := FindLine('<font face=arial,helvetica><b>Risulati Film</b>',Page,LineNr);
 LineNr := LineNr + 3; 
 while LineNr > 2 do
 begin 
  Line := Page.GetString(LineNr); 
  BeginPos := pos('<li><b><a href="',Line)+16; 
  EndPos := pos('">',Line); 
  MovieAddress := copy(Line,BeginPos,EndPos-BeginPos); 
  Delete(Line,1,EndPos + 1); 
  BeginPos := 1; 
  EndPos := -1; 
  MovieTitle := Line; 
  HTMLRemoveTags(MovieTitle); 
  HTMLDecode(Movietitle); 
  PickTreeAdd(MovieTitle, MovieAddress); 

  NewLineNr := FindLine('<li><b><a href="',Page,LineNr+1); 
  if NewLineNr <> (LineNr + 1) then 
   LineNr := 2
  else 
   LineNr := NewLineNr; 

  if TheMovieAddress='*' then 
   TheMovieAddress := MovieAddress 
  else 
   TheMovieAddress := ''; 
 end; 
 if TheMovieAddress='*' then TheMovieAddress := ''; 
end; 

begin 
 if CheckVersion(3,4,1) then 
 begin 
  MovieName := GetField(fieldOriginalTitle); 
  if MovieName = '' then 
   MovieName := GetField(fieldTranslatedTitle); 
  if Input('Yahoo!Cinema Import', 'Enter the title of the movie:', MovieName) then 
  begin 
   AnalyzePage('http://it.search.movies.yahoo.com/search/movies_db_it?mt='+UrlEncode(MovieName));
  end; 
 end else 
  ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.1)'); 
end.

Posted: 2003-03-15 00:42:41
by Ork
[FR] Le script pour Cinematografo.it ne s'arrête pas s'il n'y a pas d'annotations.

[IT] Lo script per Cinematografo.it non ferma se non c'è note.

Remplacer/Sostituire

Code: Select all

else if pos('<strong>Note</strong>', Line) <> 0 then
par/con

Code: Select all

else if pos('</table>', Line) <> 0 then

Posted: 2003-03-15 15:39:34
by stilegojo
Grazie per le rettifiche!

stilegojo