[REL] Zinema [Es] - Primera versión
Posted: 2006-01-01 14:29:33
En algunas ocasiones tiene esa pelicula que no encontramos en otros lugares.
Zinema (ES).ifs
Zinema (ES).ifs
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=gilistico
Title=Zinema (ES)
Description= Movie importation script for "Zinema + Google" (Spain)
Site=www.zinema.com
Language=ES
Version=1.0
Requires=3.5.0
Comments= Primera version
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 zinema;
uses
StringUtils1;
var
MovieName: string;
function MyTrim(var S: string): string;
var
n,len, space: Integer;
c: char;
t: String;
begin
len := length(s);
for n:=len downto 1 do
begin
c := Copy(s,n,1);
if(c= #32) OR (c=#9) OR (c=#13) OR (c=#10) then
len := len-1
else break;
end;
space := 2;
t := '';
for n :=1 to len do
begin
c := Copy(s,n,1);
if(c= #32) OR (c=#9) then
begin
if space > 0 then
continue;
c := ' ';
space := 1;
end
else if (c=#13) OR (c=#10) then
begin
if space > 0 then
continue;
space := 1
end
else space := 0;
t := t + c;
end;
s := t;
result := t;
end;
function DeleteTags(var S: string): string;
var
n,len, tag, space: Integer;
c: char;
t: String;
begin
tag := 0;
space := 0;
t := '';
len := length(s);
for n :=1 to len do
begin
c := Copy(s,n,1);
if (c= #13) OR (c=#10) OR (c= #32) OR (c=#9) then
begin
if space = 1 then
continue;
c := ' ';
space := 1;
end
else
begin
space := 0;
end;
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
Page: TStringList;
LineNr, Count: Integer;
PosIni, PosFin: Integer;
Line, Line2, SubLine: string;
Title, DirURL: string;
txtTemp: string;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
LineNr := FindLine('</b> - no produjo ningún documento.<br>', Page, 0);
if LineNr <> -1 then
begin
ShowMessage('No se ha encontrado ningún registro');
Page.Free;
exit;
end;
PickTreeClear;
Count := 0;
LineNr := 0;
While TRUE do
begin
LineNr := FindLine('<p class=g><a class=l href="', Page, LineNR+1);
if LineNr = -1 then
begin
LineNr := FindLine('<b> Siguiente </b>', Page, 0);
if LineNr = -1 then
break;
Line := Page.GetString(LineNr);
Line := TextBetween (Line, '<td nowrap nowrap>', '>');
Address := TextBetween (Line, 'href=', '>');
if Address = '' then
break;
Address := 'http://www.google.com' + Address;
Page.Text := GetPage(Address);
LineNr := 0;
continue;
end;
Line := Page.GetString(LineNr);
Line2 := Line;
DirURL := TextBetween (Line, '<p class=g><a class=l href="', '">');
Line := Line2;
Title := TextBetween (Line,'<p class=g>', '</a>');
Line := TextBetween (Line2,'LA BUTACA -', '</a>');
if Line <>'' then
Title := Line;
DeleteTags(Title);
HTMLDecode(Title);
PickTreeAdd(Title, DirURL);
Count := Count +1;
end;
if Count = 0 then
begin
ShowMessage('No se han encontrado registros');
Page.Free;
exit;
end;
if PickTreeExec(Address) then
AnalyzeMovie(Address);
Page.Free;
end;
//------------------------------------------------------------------------------------
procedure AnalyzeMovie(Address: string);
var
Page: String;
LineNr: Integer;
LineEnd: Integer;
Line: string;
Item: string;
Comments: string;
begin
Line := '';
Comments := '';
SetField(fieldURL, Address);
Page := GetPage(Address);
// Cartel
Item := TextBetween(Page, 'src="../../', '"');
if Item <> '' then
GetPicture('http://www.zinema.com/'+Item );
Page := StringReplace(Page,'<font color="#800000" face="Arial"><small><strong> </strong></small></font>','');
// Titulo español
Item := TextBetween(Page, '<font size="4">', '</font>');
if Item <> '' then
begin
Item := DeleteTags(Item);
HTMLDecode(Item);
SetField(fieldTranslatedTitle, Trim (Item));
SetField(fieldOriginalTitle,Trim (Item));
end;
// Titulo original
Item := LeeDato(Page, 'original');
if Item <> '' then
SetField(fieldOriginalTitle,Trim (Item));
// Dirección
Item := LeeDato(Page, 'Dirección');
if Item <> '' then
SetField(fieldDirector, Trim (Item));
// Pais
Item := LeeDato(Page, 'Nacionalidad');
if Item <>'' then
SetField(fieldCountry, Trim (Item));
// Año
Item := LeeDato(Page, 'Año');
if Item <>'' then
SetField(fieldYear, Trim (Item));
// Duración
Item := LeeDato(Page, 'Duración');
if Item <>'' then
SetField(fieldLength, TextBefore(Item,' m',''));
// Genero
Item := LeeDato(Page, 'Género');
if Item <>'' then
SetField(fieldCategory, Trim (Item));
// Interpretación
Item := LeeDato(Page, 'Intérpretes');
if Item <>'' then
SetField(fieldActors, Item);
// Sinopsis
Item := LeeDato(Page, 'Sinopsis');
if Item <>'' then
SetField(fieldDescription, Trim (Item));
// Guión
Item := LeeDato(Page, 'Guión');
if Item <>'' then
Comments := Comments + 'Guión: ' + Item + #13#10;
// Fotografía
Item := LeeDato(Page, 'Fotografía');
if Item <>'' then
Comments := Comments + 'Fotografía: ' + Item + #13#10;
// Música
Item := LeeDato(Page, 'Música');
if Item <>'' then
Comments := Comments + 'Música: ' + Item + #13#10;
// Montaje
Item := LeeDato(Page, 'Montaje');
if Item <>'' then
Comments := Comments + 'Montaje: ' + Item + #13#10;
// Estreno
Item := LeeDato(Page, 'Estreno');
if Item <>'' then
Comments := Comments + 'Estreno en España: ' + Item;
if(Comments <>'') then
SetField(fieldComments, Comments);
end;
function LeeDato(Page: String; Texto: string): string;
var
Line: String;
begin
Line := TextBetween(Page, Texto +'</strong>', '<font color="#800000"');
Line := StringReplace(Line,#13#10,' ');
Line := StringReplace(Line,'<tr>',#13#10);
HTMLRemoveTags(Line);
HTMLDecode(Line);
Line := MyTrim(Line);
result := Line;
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('Zinema', 'Titulo de la pelicula:', MovieName);
AnalyzePage(UrlEncode('http://www.google.com/custom?num=100&hl=es&rls=GGLD,GGLD:2005-49,GGLD:es&as_epq=' + MovieName + '&lr=lang_es&as_occt=title&as_dt=i&as_sitesearch=www.zinema.com'));
end.