[UPD ITA] Asianworld.it

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

[UPD ITA] Asianworld.it

Post by fulvio53s03 »

Un aggiornamnto dello script Asianworld; estrae informazioni dalle due sezioni principale: Sottotirtoli e DVD pubblicati; in genere la prima sezione è più completa.


An update to the script.
It extracts informations from both Asianworld's sections: subtitles and DVD.
Usually the first is more rich in informations to extract....

Code: Select all

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

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

[Infos]
Authors=Fulvio53s03 based on original script by L.Francisco
Title=AsianWorld
Description=Get movie info from www.AsianWorld.it
Site=http://www.asianworld.it
Language=IT
Version=1.0.3 -  2.09.2010
Requires=3.5.1
Comments=**Changes**|ABNormal did it
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]
EmuleClearer=0|0|0=Title as is|1=Title without ".","_" & "[...]"

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

program AsianWorld;
uses
  StringUtils7552;

var
  MovieName, Pagestr, indirizzo, indirizzosub, indirizzoDVD: string;
  TheMovieAddress: string;
  Italia, comm: String;
  TrovatiSub: integer;

procedure AnalyzePagesub(Address: string);
var
  Page: TStringList;
  LineNr: integer;
  BeginPos: integer;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  Pagestr := Page.Text;
//  Pagestr := GetPage(Address);
  LineNr := FindLine('id_subq', Page, 0);
  if LineNr = -1 then
    begin
      TrovatiSub := 0;
      SetField(fieldURL, 'Error ' + Address);
      AnalyzeMoviePageSub(Page);
    end
  else
    begin
      PickTreeClear;
      AddMoviesTitlesFromSubPage(Page);
      if TheMovieAddress='' then
        begin    // risultati multipli  oppure 0
//fulvio          if PickTreeExec(Address) then    //qui mostra la maschera di non trovato
//fulvio             TheMovieaddress := Address;
          Page.Text := GetPage(TheMovieAddress);
          Pagestr := Page.Text;
          SetField(FieldUrl, TheMovieAddress);
          AnalyzeMoviePageSub(Page);
          //AnalyzePagesub(Address);
        end
      else
        begin    // solo 1 risultato
          SetField(fieldURL, TheMovieAddress);
          Page.Text := GetPage(TheMovieAddress);
          Pagestr := Page.Text;
          AnalyzeMoviePageSub(Page);
        end;
      end;

  Page.Free;
end;

procedure AnalyzePageDVD(Address: string);
var
  Page: TStringList;
  LineNr: integer;
  BeginPos: integer;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  Pagestr := Page.Text;
  LineNr := FindLine('id_subq', Page, 0);
  if LineNr = -1 then
    begin
      TrovatiSub := 0;
      SetField(fieldURL, 'Error ' + Address);
      AnalyzeMoviePageDVD(Page);
    end
  else
    begin
//      PickTreeClear;
      AddMoviesTitlesFromDVDPage(Page);
      if TheMovieAddress='' then
        begin    // risultati multipli  oppure 0
          if PickTreeExec(Address) then
             TheMovieaddress := Address;
          if Length(TheMovieAddress) > 0 then
             begin
             Page.Text := GetPage(TheMovieAddress);
             Pagestr := Page.Text;
             SetField(FieldUrl, TheMovieAddress);
             if pos('dvdrisultato.php', TheMovieAddress) >0 then
                AnalyzeMoviePageDVD(Page);   //fulvio: viene eseguito questo
             if pos('subrisultato.php', TheMovieAddress) > 0 then
                AnalyzeMoviePageSub(Page);   //fulvio: viene eseguito questo
          end
          //AnalyzePagesub(Address);
        end
      else
        begin    // solo 1 risultato
          SetField(fieldURL, TheMovieAddress);
          Page.Text := GetPage(TheMovieAddress);
          Pagestr := Page.Text;
          AnalyzeMoviePageSub(Page);
        end;
      end;

  Page.Free;
end;

