adorocinema.com

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
cluis_henrique
Posts: 21
Joined: 2010-01-21 00:54:05

adorocinema.com

Post by cluis_henrique »

I made a script for adorocinema.com please test and comment.

Code: Select all

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

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

[Infos]
Authors=Luis Henrique Carneiro
Title=AdoroCinema
Description=Movie importation script for AdoroCinema
Site=www.adorocinema.com
Language=BR
Version=1.0 (27 Janeiro 2010)
Requires=3.5.1
Comments=
License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version.
GetInfo=1

[Options]
Link do site Oficial=0|0|0=Não|1=Sim

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

program AdoroCinema;
uses StringUtils1,StringUtils7552;
var nomeFilme: string;


// simple string procedures

function ra(S : string) : string;
Begin
  S:=StringReplaceAll(S,'ç','c');
  S:=StringReplaceAll(S,'ã','a');
  S:=StringReplaceAll(S,'é','e');
  S:=StringReplaceAll(S,'í','i');
  S:=StringReplaceAll(S,'acute;','');
  S:=StringReplaceAll(S,'tilde;','');
  S:=StringReplaceAll(S,'cedil;','');
  S:=StringReplaceAll(S,'&','');
  Result := S;
End;

function StringReplaceAll(S, Old, New: string): string;
begin
 while Pos(Old, S) > 0 do
 S := StringReplace(S, Old, New);
 Result := S;
end;

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

procedure CutBefore(var Str: string; Pattern: string);
begin
 Str := Copy(Str, Pos(Pattern, Str), Length(Str));
end;
procedure CutAfter(var Str: string; Pattern: string);
begin
 Str := Copy(str, Pos(Pattern, Str) + Length(Pattern), Length(Str));
end;

// Loads and analyses page from internet
procedure AnalyzePage(Address: string);
var
 Page: TStringList;
begin
 Page := TStringList.Create;
 Page.Text := GetPage(Address);
 if Pos('>nome original:<', Page.Text) = 0 then
 begin
 ShowMessage('Nothing found.');
 Exit;
 end
 else
 begin
 PickTreeClear;
 PickTreeAdd('Search results:', '');
 AddMoviesTitles(Page);
 if PickTreeExec(Address) then
     AnalyzeMoviePage(Address);
 end
end;

procedure AnalyzeMoviePage(Address: String);
var
  Page: TStringList;
  LineNr, BeginPos: integer;
  value, value2: string;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  value2:=Address;

  value:=TextBetween(Page.Text,'site oficial</strong>:<a href="','" ');
  SetField(fieldURL, value + '     (' + value2 + ')' );

  value:=ra(TextBetween(Page.Text,'<title>',' - '));
  SetField(fieldTranslatedTitle, value);

  value:=ra(TextBetween(Page.Text,'original</strong>:','</'));
  SetField(fieldOriginalTitle, trim(value));

  value:=TextBetween(Page.Text,'amento</strong>:','</');
  SetField(fieldYear, trim(value));

  value:=TextBetween(Page.Text,' </strong> ','</p>');
  value:=TextBetween(value,'(',')');
  SetField(fieldCountry, trim(value));

  value:=TextBetween(Page.Text,'nero</strong>:','</');
  value:=ra(value);
  SetField(fieldCategory, trim(value));
  
  value:=TextBetween(Page.Text,'dura','/p>');
  value:=ConvertNum(TextBetween(value,'>','<'));
  SetField(fieldLength, trim(value));
  
  value:=TextBetween(Page.Text,'<strong>produ','/li');
  value:=ra(TextBetween(value,'>:','<'));
  SetField(fieldProducer, FullTrim(value));

  value:=TextBetween(Page.Text,'<li><strong>dire','/li');
  value:=ra(TextBetween(value,'>:','<'));
  SetField(fieldDirector, trim(value));

  value:=TextBetween(Page.Text,'elenco:','id="ficha_noticias"');
  value:=FormatText2(value);
  SetField(fieldActors, value);

  value:=TextBetween(Page.Text,'sinopse:</h4></div>','</p></div>');
  value:=ra(FormatText2(value));
  SetField(fieldDescription, value);

  value:=TextBetween(Page.Text,'tica do adorocinema</h4>','src="');
  value:=TextBetween(value,'Rate','"');
  SetField(fieldRating, value);

  value:=TextBetween(Page.Text,'thumb" src="','" width=');
  if (value <> '') and CanSetPicture then GetPicture(value);
  GetPicture(value);

