[REQ] Script for Blockbuster México

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
slasher
Posts: 13
Joined: 2007-05-05 18:07:33

[REQ] Script for Blockbuster México

Post by slasher »

Hi, everybody. I would like to request a script to retrieve data from the Blockbuster Mexico page.

The reason I am asking a script to this particular site is because movie titles in Spain and Latin America (I am from Uruguay) are completely different. For example:
  • "Along came Polly" is Mi novia Polly in Argentina/Mexico, and Y entonces llegó ella in Spain.
  • "Jarhead" is Soldado anónimo in Argentina/Mexico, and Jarhead: El infierno espera in Spain... etc.
I already made some very **very** simple scripts for personal use, tho I don't think I'm capable to do a script like the one I'm requesting.

I am currently using some spanish website scripts, like Alpacine, Cineol and Filmaffinity, so, either a script to blockbuster mx, or any other script (already made or not) to a website that handles latin american titles, it would be just fine. (As I said, the ones I have are only from spanish websites...)

If anyone can help me, I'd be very grateful...

Sorry for the long request, and thanks in advance!!!

Slasher.
legrad
Posts: 109
Joined: 2006-02-11 09:46:06
Location: Lerida-Spain

Post by legrad »

No posteo en ingles por que imagino que hablas español.
Espero que el script te sirva, solo tiene la pega de que en la pagina si no hay datos en un campo es posible que cargue lo que encuentra a continuacion ejemplo la pelicula "los creyentes" no contiene datos del reparto entonces el script al no encontrarlos introduce en el campo actores "Producción: Categoría: MisterioDisponible a partir del: 23/4/1992 ... "
Si no hay caratula asi mismo carga un logotipo que es comun a todos los films sin caratula.
Aviso de por ejemplo si buscas ejem. "el hombre tranquilo" es mejor con este nombre que con solo "hombre" aunque asi podria ser que tambien lo encuentre, te digo esto por que los resultados de la pagina de blockbuster solo muestran los 20 o 30 resultados primeros relativos a la palabra buscada, se podria ampliar el script para que cargara tambien los vinculos a resultados siguientes, pero de momento no me da la cosa para mas. en fin un saludo

Code: Select all

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

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

[Infos]
Authors=Legrad
Title=blockbuster(ES)
Description=
Site=www.blockbuster.com.mx
Language=ES
Version=1.0
Requires=3.5.0
Comments=
License=
GetInfo=1

[Options]

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

program blockbuster;
var 
  MovieName: 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; 
//------------------------------------------------------------------------------------ 
                      function TextBetween(var S: string; StartTag: string; EndTag: string): string; 
var 
  InitialPos: Integer; 
begin 
  InitialPos := Pos(StartTag, S); 
  if InitialPos = 0 then 
    result := '' 
  else 
  begin 
    Delete(S, 1, InitialPos + Length(StartTag) - 1); 
    InitialPos := Pos(EndTag, S); 
    if InitialPos = 0 then 
      result := S 
    else 
    begin 
      result := copy(S, 1, InitialPos - 1); 
      Delete(S, 1, InitialPos + 1); 
    end; 
  end; 
end; 

//------------------------------------------------------------------------------------ 
                               function DeleteTags(var S: string): string; 
var 
   n,len, tag: Integer; 
   c: char; 
   t: String; 
begin 

   tag := 0; 
   t := ''; 
   len := length(s); 

   for n :=1 to len do 
   begin 
      c := Copy(s,n,1); 


      if c = #9 then 
         c := ' '; 

      if(tag=1) then 
      begin 
         if(c='>') then tag := 0; 
         continue; 
      end 
      else 
      begin 
         if(c='<') then 
         begin 
            tag := 1; 
            continue; 
         end; 
         t := t + c; 
      end; 
   end 
   s := t; 
   result := t; 
end; 


//------------------------------------------------------------------------------------ 
procedure AnalyzePage(Address: string);
var
  strPage, MovieAddr, MovieTitle, MovieDate, MovieID, Movie: string;
  BeginPos, EndPos: Integer;
  BeginPoss, EndPoss: Integer;