procedure AnalyzeMoviePageSub(Page: TStringList);
var
  Line, Commento, Savecommento, TabComm: string;
  InitChar, EndChar: string;
  LineNr,PrevLineNr, BeginPos, EndPos, Field, PositionComm: Integer;
begin
//setfield (fieldDescription, address);
  SetField(fieldDate, DateToStr(Date));
  LineNr := FindLine('/images/archiviosottotitoli', Page, 0);
  if LineNr > -1 then
  begin
  LineNr := FindLine('maintitle', Page, Linenr);
    Line := Page.GetString(LineNr);
    SetField(fieldTranslatedTitle, textbetween(Line, 'align="center">', '</h3>'));
  LineNr := FindLine('img src', Page, Linenr);
    Line := Page.GetString(LineNr);
    GetPicture(textbetween(Line, 'img src="', '"'));
  LineNr := FindLine('Titolo', Page, Linenr);
    Line := Page.GetString(LineNr);
    SetField(fieldOriginalTitle, textbetween(Line, '</b>', '<br>'));
Linenr := Linenr+1;
    Line := Page.GetString(LineNr);
    SetField(fieldYear, textbetween(Line, '</b>', '<br>'));
Linenr := Linenr+1;
    Line := Page.GetString(LineNr);
    SetField(fieldDirector, textbetween(Line, '</b>', '<br>'));
Linenr := Linenr+1;
    Line := Page.GetString(LineNr);
    SetField(fieldCountry, textbetween(Line, '</b>', '<br>'));
Linenr := Linenr+1;
    Line := Page.GetString(LineNr);
    Comm := textbetween(Line, '</b>', '<br>');
    comm := stringReplace(comm, '- ', '');
    comm := Fulltrim(comm);
    HTMLRemoveTags(comm);
    HTMLDecode(comm);
    SetField(fieldCategory, Comm);
Linenr := Linenr+1;
    Line := Page.GetString(LineNr);
    SetField(fieldActors, textbetween(Line, '</b>', '<br>'));

// prima parte commenti
  Linenr := Linenr+1;
    Line := Page.GetString(LineNr);
    Comm := textbetween(Line, '<b>', '<br>');
    comm := Fulltrim(comm);
    HTMLRemoveTags(comm);
    HTMLDecode(comm);

  LineNr := FindLine('Scarica i sottotitoli', Page, LineNr);
    Line := Page.GetString(LineNr);
    Line := textbetween(Line, 'http://', '">Scarica');
    Line := Fulltrim(Line);
    HTMLRemoveTags(Line);
    HTMLDecode(Line);
    Commento := 'Sottotitoli:   http://' + Line + '    ' + Comm;
// fine prima parte commenti

// descrizione
  PositionComm := pos('Trama e recensione', PageStr);
  Delete(Pagestr, 1, PositionComm-1);
  Endchar := '</div>';
  comm := TextBetween(Pagestr, '<br>', Endchar);
  comm := Fulltrim(comm);
  HTMLRemoveTags(comm);
  HTMLDecode(comm);
  SetField(fieldDescription, comm);
  PositionComm := pos(Endchar, PageStr);
  Delete(Pagestr, 1, PositionComm-1);

// seconda parte commenti   (Voto)
  InitChar := '<div align="center">';
  comm := TextBetween(Pagestr, InitChar, '</div>');
  HTMLRemoveTags(comm);
  HTMLDecode(comm);
  comm := Fulltrim(comm);
  Commento := Commento + '   - ' + Comm + crlf + 'Commenti:';
// fine seconda parte commenti

// terza parte: commenti
  PositionComm := pos(InitChar, PageStr);
  Delete(Pagestr, 1, PositionComm-1);
  Pagestr := TextBetween(Pagestr, 'ipb_table', '</table>');

  SaveCommento := Commento;
  Commento := '';
  TabComm := TextBetween(Pagestr, '<tr class=', '</tr>');
  While Length(TabComm) > 10 do
    begin