end;

procedure AddMoviesTitles(ResultsPage: TStringList);
var
 Page: string;
 MovieTitle, MovieAddress : String;
begin
 Page := ResultsPage.Text;
 while Pos('>nome original:<', Page) > 0 do
 begin
 CutBefore(Page, '>nome original:<');
 MovieAddress := 'http://www.adorocinema.com/filmes' + TextBetween(Page, '<a href="http://www.adorocinema.com/filmes', '/#');
 CutBefore(Page, '<a href="http://www.adorocinema.com/filmes');
 MovieTitle := TextBetween(Page, 'title="', '">');
 MovieTitle := ra(MovieTitle);
 CutAfter(Page, '<span class="favoritos">');
 PickTreeAdd(MovieTitle, MovieAddress);
 end;
end;

begin
  PickListClear;
  nomeFilme := GetField(fieldTranslatedTitle);
  if (length(nomeFilme)=0) then
    nomeFilme := GetField(fieldOriginalTitle);
  if Input('Importar do Adorocinema', 'Escreve o nome do filme:', nomeFilme) then
  begin
    nomeFilme:=stringreplace(nomeFilme,' ','+');
    AnalyzePage('http://www.adorocinema.com/busca/?criteria='+nomeFilme);
  end;
end.
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Does this replace the version made by Guardião ?
cluis_henrique
Posts: 21
Joined: 2010-01-21 00:54:05

Post by cluis_henrique »

antp wrote:Does this replace the version made by Guardião ?
Yes, because the guardião was not working, and not be directly applied to the www.adorocinema.com
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks.
I changed the version to 2.0 then, to distinguish it from the old script.
Sorry for late reply, I forgot this topic.
cluis_henrique
Posts: 21
Joined: 2010-01-21 00:54:05

New version for the new site structure

Post by cluis_henrique »

Code: Select all

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

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

[Infos]
Authors=Luis Henrique Carneiro
Title=AdoroCinema
Description=Movie importation script for AdoroCinema
Site=www.adorocinema.com
Language=BR
Version=3.0 (08 Outubro 2011)
Requires=3.5.1
Comments=
License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version.
GetInfo=1


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

program AdoroCinema;
uses StringUtils1,StringUtils7552;
var nomeFilme: string;


// simple string procedures

function ra(S : string) : string;
Begin
  S:=StringReplaceAll(S,'ç','c');
  S:=StringReplaceAll(S,'ã','a');
  S:=StringReplaceAll(S,'é','e');
  S:=StringReplaceAll(S,'í','i');
  S:=StringReplaceAll(S,'acute;','');
  S:=StringReplaceAll(S,'tilde;','');
  S:=StringReplaceAll(S,'cedil;','');
  S:=StringReplaceAll(S,'&','');
  Result := S;
End;

function StringReplaceAll(S, Old, New: string): string;
begin
 while Pos(Old, S) > 0 do
 S := StringReplace(S, Old, New);
 Result := S;
end;

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

procedure CutBefore(var Str: string; Pattern: string);
begin
 Str := Copy(Str, Pos(Pattern, Str), Length(Str));
end;
procedure CutAfter(var Str: string; Pattern: string);
begin
 Str := Copy(str, Pos(Pattern, Str) + Length(Pattern), Length(Str));
end;

// Loads and analyses page from internet
procedure AnalyzePage(Address: string);
var
 Page: TStringList;
begin
 Page := TStringList.Create;
 Page.Text := GetPage(Address);
 if Pos('>Titulo Original:<', Page.Text) = 0 then
 begin
 ShowMessage('Nothing found.');
 Exit;
 end
 else
 begin
 PickTreeClear;
 PickTreeAdd('Search results:', '');
 AddMoviesTitles(Page);
 if PickTreeExec(Address) then
     AnalyzeMoviePage(Address);
 end
end;

procedure AnalyzeMoviePage(Address: String);
var
  Page: TStringList;
  LineNr, BeginPos: integer;
  value, value2: string;
