arggg... you wise, I do: a selection box with two alternatives: the little and the big... here you are the new script:
Code: Select all
// GETINFO SCRIPTING
// Carteles-Metropoli v1.0 by micmic.ifs
(***************************************************
* Author: micmic (micmic@dieznet.com) *
* Script for the importation of pictures from *
* carteles.metropoliglobal.com *
* *
* For use with Ant Movie Catalog 3.4.0 *
* www.ant.be.tf/moviecatalog ··· www.buypin.com *
* *
* 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 *
***************************************************)
program micmic;
var
MovieName: string;
const
Base = 'http://carteles.metropoliglobal.com/';
BaseURL = 'http://carteles.metropoliglobal.com/4resultados.php?titulo=';
BaseURL2 = '&director=&interpretes=&Submit=Buscar';
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 AnalizaBigImagePage(ImagenURL: string): string;
var
Page: TStringList;
LineNr: Integer;
PosIni, PosFin: Integer;
Line, SubLine: string;
txtTemp: string;
begin
Page := TStringList.Create;
Page.Text := GetPage(ImagenURL);
txtTemp := '<td bgcolor="#FFFFFF"><div align="center"><img src="';
LineNr := FindLine(txtTemp, Page, 0);
if LineNr > 0 then
begin
Line := Page.GetString(LineNr);
PosIni := pos(txtTemp, Line);
SubLine := Copy(Line, PosIni + Length(txtTemp), Length(Line));
txtTemp := '"';
PosFin := pos(txtTemp, SubLine);
txtTemp := Copy(SubLine, 1, PosFin - 1);
end else
txtTemp := '';
Page.Free;
result := txtTemp;
end;
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
PosIni, PosFin: Integer;
Line, SubLine: string;
Title, DirURL: string;
txtTemp: string;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
if Pos('No se han encontrado resultados', Page.Text) > 0 then
begin
ShowMessage('No se ha encontrado ningún artículo por título.');
end else
begin
PickTreeClear;
PickTreeAdd('Resultados para "' + MovieName + '" en ' + Base + ':', '');
// buscamos los resultados
LineNr := 0;
while LineNr < Page.Count do
begin
SubLine := Page.GetString(LineNr);
txtTemp := '<td width="92%"><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="';
PosIni := pos(txtTemp, SubLine);
if PosIni > 0 then
begin
SubLine := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
txtTemp := '">';
PosFin := pos(txtTemp, SubLine);
DirURL := Base + Copy(SubLine, 1, PosFin - 1);
SubLine := Copy(SubLine, PosFin + Length(txtTemp), Length(SubLine));
txtTemp := '</a>';
PosFin := pos(txtTemp, SubLine);
Title := Copy(SubLine, 1, PosFin - 1);
//ShowMessage(Title + '-->' + DirURL);
PickTreeAdd(Title, DirURL);
end;
LineNr := LineNr + 1;
end;
Page.Free;
if PickTreeExec(Address) then
AnalyzeMoviePage(Address);
end;
end;
procedure AnalyzeMoviePage(Address: string);
var
Page: TStringList;
PosIni, PosFin: Integer;
dirBase: string;
txtTemp: string;
txtAux: string;
campo, valor: string;
LineNr: Integer;
Line, SubLine: string;
ImagenPeqSRC, ImagenURL, ImagenGrandeSRC: string;
Comentarios: string;
begin
//ShowMessage(Address);
SetField(fieldURL, Address);
Page := TStringList.Create;
Page.Text := StringReplace(GetPage(Address), '<br>', #13#10);
// buscamos los campos
Comentarios := '';
ImagenPeqSRC := '';
ImagenURL := '';
ImagenGrandeSRC := '';
LineNr := 0;
while LineNr < Page.Count do
begin
SubLine := Page.GetString(LineNr);
txtTemp := '<title>';
PosIni := pos(txtTemp, SubLine);
if PosIni > 0 then
begin
txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
PosFin := pos('</title>', txtAux);
campo := Copy(txtAux, 1, PosFin - 1);
if campo <> '' then SetField(fieldTranslatedTitle, campo);
end;
txtTemp := '<td width="68%" valign="TOP" bgcolor="#F5F5F5"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">';
PosIni := pos(txtTemp, SubLine);
if PosIni > 0 then
begin
txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
PosFin := pos('</font></td>', txtAux);
campo := Copy(txtAux, 1, PosFin - 1);
if campo <> '' then SetField(fieldOriginalTitle, campo);
end;
txtTemp := '<td valign="TOP" bgcolor="#FFFFFF"><div align="right"><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">';
PosIni := pos(txtTemp, SubLine);
if PosIni > 0 then
begin
txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
PosFin := pos(':', txtAux);
campo := Copy(txtAux, 1, PosFin - 1);
LineNr := LineNr + 2;
SubLine := Page.GetString(LineNr);
txtTemp := '<td valign="TOP" bgcolor="#F5F5F5"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">';
PosIni := pos(txtTemp, SubLine);
txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
PosFin := pos('</font></td>', txtAux);
valor := Copy(txtAux, 1, PosFin - 1);
if campo = 'AÑO' then SetField(fieldYear, valor);
if campo = 'NACIONALIDAD' then SetField(fieldCountry, valor);
if campo = 'DIRECTOR' then SetField(fieldDirector, valor);
if campo = 'INTÉRPRETES' then SetField(fieldActors, valor);
if campo = 'DURACION' then Comentarios := Comentarios + 'Duración: ' + valor + #13#10;
if campo = 'GUIÓN' then Comentarios := Comentarios + 'Guión: ' + valor + #13#10;
if campo = 'FOTOGRAFÍA' then Comentarios := Comentarios + 'Fotografía: ' + valor + #13#10;
if campo = 'MÚSICA' then Comentarios := Comentarios + 'Música: ' + valor + #13#10;
//ShowMessage(campo + '-->' + valor);
end;
txtTemp := '/cpp/albums/userpics/';
PosIni := pos(txtTemp, SubLine);
if PosIni > 0 then
begin
txtAux := Copy(SubLine, PosIni, Length(SubLine));
PosFin := pos('" width="', txtAux);
campo := Copy(txtAux, 1, PosFin - 1);
if ImagenPeqSRC = '' then ImagenPeqSRC := Base + campo;
end;
//this is the other directory I found
txtTemp := '/c/';
PosIni := pos(txtTemp, SubLine);
if ((PosIni > 0) and (ImagenPeqSRC = '')) then
begin
txtAux := Copy(SubLine, PosIni, Length(SubLine));
PosFin := pos('" width="', txtAux);
campo := Copy(txtAux, 1, PosFin - 1);
if ImagenPeqSRC = '' then ImagenPeqSRC := Base + campo;
end;
//now the big image
txtTemp := 'pgrande.php?image_id=';
PosIni := pos(txtTemp, SubLine);
if ((PosIni > 0) and (ImagenURL = '')) then
begin
txtAux := Copy(SubLine, PosIni, Length(SubLine));
PosFin := pos('">', txtAux);
campo := Copy(txtAux, 1, PosFin - 1);
if ImagenURL = '' then ImagenURL := Base + campo;
end;
txtTemp := '<td valign="TOP" colspan="2"><font size="1" face="Arial, Helvetica, sans-serif">';
PosIni := pos(txtTemp, SubLine);
if PosIni > 0 then
begin
txtAux := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
PosFin := pos('</font></td>', txtAux);
campo := Copy(txtAux, 1, PosFin - 1);
if campo <> '' then SetField(fieldDescription, campo);
end;
LineNr := LineNr + 1;
end;
if Comentarios <> '' then SetField(fieldComments, Comentarios);
if ImagenURL <> '' then ImagenGrandeSRC := Base + AnalizaBigImagePage(ImagenURL);
//ShowMessage(ImagenGrandeSRC + '<--' + ImagenPeqSRC);
If (ImagenGrandeSRC <> '') or (ImagenPeqSRC <> '') then
begin
PickTreeClear;
PickTreeAdd('Imagenes para "' + MovieName + '" en ' + Base + ':', '');
If (ImagenPeqSRC <> '') then PickTreeAdd('Pequeña', ImagenPeqSRC);
If (ImagenGrandeSRC <> '') then PickTreeAdd('Grande', ImagenGrandeSRC);
if PickTreeExec(Address) then GetPicture(Address, False);
end;
Page.Free;
DisplayResults;
end;
// bmicmic: Bucle Principal
begin
if CheckVersion(3,4,0) then
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
Input('Importar de ' + Base, 'Introduce el Titulo de la Pelicula:', MovieName);
AnalyzePage(BaseURL + UrlEncode(MovieName) + BaseURL2);
end else
ShowMessage('Este script necesita una versión superior de Ant Movie Catalog (al menos la version 3.4.0)');
end.
I know, but the page code for the duration is different and I don't know how capture... thinking....