[ADD][BR]InterFilmes v1.0 by h0ttz

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
h0ttz
Posts: 2
Joined: 2010-06-09 14:31:47

[ADD][BR]InterFilmes v1.0 by h0ttz

Post by h0ttz »

Então galera, espero que esteja contribuindo com a comunidade.

Criei esse script, com base na atual versão que existe para o site InferFilmes.com, do Guardião.

Corrigi alguns bugs que existiam, por exemplo: quando se realizava busca onde o nome do filme continha o carácter '(' ou ')'.

Itens adicionados no resultado da busca:
- todos os comentários dos usuários sobre o filme.
- produtora

Espero que gostem e que não tenha nenhum problema.

Se por acaso acharem algum bug, relate aqui no fórum.

[]´s

Code: Select all

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

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

[Infos]
Authors=h0ttz ( h0ttzspam@gmail.com )
Title=InterFilmes by h0ttz
Description=Movie importation script for InterFilmes.com
Site=http://www.interfilmes.com
Language=BR
Version=1.00
Requires=3.5.1
Comments=Script feito por h0ttz para o site "http://www.interfilmes.com"|Caso detectem erros, me mande um email: h0ttzspam@gmail.com|
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 InterFilmes;
var MovieName:string; //Iniciado em 08-06-2010
uses StringUtils1;


// Método Para Trazer Dados do Filme
procedure AnalyzeFilmPage(Address:string);
var Page:TStringList;
    valor, valor2:String;
    i:integer;