begin
  strPage := GetPage(Address);
  BeginPos := Pos('<TD CLASS="TituloPeliculas">', strPage);
  if(BeginPos > -1)then
    begin
      PickTreeClear;
      Delete(strPage, 1, BeginPos);
      BeginPos := Pos('HREF="BBFILMDesc.asp?Page=8001&nParam1=', strPage);
      EndPos := 1;
      while ((BeginPos > 0) and (EndPos > 0)) do

        begin
          Delete(strPage, 1, BeginPos);
          EndPos := Pos('">', strPage);
          MovieId := Copy(strPage,+39, EndPos-39);
          MovieAddr := 'http://www.blockbuster.com.mx/BBFILMDesc.asp?Page=8001&nParam1=' + MovieId;
          BeginPoss := Pos('">',strPage);
          EndPoss := Pos('</TD>', strPage);
          MovieTitle := Copy(strPage,BeginPoss+2, EndPoss);
          MovieTitle  := StringReplace(MovieTitle ,#13#10, '');
          DeleteTags(MovieTitle);
          PickTreeAdd(MovieTitle, MovieAddr);
          BeginPos := Pos('HREF="BBFILMDesc.asp?Page=8001&nParam1=', strPage);
          if(Pos('<!-- Termina Footer -->', strPage) < BeginPos) then
           BeginPos := -1;
        end;

    end;
    PickTreeSort;
    PickTreeExec(Address)
    AnalyzeMoviePage(Address);
end;

//------------------------------------------------------------------------------------ 

procedure AnalyzeMoviePage(Address: string); 
var 
  Page: TStringList; 
  LineNr: Integer; 
  Line: string; 
  Item: string; 
  Comments: string; 
  Actors: string; 
  Directors: string; 
  Description: string;
  Busca: integer;


begin 
  Description := ''; 

  // URL 
  SetField(fieldURL, Address); 
  Page := TStringList.Create; 
  Page.Text := GetPage(Address); 

  // Titulo traducido 
  LineNr := FindLine('"TituloPeliculas">', Page, 0);
  Line := Page.GetString(LineNr); 
  Item := TextBetween (Line, '"TituloPeliculas">', '</FONT>');
  DeleteTags (Item);
  HTMLDecode(Item); 
  SetField(fieldTranslatedTitle, Trim (Item));

  // Titulo Original
  LineNr := FindLine('">Título Original: ', Page, 0);
  Line := Page.GetString(LineNr);
  Item := TextBetween (Line, '">Título Original: ', '<BR>');
  DeleteTags (Item);
  HTMLDecode(Item);
  SetField(fieldOriginalTitle, Trim (Item));

  // Productor
  LineNr := FindLine('">Estudio: </FONT>', Page, 0);
  Line := Page.GetString(LineNr);
  Item := TextBetween (Line, '">Estudio: </FONT>', '<BR>');
  DeleteTags (Item);
  HTMLDecode(Item);
  SetField(fieldProducer, Trim (Item));
  
    // Año
  LineNr := FindLine('">Año de Producción: </FONT>', Page, 0);
  Line := Page.GetString(LineNr);
  Item := TextBetween (Line, '">Año de Producción: </FONT>', '<BR>');
  DeleteTags (Item);
  HTMLDecode(Item);
  SetField(fieldYear, Trim (Item));
  
  // Duración
  LineNr := FindLine('">Duración: </FONT>', Page, 0);
  Line := Page.GetString(LineNr);
  Item := TextBetween (Line, '">Duración: </FONT>', 'MIN');
  DeleteTags (Item);
  HTMLDecode(Item);
  SetField(fieldLength, Trim (Item));
  
   // director 
  LineNr := FindLine('">Director: </FONT>', Page, 0);
  if LineNr > 0 then 
  begin 
    Item := copy(Page.Text, pos('Director: </FONT>',Page.Text), length(Page.Text));
    Item := TextBetween (Item, '">', '</A>');
    Item := StringReplace(Item , #13#10, ''); 
    DeleteTags (Item); 
    Item  := Trim(Item ); 
    HTMLDecode(Item); 
    SetField(fieldDirector, Trim (Item)); 
  end;

    // Reparto
  LineNr := FindLine('Con:', Page, 0);
  if LineNr > 0 then
  begin
    Item := copy(Page.Text, pos('Con:',Page.Text), length(Page.Text));
    Item := TextBetween (Item, '">', '</A><BR><FONT ');
    Item := StringReplace(Item , #13#10, '');
    DeleteTags (Item);
    Item  := Trim(Item );
    HTMLDecode(Item);
    SetField(fieldActors, Trim (Item));
  end;
  // Nacionalidad
  LineNr := FindLine('"TextoNegritas">Producción: </FONT>', Page, 0);
  Line := Page.GetString(LineNr);
  Item := TextBetween (Line, '"TextoNegritas">Producción: </FONT>', '<BR>');
  DeleteTags (Item);
  HTMLDecode(Item);
  SetField(fieldCountry, Trim (Item));
  
  // Categoria
  LineNr := FindLine('">Categoría: </FONT>', Page, 0);
  Line := Page.GetString(LineNr);
  Item := TextBetween (Line, '">Categoría: </FONT>', '<BR>');
  DeleteTags (Item);
  HTMLDecode(Item);
  SetField(fieldCategory, Trim (Item));
  
  // Sinopsis
  LineNr := FindLine('">Sinopsis</P>', Page, 0);
  if LineNr > 0 then
  begin
    Item := copy(Page.Text, pos('">Sinopsis</P>',Page.Text), length(Page.Text));
    Item := TextBetween (Item, 'size="1">', '</FONT></TD>');
    Item := StringReplace(Item , #13#10, '');
    DeleteTags (Item);
    Item  := Trim(Item );
    HTMLDecode(Item);
    SetField(fieldDescription, Trim (Item));
  end;

  // Caratula
  LineNr := FindLine('<IMG SRC="covers/', Page, 0);
  Line := Page.GetString(LineNr);
  Item := TextBetween (Line, '<IMG SRC="covers/', '" WIDTH');
  GetPicture ('http://www.blockbuster.com.mx/covers/'+Item);

end;
 //-------------------------------------------------------------------------
begin 
       if (CheckVersion(3,5,0)=FALSe) then 
   begin 
      ShowMessage('Se requiere Ant Movie Catalog versión 3.5 o superior'); 
      exit; 
   end; 

   MovieName := GetField(fieldTranslatedTitle); 
   if MovieName = '' then 
            MovieName := GetField(fieldOriginalTitle); 
Input('blockbuster', 'Buscar:', MovieName); 

     if(GetOption('Sin resultado') = 0) then  Input('blockbuster', 'Buscar:', MovieName); 

   AnalyzePage('http://www.blockbuster.com.mx/bbListing.asp?nParam2=1&Cursor=1&stParam2=' + UrlEncode(MovieName)+'&Page=8');
end. 
slasher
Posts: 13
Joined: 2007-05-05 18:07:33

Post by slasher »

¡Fantástico! ¡Muchas gracias, Legrad!

Un gran abrazo desde Uruguay,
Slasher
Post Reply