begin
  Page := TStringList.Create;
  Page.Text := GetPage(Address);
  value2:=Address;

  //value:=TextBetween(Page.Text,'site oficial</strong>:<a href="','" ');
  //SetField(fieldURL, value + '     (' + value2 + ')' );
  SetField(fieldURL, value2 );
  
  value:='http://media.'+TextBetween(Page.Text,'<img src="http://media.','"');
  if (value <> '') and CanSetPicture then GetPicture(value);
  GetPicture(value);

  value:=ra(TextBetween(Page.Text,'class="item fn">','</span>'));
  SetField(fieldTranslatedTitle, value);

  value:=ra(TextBetween(Page.Text,'original:</strong>','</'));
  value:=TextBetween(value,'(',')');
  SetField(fieldOriginalTitle, trim(value));

  value:=TextBetween(Page.Text,'amento:</strong>',' (');
  SetField(fieldYear, trim(value));

  value:=TextBetween(Page.Text,'amento:</strong>','</p>');
  value:=TextBetween(value,'(',')');
  SetField(fieldCountry, trim(value));
  
  value:=TextBetween(Page.Text,'Dire','/p>');
  value:=TextBetween(value,'>','<');
  SetField(fieldDirector, trim(value));
  
  value:=TextBetween(Page.Text,'Atores:','<p><strong>Dura');
  value:=FormatText2(value);
  SetField(fieldActors, value);

  value:=TextBetween(Page.Text,'Dura','/p>');
  value:=ConvertNum(TextBetween(value,'>','<'));
  SetField(fieldLength, trim(value));
  
  value:=TextBetween(Page.Text,'nero:</strong>','</');
  value:=ra(value);
  SetField(fieldCategory, trim(value));
 
  //value:=TextBetween(Page.Text,'<strong>produ','/li');
  //value:=ra(TextBetween(value,'>:','<'));
  //SetField(fieldProducer, FullTrim(value));

  value:=TextBetween(Page.Text,'"rating nota n','"');
  value:=ConvertNum(value);
  SetField(fieldRating, value);

  value:=TextBetween(Page.Text,'"description">','</p>');
  value:=ra(FormatText2(value));
  SetField(fieldDescription, value);
  
  value:=TextBetween(Page.Text,'<h2><a href="criticas/"','<div class="criticas-outras">');
  value:=RemoveSpaces(ra(FormatText2(value)),true);
  SetField(fieldComments, value);

  SetField(fieldmediatype, 'DVD');
  
  // Producer
  Page.Text := GetPage(Address+'ficha-tecnica-e-premios/');

  value:=TextBetween(Page.Text,'dio:</STRONG','<STRONG>dist');
  value:=TextBetween(value,'>','<');
  SetField(fieldProducer, value);



end;

procedure AddMoviesTitles(ResultsPage: TStringList);
var
 Page: string;
 MovieTitle, MovieAddress : String;
begin
 Page := ResultsPage.Text;
 while Pos('>Titulo Original:<', Page) > 0 do
 begin
 CutBefore(Page, '>Titulo Original:<');
 MovieAddress := 'http://www.adorocinema.com/filmes/' + TextBetween(Page, '<a href="/filmes/', 'comentarios/#f');
 CutBefore(Page, '- </span><a href="/filmes/');
 MovieTitle := TextBetween(Page, 'Titulo Original:</strong> (', ')</p>');
 MovieTitle := ra(MovieTitle);
 CutAfter(Page, '<span class="favoritos">');
 PickTreeAdd(MovieTitle, MovieAddress);
 end;
end;

begin
  PickListClear;
  nomeFilme := GetField(fieldTranslatedTitle);
  if (length(nomeFilme)=0) then
    nomeFilme := GetField(fieldOriginalTitle);
  if Input('Importar do Adorocinema', 'Escreve o nome do filme:', nomeFilme) then
  begin
    nomeFilme:=stringreplace(nomeFilme,' ','+');
    AnalyzePage('http://www.adorocinema.com/busca/?criteria='+nomeFilme);
  end;
end.
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

thanks
ronniewo2
Posts: 14
Joined: 2012-08-03 22:28:41

Post by ronniewo2 »

I finally had some time to rewrite a script that works fine to adorocinema.
Please, comment.

Code: Select all

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

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

[Infos]
Authors=Ronniewo2 (Ronnie Oliveira)
Title=AdoroCinema
Description=Movie importation script for adorocinema.com
Site=http://adorocinema.com
Language=BR
Version=4.00
Requires=3.5.1
Comments=Shows only 20 first results; only can find whole words (this is a bug of the site)...
License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version.
GetInfo=1

[Options]

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

program AdoroCinema;
var MovieName:string;
uses StringUtils1;