begin
  Page := TStringList.Create;
  valor:='http://www.interfilmes.com/'+Address;
  valor := StringReplace(valor, 'filme_', 'filme_v1_');
  valor := TextBefore(valor, '-(', '');
  Page.Text:=GetPage(valor+'.html#Elenco');

  // Seta URL
  HTMLDecode(valor);
  SetField(fieldURL,valor);

  // Seta Descrição
  valor:=TextBetween(Page.Text,'<meta name="description" content="','">');
  HTMLRemoveTags(valor);
  HTMLDecode(valor);
  SetField(fieldDescription, trim(valor));

  // Seta Título Original
  i:=FindLine('<u>Título Original:</u>',Page,0);
  valor:=Page.GetString(i+1);
  i:=Pos('<br>',valor);
  valor:=Copy(valor,1,i-1);
  HTMLDecode(valor);
  SetField(fieldOriginalTitle, trim(valor));

  //Seta Título no Brasil
  i:=FindLine('<u>Título no Brasil:</u>',Page,0);
  valor:=Page.GetString(i+1);
  i:=Pos('<br>',valor);
  valor:=Copy(valor,1,i-1);
  HTMLDecode(valor);
  SetField(fieldTranslatedTitle, trim(valor));

  // Seta Produtora
  i:=FindLine('<u>Estúdio/Distrib.:</u>',Page,0);
  valor:=Page.GetString(i+1);
  i:=Pos('<br>',valor);
  valor:=Copy(valor,1,i-1);
  HTMLDecode(valor);
  SetField(fieldProducer, trim(valor));

  // Seta Gênero
  i:=FindLine('<u>Gênero:</u>',Page,0);
  valor:=Page.GetString(i+1);
  i:=Pos('<br>',valor);
  valor:=Copy(valor,1,i-1);
  HTMLDecode(valor);
  SetField(fieldCategory, trim(valor));

  // Seta Ano de Lançamento
  i:=FindLine('Ano de Lançamento:',Page,0);
  valor:=Page.GetString(i+1);
  i:=Pos('<br>',valor);
  valor:=Copy(valor,1,i-1);
  HTMLDecode(valor);
  SetField(fieldYear, trim(valor));

  // Seta Duração
  valor:=TextBetween(Page.Text,'Tempo de Duração:</u> ',' ');
  HTMLDecode(valor);
  SetField(fieldLength, trim(valor));

  // Seta Direção
  i:=FindLine('<u>Direção:</u>',Page,0);
  valor:=TextBetween(Page.Text,'.html>','</a><br></font>');
  HTMLRemoveTags(valor);
  HTMLDecode(valor);
  SetField(fieldDirector, trim(valor));

  // Seta País de Origem
  i:=FindLine('<u>País de Origem:</u>',Page,0);
  valor:=Page.GetString(i+1);
  i:=Pos('<br>',valor);
  valor:=Copy(valor,1,i-1);
  HTMLDecode(valor);
  SetField(fieldCountry, trim(valor));
  
  // Seta Elenco
  valor2:='<u><b>Elenco</b></u><br>';
  i:=FindLine(valor2,Page,0);
  valor:=Page.GetString(i);
  valor:=StringReplace(valor,valor2,'');
  valor:=StringReplace(valor,'<br>',#13#10);
  HTMLRemoveTags(valor);
  HTMLDecode(valor);
  SetField(fieldActors, trim(valor));

  // Seta Imagem do Filme
  i:=FindLine('<td width="130" height="2200" bgcolor="#FFECD9" align="center" valign="top">',Page,0);
  valor:=Page.GetString(i+1);
  valor:='http://www.interfilmes.com/'+TextBetween(valor,'src="','"');
  GetPicture(valor);

  // Seta Nota/Avaliação
  valor:=Page.Text;
  valor2:='';
  i:=0;
  repeat
    i:=Pos('estrela.gif',valor);
    if i>0 then
    begin
      Delete(valor, 1, i + 1);
      valor2:=IntToStr(StrToInt(valor2,0)+1);
    end;
  until i=0;
  valor2:=IntToStr(StrToInt(valor2,0)*2);
  SetField(fieldRating,valor2);
  Page.free;
end;


// Método para Trazer Todos os Comentários
procedure AnalyzeFilmPageComments(Address:string);
var Page:TStringList;
    valor:String;
begin
  Page := TStringList.Create;
  valor:='http://www.interfilmes.com/'+Address;
  valor := StringReplace(valor, 'filme_', 'filme_c');
  valor := TextBefore(valor, '-(', '');
  Page.Text:=GetPage(valor+'.html#Comentario');

  // Seta Comentários
  valor:=TextBetween(Page.Text,'<br><br><table border=0 cellspacing=1 cellpadding=0 bgcolor=#111111 bordercolor=#111111 width=395>','</table><br><script');
  valor:=StringReplace(valor,'<td width=8% bgcolor=#FFF9F2 bordercolor=#663300 align=center><font face=Tahoma size=1 color=#663300><b>','[');
  valor:=StringReplace(valor,'</b></font></td>',']');
  valor:=StringReplace(valor,']</tr><tr>',' ');
  valor:=StringReplace(valor,#13#10'[','[');
  valor:=StringReplace(valor,']'#13#10,']');
  valor:=StringReplace(valor,'<br>',#13#10);
  valor:=StringReplace(valor,' ',' ');
  valor:=StringReplace(valor,'<td colspan=3 bgcolor=#FFF9F2 bordercolor=#663300><font face=Verdana size=1 color=#663300>',#13#10);
  valor:=StringReplace(valor,'<tr>[',#13#10'<tr>[');
  HTMLRemoveTags(valor);
  valor:=StringReplace(valor,'Nota: ',' ');
  HTMLDecode(valor);
  SetField(fieldComments, trim(valor));

  Page.free;
end;


procedure AnalyzePage(Address: String);
var Page:TStringList;
    i:integer;
    nome, url:string;
begin
  PickTreeClear;
  Page := TStringList.Create;
  Page.Text := PostPage(Address,'search='+MovieName);
  i:=0;
  repeat
    i:=FindLine('<font color=#FFFFFF face=Verdana size=2>',Page,i+1);
    nome:=Page.GetString(i);
    HTMLRemoveTags(nome);
    if (length(nome)>0) then
    begin
      url:=Page.GetString(i-1);
      url:=TextBetween(url,'"','"');
      PickTreeAdd(nome,url);
    end;
  until i=-1;
 if PickTreeExec(Address) then
      AnalyzeFilmPage(Address);
      AnalyzeFilmPageComments(Address);
  Page.free;
end;


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

Post by antp »

Is it based on the existing script? (I guess yes, from what I understand with an online translator)
If so, why is it version 1.00 instead of 1.10 or 2.00 ?
And why not keep original author name?
h0ttz
Posts: 2
Joined: 2010-06-09 14:31:47

Post by h0ttz »

antp wrote:Is it based on the existing script? (I guess yes, from what I understand with an online translator)
If so, why is it version 1.00 instead of 1.10 or 2.00 ?
And why not keep original author name?
Is it based on the existing script? (I guess yes, from what I understand with an online translator)
Yes. InterFilmes by Guardiao.

If so, why is it version 1.00 instead of 1.10 or 2.00 ?
Because my first script to InterFilmes.

And why not keep original author name?
Because i fix all bugs, i changed the code and added news features.

I thought that I had done all this change should have a new version and copyright
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

If you rewrote all there is a new copyright indeed, but if you just made changes to the code it is better to include the old name, e.g.:

Authors=h0ttz ( h0ttzspam@gmail.com ), previous versions by Guardião and mikepax

Version 2 will indicate to users that it is a newer script than the other one, else they may think it is older...
mikepax
Posts: 4
Joined: 2009-08-29 16:31:30

Post by mikepax »

Muito legal você fazer upgrade no script.
Mas não falte com educação desconsiderando os antigos autores do script, afinal eu já fiz 2 upgrades nesse script.
Ele não catava as imagens, só pegava os 2 primeiros nomes do elenco, No campo Diretor trazia um bocado de tag junto e só pegava metade da sinopse.
Flw.
ronniewo2
Posts: 14
Joined: 2012-08-03 22:28:41

Post by ronniewo2 »

Here's the newer version with many corrections. The other one was too old and I rewrote it almost completely.

Code: Select all

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

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

[Infos]
Authors=Ronniewo2 / Previous version: Guardião and mikepax
Title=InterFilmes
Description=Movie importation script for InterFilmes.com
Site=http://www.interfilmes.com
Language=BR
Version=2.30
Requires=3.5.1
Comments=Released 18/03/2013
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 InterFilmes;
var MovieName:string;
uses StringUtils1;

procedure AnalyzeFilmPage(Address:string);
var Page:TStringList;
    valor, valor2:String;
    i:integer;
begin
  Page := TStringList.Create;
  valor:='http://www.interfilmes.com/'+Address;
  valor := StringReplace(valor, 'filme_', 'filme_v1_');
  valor := TextBefore(valor, '-(', '');
  Page.Text:=GetPage(valor+'.html#Elenco');
  //showmessage(page.text);
  //SetField(fieldURL,valor);
  
  i:=FindLine('</title>">',Page,0);
  valor:=TextBetween(Page.Text,'"justify">'#13#10,'</div>');
  HTMLRemoveTags(valor);
  SetField(fieldDescription, valor);
  
  SetField(fieldMediaType, 'DVD');
 
  i:=FindLine('<font color="#FFFFFF" face="Verdana" size="2">',Page,0);
  valor:=Page.GetString(i+1);
  HTMLRemoveTags(valor);
  valor2:=TextBetween(valor,'(',')');
  valor:=StringReplace(valor,+'('+valor2+')','');
  SetField(fieldOriginalTitle, valor2);
  SetField(fieldTranslatedTitle, valor);

  i:=FindLine('<u>Gênero:</u>',Page,0);
  valor:=Page.GetString(i+1);
  i:=Pos('<br>',valor);
  valor:=Copy(valor,1,i-1);
  HTMLRemoveTags(valor);
  SetField(fieldCategory,valor);

  i:=FindLine('Ano de Lançamento:',Page,0);
  valor:=Page.GetString(i+1);
  i:=Pos('<br>',valor);
  valor:=Copy(valor,1,i-1);
  SetField(fieldYear,valor);
 
  valor:=TextBetween(Page.Text,'Tempo de Duração:</u> ','</span>');
  HTMLRemoveTags(valor);
  SetField(fieldLength,valor);
 
  i:=FindLine('<u>Direção:</u>',Page,0);
  valor:=Page.GetString(i+2);
  HTMLRemoveTags(valor);
  SetField(fieldDirector,valor);
 
  i:=FindLine('<u>País de Origem:</u>',Page,0);
  valor:=Page.GetString(i+1);
  i:=Pos('<br>',valor);
  valor:=Copy(valor,1,i-1);
  SetField(fieldCountry,valor);
 
  valor2:=copy(Page.text,pos('<u><b>Elenco</b></u>',Page.Text),Length(Page.Text));
  valor2:=copy(valor2,1,pos('<br></font></li> ',valor2)-3);
  valor2:=StringReplace(valor2,'<br>',#13#10);
  HTMLRemoveTags(valor2);
  valor2:=copy(valor2,9,Length(valor2));
  SetField(fieldActors,valor2);
 
  i:=FindLine('<td width="130" height="2200" bgcolor="#FFECD9" align="center" valign="top">',Page,0);
  valor:=Page.GetString(i+1);
  valor:='http://www.interfilmes.com/'+TextBetween(valor,'src="','"');
  GetPicture(valor);
 
  valor:=Page.Text;
  valor2:='';
  i:=0;
  {repeat
    i:=Pos('estrela.gif',valor);
    if i>0 then
    begin
      Delete(valor, 1, i + 1);
      valor2:=IntToStr(StrToInt(valor2,0)+1);
    end;
  until i=0;
  valor2:=IntToStr(StrToInt(valor2,0)*2);
  SetField(fieldRating,valor2);}
  Page.free;
end;

procedure AnalyzePage(Address: String);
var Page:TStringList;
    i:integer;
    nome, url:string;
begin
  PickTreeClear;
  Page := TStringList.Create;
  Page.Text := PostPage(Address,'search='+MovieName);
  i:=0;
  repeat
    i:=FindLine('<font color=#FFFFFF face=Verdana size=2>',Page,i+1);
    nome:=Page.GetString(i);
    HTMLRemoveTags(nome);
    if (length(nome)>0) then
    begin
      url:=Page.GetString(i-1);
      url:=TextBetween(url,'"','"');
      PickTreeAdd(nome,url);
    end;
  until i=-1;
 if PickTreeExec(Address) then
      AnalyzeFilmPage(Address);
      //showmessage(address);
  Page.free;
end;


begin
  PickListClear;
  MovieName := GetField(fieldOriginalTitle);
  if Input('Importar do InterFilmes.com', 'Escreva o nome do filme:', MovieName) then
  begin
    MovieName := StringReplace(MovieName, ' ', '+');
    AnalyzePage('http://www.interfilmes.com/busca.html');
  end;
end. 
Last edited by ronniewo2 on 2013-03-20 17:02:10, edited 1 time in total.
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks.
The previous one was only one month old ;)
ronniewo2
Posts: 14
Joined: 2012-08-03 22:28:41

Post by ronniewo2 »

Oh, sorry! I didn't notice that. Now, checking the update page... Anyway, this one is one more option. I would be glad if someone update this topic when an update file become available. Thanks!

Edit: It's in another topic. My fault...
Here: viewtopic.php?t=4433
Last edited by ronniewo2 on 2013-03-20 17:01:41, edited 1 time in total.
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

The most reliable solution before updating a script is to check the latest version on http://update.antp.be/amc/scripts/
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Reverting to the old script, as it seems that the new one does not work as well as the February update, cf viewtopic.php?p=36155#36155
ronniewo2
Posts: 14
Joined: 2012-08-03 22:28:41

Post by ronniewo2 »

In my tests it works fine. I don't put the fields "rating" and "URL" in my scripts 'cause I like to rate the movies by myself and I don't see the utility of the field "URL"... But feel free to revert back to the old one.
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Well those that do not want one of the field can still uncheck it in the "allowed fields" list, but it is nice if the script offers it if available (especially if older versions of the script were doing it ;) )
ronniewo2
Posts: 14
Joined: 2012-08-03 22:28:41

New version

Post by ronniewo2 »

New version. Please, check it.

Code: Select all

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

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

[Infos]
Authors=Ronniewo2 (Ronnie Oliveira) / Previous version: Guardião and mikepax
Title=InterFilmes
Description=Movie importation script for InterFilmes.com
Site=http://www.interfilmes.com
Language=BR
Version=2.31
Requires=3.5.1
Comments=Released 26/11/2013
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 InterFilmes;
var MovieName:string;
uses StringUtils1;

procedure AnalyzeFilmPage(Address:string);
var Page:TStringList;
    valor, valor2:String;
    i:integer;
begin
  Page := TStringList.Create;
  valor:='http://www.interfilmes.com/'+Address;
  valor := StringReplace(valor, 'filme_', 'filme_v1_');
  if pos('-(', valor)>0 then
     valor := TextBefore(valor, '-(', '');
  Page.Text:=GetPage(valor+'.html#Elenco');
  SetField(fieldURL,valor);
  
  valor:=TextBetween(Page.Text,'</span><span itemprop="description">','</span>');
  HTMLRemoveTags(valor);
  SetField(fieldDescription, valor);
  
  SetField(fieldMediaType, 'DVD');
 
  valor:=TextBetween(Page.Text,'tulo no Brasil</td>' , '</tr>');
  valor:=TextBetween(valor,'"td2">' , '</td>');
  valor2:=TextBetween(Page.Text,'tulo Original</td>' , '</tr>');
  valor2:=TextBetween(valor2,'"td2">' , '</td>');
  SetField(fieldOriginalTitle, valor2);
  SetField(fieldTranslatedTitle, valor);

  valor:=TextBetween(Page.Text,'nero</td>' , '</tr>');
  valor:=TextBetween(valor,'"genre">' , '</td>');
  HTMLRemoveTags(valor);
  SetField(fieldCategory,valor);

  valor:=TextBetween(Page.Text,'>Ano de Lançamento</td>' , '</tr>');
  valor:=TextBetween(valor,'"td2">' , '</td>');
  SetField(fieldYear,valor);
 
  valor:=TextBetween(Page.Text,'class="td1">Dura' , '</tr>');
  valor:=TextBetween(valor,'content="' , '</span>');
  valor := TextAfter(valor, '>');
  HTMLRemoveTags(valor);
  SetField(fieldLength,valor);

  valor:=TextBetween(Page.Text,'<span itemprop="director"' , '</tr>');
  valor:=TextBetween(valor,'="name">' , '</td>');
  HTMLRemoveTags(valor);
  SetField(fieldDirector,valor);

  valor:=TextBetween(Page.Text,'s de Origem</td>' , '</tr>');
  valor:=TextBetween(valor,'"td2">' , '</td>');
  HTMLRemoveTags(valor);
  SetField(fieldCountry,valor);

  valor:=TextBetween(Page.Text,'<a name="Elenco">' , '</table>');
  valor:=TextAfter(valor,'itemprop="name">');
  HTMLRemoveTags(valor);
  valor:=StringReplace(valor,'  ','');
  valor:=StringReplace(valor,#13#10,'  ');
  valor:=StringReplace(valor,'      ',#13#10);
  valor:=StringReplace(valor,'  ','');
  valor:=StringReplace(valor,#9,'');
  SetField(fieldActors,valor);

  valor:=TextBetween(Page.Text,'<div class="poster"' , '/><div class');
  valor:=TextBetween(valor,'<img src="' , '" width');
  valor:='http://www.interfilmes.com/'+valor;
  GetPicture(valor);

  valor:=TextBetween(Page.Text,'<span itemprop="ratingValue">' , '</span>');
  valor:=FloatToStr(StrToFloat(valor)*2);
  SetField(fieldRating,valor);
  Page.free;
end;

procedure AnalyzePage(Address: String);
var Page:TStringList;
    i:integer;
    nome, url:string;
begin
  PickTreeClear;
  Page := TStringList.Create;
  Page.Text := PostPage(Address,'search='+MovieName);
  i:=0;
  repeat
    i:=FindLine('<div class="nomedofilme">',Page,i+1);
    nome:=Page.GetString(i);
    if (length(nome)>0) then
    begin
      url:=nome;
      url:=TextBetween(url,'<a href="','" title=');
      HTMLRemoveTags(nome);
      PickTreeAdd(nome,url);
    end;
  until i=-1;
 if PickTreeExec(Address) then
      AnalyzeFilmPage(Address);
  Page.free;
end;


begin
  PickListClear;
  MovieName := GetField(fieldOriginalTitle);
  if Input('Importar do InterFilmes.com', 'Escreva o nome do filme:', MovieName) then
  begin
    MovieName := StringReplace(MovieName, ' ', '+');
    AnalyzePage('http://www.interfilmes.com/busca.html');
  end;
end. 
ronniewo2
Posts: 14
Joined: 2012-08-03 22:28:41

New version

Post by ronniewo2 »

New version: 2.32
Release date: April 20/2016
Please update

Code: Select all

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

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

[Infos]
Authors=Ronniewo2 (Ronnie Oliveira) / Previous version: Guardião and mikepax
Title=InterFilmes
Description=Movie importation script for InterFilmes.com
Site=http://www.interfilmes.com
Language=BR
Version=2.32
Requires=3.5.1
Comments=Released 20/04/2016
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 InterFilmes;
var MovieName:string;
uses StringUtils1;

procedure AnalyzeFilmPage(Address:string);
var Page:TStringList;
    valor, valor2:String;
    i:integer;
begin
  Page := TStringList.Create;
  valor:='http://www.interfilmes.com/'+Address;
  valor := StringReplace(valor, 'filme_', 'filme_v1_');
  if pos('-(', valor)>0 then
     valor := TextBefore(valor, '-(', '');
  Page.Text:=GetPage(valor+'.html#Elenco');
  SetField(fieldURL,valor);
 
  valor:=TextBetween(Page.Text,'</span><span itemprop="description">','</span>');
  HTMLRemoveTags(valor);
  SetField(fieldDescription, valor);
 
  //SetField(fieldMediaType, 'Blu Ray');
 
  valor:=TextBetween(Page.Text,'tulo no Brasil</td>' , '</tr>');
  valor:=TextBetween(valor,'"td2">' , '</td>');
  valor2:=TextBetween(Page.Text,'tulo Original</td>' , '</tr>');
  valor2:=TextBetween(valor2,'"alternateName">' , '</td>');
  SetField(fieldOriginalTitle, valor2);
  SetField(fieldTranslatedTitle, valor);

  valor:=TextBetween(Page.Text,'nero</td>' , '</tr>');
  valor:=TextBetween(valor,'"genre">' , '</td>');
  HTMLRemoveTags(valor);
  SetField(fieldCategory,valor);

  valor:=TextBetween(Page.Text,'>Ano Lançamento</td>' , '</tr>');
  valor:=TextBetween(valor,'datePublished" content="' , '"><a');
  SetField(fieldYear,valor);
 
  valor:=TextBetween(Page.Text,'class="td1">Dura' , '</tr>');
  valor:=TextBetween(valor,'content="' , '</span>');
  valor := TextAfter(valor, '>');
  HTMLRemoveTags(valor);
  SetField(fieldLength,valor);

  valor:=TextBetween(Page.Text,'<span itemprop="director"' , '</tr>');
  valor:=TextBetween(valor,'="name">' , '</td>');
  HTMLRemoveTags(valor);
  SetField(fieldDirector,valor);

  valor:=TextBetween(Page.Text,'s de Origem</td>' , '</tr>');
  valor:=TextBetween(valor,'"td2">' , '</td>');
  HTMLRemoveTags(valor);
  SetField(fieldCountry,valor);

  valor:=TextBetween(Page.Text,'<a name="Elenco">' , '</table>');
  valor:=TextAfter(valor,'itemprop="name">');
  HTMLRemoveTags(valor);
  valor:=StringReplace(valor,'  ','');
  valor:=StringReplace(valor,#13#10,'  ');
  valor:=StringReplace(valor,'      ',#13#10);
  valor:=StringReplace(valor,'  ','');
  valor:=StringReplace(valor,#9,'');
  SetField(fieldActors,valor);

  valor:=TextBetween(Page.Text,'<div class="poster"' , '/><div class');
  valor:=TextBetween(valor,'<img src="' , '" width');
  valor:='http://www.interfilmes.com/'+valor;
  GetPicture(valor);

  valor:=TextBetween(Page.Text,'<span itemprop="ratingValue">' , '</span>');
  valor:=FloatToStr(StrToFloat(valor)*2);
  SetField(fieldRating,valor);
  Page.free;
end;

procedure AnalyzePage(Address: String);
var Page:TStringList;
    i:integer;
    nome, url:string;
begin
  PickTreeClear;
  Page := TStringList.Create;
  Page.Text := PostPage(Address,'search='+MovieName);
  i:=0;
  repeat
    i:=FindLine('<div class="nomedofilme">',Page,i+1);
    nome:=Page.GetString(i);
    if (length(nome)>0) then
    begin
      url:=nome;
      url:=TextBetween(url,'<a href="','" title=');
      HTMLRemoveTags(nome);
      PickTreeAdd(nome,url);
    end;
  until i=-1;
 if PickTreeExec(Address) then
      AnalyzeFilmPage(Address);
  Page.free;
end;

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

Post by antp »

Thanks
Post Reply