// terza parte - Autore Commento
    EndChar := '</td>';
    PositionComm := pos(EndChar, pageStr) + length(EndChar);
    Line := TextBetween(Pagestr, '<td width', EndChar);
    Line := TextBetween(Line, 'href=', '</a>') + '</a>';
    EndChar := '</a>';
    Comm := TextBetween(Line, '>', EndChar);
    HTMLRemoveTags(comm);
    HTMLDecode(comm);
    comm := Fulltrim(comm);
    Commento := Commento + crlf + '- ' + comm;
    Delete(Pagestr, 1, PositionComm - 1);

// terza parte - Voto Commento
    EndChar := '</td>';
    PositionComm := pos(EndChar, pageStr) + length(EndChar);
    Line := '<b>' + TextBetween(Pagestr, '<b>', '</b>') + '</b>';
    Comm := TextBetween(Line, '>', '<');
    HTMLRemoveTags(comm);
    HTMLDecode(comm);
    comm := Fulltrim(comm);
    Commento := Commento + ' - ' + comm;
    Delete(Pagestr, 1, PositionComm - 1);
  
// terza parte - Commento
    EndChar := '</td>';
    PositionComm := pos(EndChar, pageStr) + length(EndChar);
    Line := TextBetween(Pagestr, '<td width', EndChar) + EndChar;
    Comm := TextBetween(Line, '>', '<');
    HTMLRemoveTags(comm);
    HTMLDecode(comm);
    comm := Fulltrim(comm);
    Commento := Commento + ' - ' + comm;

    if comm <> '' then
       SaveCommento := Savecommento + Commento;
    Delete(Pagestr, 1, PositionComm-1);
    TabComm := TextBetween(Pagestr, '<tr class=', '</tr>');
    Commento := '';
  end;

  SetField(fieldComments, SaveCommento);
// fine terza parte commenti

  end;
end;
procedure AnalyzeMoviePageDVD(Page: TStringList);//---------------------------------------
var
  Line, Linestr, Commento, Savecommento, TabComm: string;
  Anno, InitChar, EndChar: string;
  LineNr,PrevLineNr, BeginPos, EndPos, Field, PositionComm, lgthpage: Integer;
  LgthTabComm: integer;
begin
//setfield (fieldDescription, address);
  SetField(fieldDate, DateToStr(Date));
  LineNr := FindLine('/images/asiandvd', Page, 0);
  if LineNr > -1 then
  begin
  LineNr := FindLine('maintitle', Page, Linenr);
    Line := Page.GetString(LineNr);
    comm := textbetween(Line, 'align="center">', '</h3>');
    comm := Fulltrim(comm);
    HTMLRemoveTags(comm);
    HTMLDecode(comm);
    SetField(fieldTranslatedTitle, comm);

    comm := textBetween(pagestr, '<img class="imgnews" src="', '"');
    comm := '//http://www.asianworld.it/' + comm;
    GetPicture(comm);      //http://www.asianworld.it/

    comm := textbetween(Pagestr, '<b>Titolo originale: </b>', '<br>');
    comm := Fulltrim(comm);
    HTMLRemoveTags(comm);
    HTMLDecode(comm);
    SetField(fieldOriginalTitle, comm);

    comm := textbetween(Pagestr, '<b>Nazione e Anno: </b>', '<br>');
    comm := Fulltrim(comm);
    HTMLRemoveTags(comm);
    HTMLDecode(comm);
    Anno := Copy(comm, length(comm) - 3, 4);
//    SetField(fieldYear, StrToInt(Anno, 0));
    SetField(fieldYear, Anno);
    if (anno > '1900') and (anno < '2100') then
        delete(comm, length(comm) - 5, 6);
    SetField(FieldCountry, comm);
    
  Linenr := Linenr+1;
    comm := textbetween(Pagestr, '<b>Regia: </b>', '<br>');
    comm := Fulltrim(comm);
    HTMLRemoveTags(comm);
    HTMLDecode(comm);
    SetField(fieldDirector, comm);

    comm := textbetween(Pagestr, '<b>Generi: </b>', '<br>');
    comm := stringReplace(comm, '- ', '');
    comm := Fulltrim(comm);
    HTMLRemoveTags(comm);
    HTMLDecode(comm);
    SetField(fieldCategory, comm);

    comm := textbetween(Pagestr, '<b>Cast: </b>', '<br>');
    comm := Fulltrim(comm);
    HTMLRemoveTags(comm);
    HTMLDecode(comm);
    SetField(fieldActors, comm);