procedure AnalyzeFilmPage(Address:string);
var Page:TStringList;
    valor, Pag, Pag2, Text, valor2:String;
    j, i, min, Code, min2:integer;
begin
  Page := TStringList.Create;
  valor:= Address;
  Page.Text:=GetPage(valor);
  SetField(fieldURL,valor);
  
  SetField(fieldMediaType,'DVD');

  i:=FindLine('<p itemprop="description">',Page,0);
  valor:=Page.GetString(i);
  valor:=TextBetween(Page.Text,'<p itemprop="description">'#13#10,'</p>');
  valor:= Utf8Decode(valor);
  HTMLDecode(valor);
  valor:= StringReplace(valor, '<br/>', #13#10);
  HTMLRemoveTags(valor);
  SetField(fieldDescription, valor);

  i:=FindLine('="og:title" content="',Page,0);
  valor:=Page.GetString(i);
  valor:=TextBetween(valor,'t="','" />');
  valor:= Utf8Decode(valor);
  HTMLDecode(valor);
  SetField(fieldTranslatedTitle, valor);

  i:=FindLine('<th>Ano de produ',Page,0);
  valor:=Page.GetString(i);
  valor:=TextBetween(valor,'<th>Ano de produ' , '</span></');
  valor:=TextAfter(valor,'">');
  SetField(fieldYear,valor);

  i:=FindLine('original</th><td>',Page,0);
  valor:=Page.GetString(i);
  valor := TextBetween(valor, 'td>' , '</td>');
  valor:= Utf8Decode(valor);
  HTMLDecode(valor);
  SetField(fieldOriginalTitle, valor);

  Pag:=Page.Text;
  Text:='';
  repeat
    i:=pos('<span itemprop="genre">',Pag);
    if i>0 then begin
       valor:=copy(Pag,i+20,Length(Pag));
       valor := TextBetween(valor, '">' , '</span>');
       valor:= Utf8Decode(valor);
       delete(Pag,i,19);
       Text:=Text+' / '+valor;
    end;
  until i=0;
  Delete(Text,1,3);
  SetField(fieldCategory,Text);

  i:=FindLine('itemprop="duration"',Page,0);
  valor:=Page.GetString(i);
  valor:=TextBetween(valor,'">','</');
  HTMLRemoveTags(valor);
  if copy(valor,2,1)='h' then begin
     Text:=copy(valor,1,1);
     min:=StrToInt(Text,-1);
     if min<>-1 then
        min:=min*60;
  end
  else min:=0;
  Text:=copy(valor,4,1);
  Pag:=copy(valor,5,1);
  if StrToInt(Pag,-1)<>-1 then
     Text:=Text+Pag;
  min2:=StrToInt(Text,-1);
  if min2<>-1 then
     min:=min+min2;
  valor:=IntToStr(min);
  SetField(fieldLength,valor);

  i:=FindLine('itemprop="url" ><span itemprop="name">',Page,0);
  valor:=Page.GetString(i);
  valor := TextBetween(valor, '="name">' , '</span>');
  valor:= Utf8Decode(valor);
  HTMLDecode(valor);
  SetField(fieldDirector,valor);
 
  valor:=Page.Text;
  valor := TextBetween(valor, 'Nacionalidade </span>' , #13#10'</div>');
  valor := TextAfter(valor,'<span class="acLnk');
  valor := TextAfter(valor, '">');
  valor:= Utf8Decode(valor);
  HTMLDecode(valor);
  HTMLRemoveTags(valor);
  SetField(fieldCountry,valor);

  i:=FindLine('<meta property="og:image"',Page,0);
  valor:=Page.GetString(i);
  valor:=TextBetween(valor,'"og:image"','/><');
  valor:=TextBetween(valor,'content="','"');
  //*valor:= StringReplace(valor,'195x289','290x478');
  GetPicture(valor);

  valor:= Address+'/creditos';
  Page.Text:=GetPage(valor);
  Text:='';
  Pag:=TextBetween(Page.Text,'Atores e atrizes','id="production">Topo</span>'#13#10);
  if trim(Pag)='' then
     Pag:=TextBetween(Page.Text,'Atores e atrizes','</table>'#13#10);
  repeat
    i:=FindLine('Personagem:',Page,0);
    valor:=Page.GetString(i-3);
    valor2:=Page.GetString(i);
    Delete(valor2,pos('Personagem:',valor2),12);
    Page.SetString(i,'nothing important');
    valor:=trim(valor);
    valor:=valor+' - '+valor2;
    valor:= StringReplace(valor, #13#10, ' - ');
    valor:=trim(valor);
    HTMLRemoveTags(valor);
    if Length(valor)>1 then
       Text:=Text+#13#10+valor;
  until i=-1;
  
  repeat
       i:=pos('<div class="tab_tooltip',Pag);
       valor:=TextBetween(Pag,'<div class="tab_tooltip',#13#10'</span>');//</a>');
       j:=pos('<span itemprop="name">',valor);
       if j>0 then
          valor:=TextAfter(valor,'<span itemprop="name">'#13#10)
       else begin
          valor:=TextAfter(valor,'">'#13#10);
          valor:=TextAfter(valor,'">'#13#10);
       end;

       valor:=trim(valor);
       valor2:=TextBetween(Pag,'<td>'#13#10,#13#10'</td>');
       valor:=valor+' - '+valor2;
       j:=pos('<td>',Pag);
       Delete(Pag,j,5);
       j:=pos('<td>',Pag);
       Delete(Pag,j,5);
       Delete(Pag,i,23);

       valor:= StringReplace(valor, #13#10, ' - ');
       valor:=trim(valor);
       HTMLRemoveTags(valor);
       if Length(valor)>1 then
          Text:=Text+#13#10+valor;
  until i=0;
  Text:= Utf8Decode(Text);
  valor:=copy(Text,3,Length(Text));
  SetField(fieldActors,valor);

  Page.free;
end;

procedure AnalyzePage(Address: String);
var Page:string;
    i:integer;
    nome, nome2, ano, url, Pag, Search:string;
begin
  PickTreeClear;
  Search:='busca/1/?q='; //1 = filmes
  Page := GetPage(Address+Search+MovieName);
  Pag:=Page;
  repeat
    i:=pos('"margin-top:-5px;">', Pag);
    url:=copy(Pag,i+30,26);
    url:=TextBetween(url,'/','''');
    nome:=copy(Pag,i+30,pos('<br',Pag));
    nome:=TextBetween(nome,'>'#13#10,'<div>');
    nome:=copy(nome,1,Length(nome)-2);
    nome2:=nome;
    ano:=nome;
    nome:=copy(nome,1,pos(#13#10,nome)-1);
    nome2:=copy(nome2,pos(#13#10,nome2)+2,length(nome2));
    ano:=nome2;
    nome2:=copy(nome2,1,pos(#13#10,nome2)-1);
    ano:=TextBetween(ano,'="fs11">'#13#10,'<br />');
    nome:=nome+' '+nome2+' - '+ano;
    nome:= Utf8Decode(nome);
    HTMLRemoveTags(nome);
    delete(Pag,i,19);
    nome:=trim(nome);
    if (length(nome)>2) and (pos('AdoroCinema',nome)=0) then begin
      url:='http://adorocinema.com/'+url;
      PickTreeAdd(nome,url);
    end;
  until i=0;
 if PickTreeExec(Address) then
      AnalyzeFilmPage(Address);
end;


begin
  PickListClear;
  MovieName := GetField(fieldOriginalTitle);
  if Input('Importar do AdoroCinema.com', 'Escreva o nome do filme:', MovieName) then
  begin
    MovieName := StringReplace(MovieName, ' ', '+');
    AnalyzePage('http://adorocinema.com/');
  end;
end. 
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Is it a complete rewrite from nothing, or did you fix the previous script?
In the latter case, it would be better to also keep the name of previous author
ronniewo2
Posts: 14
Joined: 2012-08-03 22:28:41

Post by ronniewo2 »

I rewrote almost 80% of it, and the rest was taken from 2 or 3 other codes. So I didn't feel the needed to include that authors, but, anyway, feel free to include them:

NeiPCs / Guardião / MIKEPAX

And sorry for my mistake...
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

I'll just include that in the comment then ;)
Thanks
tiagoaquino
Posts: 17
Joined: 2011-05-08 19:18:08
Location: Brasil
Contact:

Atualização

Post by tiagoaquino »

A última versão de script q tenho aqui é uma 4.0. Já não funciona com o adorocinema. Alguém atualiza?
ronniewo2
Posts: 14
Joined: 2012-08-03 22:28:41

Post by ronniewo2 »

Here you are:

Code: Select all

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

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

[Infos]
Authors=Ronniewo2 (Ronnie Oliveira)
Title=AdoroCinema
Description=Movie importation script for adorocinema.com
Site=http://adorocinema.com
Language=BR
Version=5.00
Release date=27/12/16
Requires=3.5.1
Comments=Shows only 20 first results; only can find whole words (this is a bug of the site)...|Previous versions by NeiPCs / Guardião / MIKEPAX
License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version.
GetInfo=1
RequiresMovies=1

[Options]

[Parameters]

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

program AdoroCinema;
var MovieName:string;
uses StringUtils1;

procedure AnalyzeFilmPage(Address:string);
var Page:TStringList;
    valor, Pag, Pag2, Text, valor2:String;
    j, i, min, Code, min2:integer;
begin
  Page := TStringList.Create;
  valor:= Address;
  Page.Text:=GetPage(valor);
  SetField(fieldURL,valor);
  
  i:=FindLine('itemprop="aggregateRating"',Page,0);
  valor:=Page.GetString(i+3);
  valor:=TextBetween(valor,' ','</span>');
  valor:= Utf8Decode(valor);
  HTMLDecode(valor);
  HTMLRemoveTags(valor);
  SetField(fieldRating, trim(valor));

  SetField(fieldMediaType,'DVD');

  i:=FindLine('itemprop="description">',Page,0);
  valor:=Page.GetString(i);
  valor:=TextBetween(Page.Text,'itemprop="description">','</p>');
  valor:= Utf8Decode(valor);
  HTMLDecode(valor);
  valor:= StringReplace(valor, '<br/>', #13#10);
  HTMLRemoveTags(valor);
  SetField(fieldDescription, trim(valor));

  i:=FindLine('="og:title" content="',Page,0);
  valor:=Page.GetString(i);
  valor:=TextBetween(valor,'t="','" />');
  valor:= Utf8Decode(valor);
  HTMLDecode(valor);
  SetField(fieldTranslatedTitle, valor);

  i:=FindLine('">Ano de produ',Page,0);
  valor:=Page.GetString(i+1);
  valor:=TextBetween(valor,'">' , '</span>');
  //valor:=TextAfter(valor,'">');
  SetField(fieldYear,valor);

  i:=FindLine('class="that">',Page,0);
  valor:=Page.GetString(i);
  valor := TextBetween(valor, 'class="that">' , '</span>');
  valor:= Utf8Decode(valor);
  HTMLDecode(valor);
  SetField(fieldOriginalTitle, valor);

  Pag:=Page.Text;
  Text:='';
  repeat
    i:=pos('<span itemprop="genre">',Pag);
    if i>0 then begin
       valor:=copy(Pag,i+20,Length(Pag));
       valor := TextBetween(valor, '">' , '</span>');
       valor:= Utf8Decode(valor);
       delete(Pag,i,19);
       Text:=Text+' / '+valor;
    end;
  until i=0;
  Delete(Text,1,3);
  SetField(fieldCategory,Text);

  i:=FindLine('">Data de lan',Page,0);
  valor:=Page.GetString(i+5);
  HTMLRemoveTags(valor);
  valor := trim(valor);
  i:=pos('h',valor);
  min2 := 0;
  if i > 0 then begin
     min2:=StrToInt(copy(valor,i-1,1),-1);
     min:=StrToInt(copy(valor,i+2,2),-1);
     if min2<>-1 then
        min2:=min2*60;
  end
  else min:=0;
  if min2<>-1 then
     min:=min+min2;
  valor:=IntToStr(min);
  SetField(fieldLength,valor);

  i:=FindLine('itemprop="director"',Page,0);
  valor:=Page.GetString(i+1);
  valor := TextBetween(valor, '="name">' , '</span>');
  valor:= Utf8Decode(valor);
  HTMLDecode(valor);
  SetField(fieldDirector,valor);
 
  Text := '';
  j:=1;
  i:=FindLine('<span class="light">Nacionalidade',Page,0);
  repeat
     valor := Page.GetString(i+1);
     if pos('</div>',valor) > 0 then begin
        j := 0;
     end
     else begin
        valor := TextBetween(valor, '">' , '</span>');
        valor := trim(valor);
        if valor <> '' then
           Text:=Text+' / '+valor;
     end;
     i:=i+1;
  until j = 0;
  Delete(Text,1,3);
  valor:= Utf8Decode(Text);
  HTMLDecode(valor);
  HTMLRemoveTags(valor);
  SetField(fieldCountry, trim(valor));

  i:=FindLine('class="shot-img"',Page,0);
  valor:=Page.GetString(i);
  valor:=TextBetween(valor,'data-src="','" alt="');
  //*valor:= StringReplace(valor,'195x289','290x478');
  GetPicture(valor);

  valor:= Address+'creditos/';
  Page.Text:=GetPage(valor);
  Text:='';
  Pag:=TextBetween(Page.Text,'<div id="actors"','<div class="row md-table-row');
  //if trim(Pag)='' then
     //Pag:=TextBetween(Page.Text,'Atores e atrizes','</table>'#13#10);
  repeat
    i:=FindLine('Personagem :',Page,0);
    valor:=Page.GetString(i-5);
    valor2:=Page.GetString(i);
    Delete(valor2,pos('Personagem :',valor2),13);
    Page.SetString(i,'nothing important'); //exclui a linha de referência já utilizada
    HTMLRemoveTags(valor);
    HTMLRemoveTags(valor2);
    valor:=trim(valor)+' ... '+trim(valor2);
    if Length(valor)>5 then
       Text:=Text+#13#10+valor;
  until i=-1;
 
  repeat
       i:=pos('<div class="tab_tooltip',Pag);
       valor:=TextBetween(Pag,'<div class="tab_tooltip',#13#10'</span>');//</a>');
       j:=pos('<span itemprop="name">',valor);
       if j>0 then
          valor:=TextAfter(valor,'<span itemprop="name">'#13#10)
       else begin
          valor:=TextAfter(valor,'">'#13#10);
          valor:=TextAfter(valor,'">'#13#10);
       end;

       valor:=trim(valor);
       valor2:=TextBetween(Pag,'<td>'#13#10,#13#10'</td>');
       valor:=valor+' - '+valor2;
       j:=pos('<td>',Pag);
       Delete(Pag,j,5);
       j:=pos('<td>',Pag);
       Delete(Pag,j,5);
       Delete(Pag,i,23);

       valor:= StringReplace(valor, #13#10, ' - ');
       valor:=trim(valor);
       HTMLRemoveTags(valor);
       if Length(valor)>1 then
          Text:=Text+#13#10+valor;
  until i=0;
  Text:= Utf8Decode(Text);
  valor:=copy(Text,3,Length(Text));
  SetField(fieldActors,valor);

  Page.free;
end;

procedure AnalyzePage(Address: String);
var Page:string;
    i:integer;
    nome, nome2, ano, url, Pag, Search:string;
begin
  PickTreeClear;
  Search:='busca/1/?q=';
  Page := GetPage(Address+Search+MovieName);
  Pag:=Page;
  repeat
    i:=pos('"margin-top:-5px;">', Pag);
    url:=copy(Pag,i+30,100);
    url:=TextBetween(url,'/','''');
    nome:=copy(Pag,i+30,pos('<br',Pag));
    nome:=TextBetween(nome,'>'#13#10,'<div>');
    nome:=copy(nome,1,Length(nome)-2);
    nome2:=nome;
    ano:=nome;
    nome:=copy(nome,1,pos(#13#10,nome)-1);
    nome2:=copy(nome2,pos(#13#10,nome2)+2,length(nome2));
    ano:=nome2;
    nome2:=copy(nome2,1,pos(#13#10,nome2)-1);
    ano:=TextBetween(ano,'="fs11">'#13#10,'<br />');
    nome:=nome+' '+nome2+' - '+ano;
    nome:= Utf8Decode(nome);
    HTMLRemoveTags(nome);
    delete(Pag,i,19);
    nome:=trim(nome);
    if (length(nome)>2) and (pos('AdoroCinema',nome)=0) then begin
      url:='http://www.adorocinema.com/'+url;
      PickTreeAdd(nome,url);
    end;
  until i=0;
 if PickTreeExec(Address) then
      AnalyzeFilmPage(Address);
end;


begin
  PickListClear;
  MovieName := GetField(fieldOriginalTitle);
  if Input('Importar do AdoroCinema.com', 'Escreva o nome do filme:', MovieName) then
  begin
    MovieName := StringReplace(MovieName, ' ', '+');
    AnalyzePage('http://www.adorocinema.com/');
  end;
end. 
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks
Post Reply