// prima parte commenti
  Linenr := Linenr+1;

// descrizione
  PositionComm := pos('Trama e recensione', PageStr);
  Delete(Pagestr, 1, PositionComm-1);
  Endchar := '<h3 class=';
  comm := TextBetween(Pagestr, 'Trama e recensione</h3>', Endchar);
  comm := Fulltrim(comm);
  HTMLRemoveTags(comm);
  HTMLDecode(comm);
  SetField(fieldDescription, comm);
  PositionComm := pos(Endchar, PageStr);
  Delete(Pagestr, 1, PositionComm-1);
  lgthpage := length(Pagestr);
  PositionComm := pos('</form>', PageStr);
  Delete(Pagestr, 1, PositionComm-1);
  lgthpage := length(Pagestr);

// Commenti
  InitChar := '<table width=';
  PositionComm := pos(InitChar, PageStr);
  Delete(Pagestr, 1, PositionComm - 1);   //mi posiziono su Pagestr verso l'inizio dei commenti
  Pagestr := TextBetween(Pagestr, InitChar, '</table>');
  Linestr := Pagestr;
// Linestr contiene tutti i commenti
  SaveCommento := Commento;
  Commento := '';
  InitChar := '<tr valign=';
  EndChar  := '<tr valign=';
  TabComm := TextBetween(Linestr, InitChar, EndChar) + EndChar;   //elemento di commento
  LgthTabcomm := length(Tabcomm) + length(initChar) + length(EndChar);
  While LgthTabComm > 0 do
    begin
//  commenti: Voto
    EndChar := '</div>';
    comm := Initchar + TextBetween(Linestr, InitChar, EndChar);
    PositionComm := pos(EndChar, Linestr) + length(EndChar);
    comm := stringreplace(comm, '<img src=', ' ');
    comm := stringreplace(comm, '/images/', '');
    comm := stringreplace(comm, 'star.gif', '  ');
    comm := stringreplace(comm, ' alt="star">', '');
    comm := stringreplace(comm, crlf, '');
    comm := stringreplace(comm, '  ', ' ');
    comm := stringreplace(comm, '|', '');
    HTMLRemoveTags(comm);
//    HTMLDecode(comm);
    comm := Fulltrim(comm);
    Commento := Commento + 'Commenti e voti : ' + Comm;
    Delete(Linestr, 1, PositionComm);

// fine commenti: Voto

// Commenti: autore
    InitChar := '<td width';
    EndChar := '</td>';
    PositionComm := pos(EndChar, Linestr) + length(EndChar);
    Comm := InitChar + TextBetween(Linestr, InitChar, EndChar);
    HtmlRemoveTags(Comm);
    Comm := FullTrim(Comm);
    comm := stringreplace(comm, crlf, '');
    Commento := Commento + crlf + '- ' + Comm;
    Delete(Linestr, 1, PositionComm - 1);
    
// Commenti: descrizione
    InitChar := '<td width';
    EndChar := '</td>';
    PositionComm := pos(EndChar, Linestr) + length(EndChar);
    Comm := InitChar + TextBetween(Linestr, InitChar, EndChar);
    HtmlRemoveTags(Comm);
    comm := stringreplace(comm, crlf, '');
    Comm := FullTrim(Comm);
    Commento := Commento + ' - ' + Comm;

    if comm <> '' then
       SaveCommento := Savecommento + Commento + crlf;
    Delete(Pagestr, 1, LgthTabcomm - 1);
    InitChar := '<tr valign=';
    EndChar  := '<tr valign=';
    Linestr := Pagestr + EndChar;
    TabComm := TextBetween(Linestr, '<tr valign=', '<tr valign=') + EndChar;
    LgthTabcomm := length(Tabcomm) - length(EndChar);
    Commento := '';
  end;

  SetField(fieldComments, SaveCommento);
// fine terza parte commenti

  end;
end;

procedure AddMoviesTitlesFromSubPage(Page: TStringList); //---------------------------------------
var
  PosOption: integer;
  LineNr: Integer;
  Line: string;
  MovieTitle, MovieAddress: string;
  BeginPos, EndPos: Integer;
  begin
  LineNr := 0;
  LineNr := FindLine('option',Page,LineNr);
  Line := TextAfter(Page.GetString(LineNr),'id_subq"');
While pos ('option',Line) > 0 do
  begin
    MovieAddress := 'http://www.asianworld.it/subrisultato.php?id_subq=' + TextBetween(Line, 'option value="', '"');
    MovieTitle := Textbetween(Line,'">','</');
    Line := textafter (Line, '</option>');
    MovieTitle := 'sub: ' + MovieTitle;
    PickTreeAdd(MovieTitle, MovieAddress);
    TrovatiSub := TrovatiSub + 1;
    if TheMovieAddress='*' then
      TheMovieAddress := MovieAddress
    else
      TheMovieAddress := '';
  end;
  if TheMovieAddress='*' then TheMovieAddress := '';
end;

procedure AddMoviesTitlesFromDVDPage(Page: TStringList);//---------------------------------------
var
  LineNr: Integer;
  Line: string;
  MovieTitle, MovieAddress: string;
  BeginPos, EndPos: Integer;
  begin
  LineNr := 0;
  LineNr := FindLine('option',Page,LineNr);
  Line := TextAfter(Page.GetString(LineNr),'id_boxq"');
While pos ('option',Line) > 0 do
  begin
    MovieAddress := 'http://www.asianworld.it/dvditalia/dvdrisultato.php?id_boxq=' + TextBetween(Line, 'option value="', '"');
//    MovieAddress := 'http://www.asianworld.it/dvdesteri/dvdrisultato.php?id_boxq=' + TextBetween(Line, 'option value="', '"');
    MovieTitle := Textbetween(Line,'">','</');
    MovieTitle := 'DVD: ' + MovieTitle;
    Line := textafter (Line, '</option>');
    PickTreeAdd(MovieTitle, MovieAddress);
    if TheMovieAddress='*' then
      TheMovieAddress := MovieAddress
    else
      TheMovieAddress := '';
  end;
  if TheMovieAddress='*' then TheMovieAddress := '';
end;


// -----------------------------
// Questo è il main dello script
// -----------------------------
begin
  if CheckVersion(3,5,0) then
   begin
    TheMovieAddress := '*';
    moviename:= GetField(fieldTranslatedTitle);
    if MovieName = '' then
       MovieName := GetField(fieldOriginalTitle);
    if Input('AsianWorld Import', 'Digita il titolo del film:', MovieName) then
    begin
//    http://www.asianworld.it/dvditalia/cercadvd_titolo.php?box_title=breaking                 uscite in Italia
//    http://www.asianworld.it/dvdesteri/cercadvd_titolo.php?box_title=confession&naz=3&ita=0   uscite Hong Kong
      indirizzosub := 'http://www.asianworld.it/cercasub_titolo.php?sub_title=' + UrlEncode(MovieName);
      indirizzoDVD := 'http://www.asianworld.it/dvditalia/cercadvd_titolo.php?box_title=' + UrlEncode(MovieName);
      Italia := '&naz=1&ita=0';
      AnalyzePagesub(indirizzosub);
//      if TrovatiSub = 0 then
         AnalyzepageDVD(indirizzoDVD);
//       SetField(fieldURL, indirizzoDVD);
//      AnalyzePage('http://www.asianworld.it/dvdesteri/cercadvd_titolo.php?box_title='+UrlEncode(MovieName));
    end;
   end
  else
    ShowMessage('Questo script richiede una versione più nuova di Ant Movie Catalog (almeno la versione 3.5.0)');
end.
:grinking:
antp
Site Admin
Posts: 9665
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks :)
Post Reply