Code: Select all
// GETINFO SCRIPTING
// www.caratulasdecine.com - Large picture
(***************************************************
* Author: japg2000 (japg2000@terra.es) *
* Script for the importation of pictures from *
* caratulasdecine *
* *
* 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 CaratulasdecineImport;
var
CaratulasdecinePage, MoviePage: TStringList;
PageOfLetter: Array of string;
Dir, Line, LineTmp, Title: string;
C: Char;
Encontrado, Salir, BeginPos, EndPos, Index, LineNr, LineMov: Integer;
debug: Integer;
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 EliminaInicio(S: string; CR: string): string;
begin
result := S;
while Pos(CR, result) = 1 do
begin
Delete(result, 1, Length(CR));
end;
end;
function CadenaEntre(var S: string; StartTag: string; EndTag: string): string;
var
InicioPos: Integer;
begin
InicioPos := Pos(StartTag, S);
Delete(S, 1, InicioPos + Length(StartTag) - 1);
InicioPos := Pos(EndTag, S);
result := copy(S, 1, InicioPos - 1);
Delete(S, 1, InicioPos + 1);
end;
function PreparaTitulo(T: string): string;
var
i: Integer;
begin
result := AnsiLowerCase(T);
HTMLDecode(result);
result := StringReplace(result, chr(146), '´');
result := StringReplace(result, chr(39), '´');
result := StringReplace(result, '', '´');
result := StringReplace(result, '´', '´');
result := StringReplace(result, '`', '´');
result := StringReplace(result, '¿', '');
result := StringReplace(result, '?', '');
result := StringReplace(result, '¡', '');
result := StringReplace(result, '!', '');
result := StringReplace(result, 'á', 'a');
result := StringReplace(result, 'é', 'e');
result := StringReplace(result, 'í', 'i');
result := StringReplace(result, 'ó', 'o');
result := StringReplace(result, 'ú', 'u');
end;
begin
Setarraylength(PageOfLetter,36);
PageOfLetter[0]:='0_9'; PageOfLetter[1]:='0_9';
PageOfLetter[2]:='0_9'; PageOfLetter[3]:='0_9';
PageOfLetter[4]:='0_9'; PageOfLetter[5]:='0_9';
PageOfLetter[6]:='0_9'; PageOfLetter[7]:='0_9';
PageOfLetter[8]:='0_9'; PageOfLetter[9]:='0_9';
PageOfLetter[10]:='a'; PageOfLetter[11]:='b';
PageOfLetter[12]:='c'; PageOfLetter[13]:='d';
PageOfLetter[14]:='e'; PageOfLetter[15]:='f_h';
PageOfLetter[16]:='f_h'; PageOfLetter[17]:='f_h';
PageOfLetter[18]:='i_k'; PageOfLetter[19]:='i_k';
PageOfLetter[20]:='i_k'; PageOfLetter[21]:='l';
PageOfLetter[22]:='m_n'; PageOfLetter[23]:='m_n';
PageOfLetter[24]:='o_q'; PageOfLetter[25]:='o_q';
PageOfLetter[26]:='o_q'; PageOfLetter[27]:='r_s';
PageOfLetter[28]:='r_s'; PageOfLetter[29]:='t_z';
PageOfLetter[30]:='t_z'; PageOfLetter[31]:='t_z';
PageOfLetter[32]:='t_z'; PageOfLetter[33]:='t_z';
PageOfLetter[34]:='t_z'; PageOfLetter[35]:='t_z';
Title := PreparaTitulo(GetField(fieldTranslatedTitle));
C := copy(Title, 1, 1);
if (C >= '0') and (C <= '9') then
begin
Index := Ord(C) - Ord('0');
end
else
begin
Index := 10 + Ord(C) - Ord('a');
end;
CaratulasdecinePage := TStringList.Create;
CaratulasdecinePage.Text := GetPage('http://www.caratulasdecine.com/' + PageOfLetter[Index] + '.htm');
//CaratulasdecinePage.SaveToFile('z:\caratulas.txt');
//CaratulasdecinePage.LoadFromFile('z:\caratulas.txt');
LineNr := FindLine('</big></big></big></big></big></big>', CaratulasdecinePage, 0);
LineNr := LineNr + 1;
Line := CaratulasdecinePage.GetString(LineNr);
Line := EliminaInicio(Line, ' ');
Salir := 0;
Encontrado := 0;
debug := 0;
repeat
while (Pos('<br>', Line) = 0) and (Pos('</td>', Line) = 0) and (LineNr < 1000) do
begin
if copy(Line, Length(Line), 1) <> ' ' then
Line := Line + ' ';
LineNr := LineNr + 1;
LineTmp := CaratulasdecinePage.GetString(LineNr);
LineTmp := EliminaInicio(LineTmp, ' ');
Line := Line + LineTmp;
end;
if Pos('</td>', Line) > 0 then
Salir := 1;
if Pos('<a class="A" href="', Line) > 0 then
begin
Dir := 'http://www.caratulasdecine.com/' + CadenaEntre(Line, '<a class="A" href="', '">');
end
else
begin
Dir := Line;
Dir := CadenaEntre(Dir, '<a href="', 'class="A">');
while Pos('<a href="', Dir) > 0 do
Dir := CadenaEntre(Dir, '<a href="', 'class="A">');
end;
//showmessage(Dir);
Line := CadenaEntre(Line, '', '<');
Line := PreparaTitulo(Line);
// ShowMessage(Title + ' ¿=? ' + Line + ' -> ' + Dir);
// if Pos('***',Line) > 0 then
// debug:=1;
if Pos(Title, Line) > 0 then
begin
MoviePage := TStringList.Create;
MoviePage.Text := GetPage(Dir);
//MoviePage.SaveToFile('z:\caratulasmovie.txt');
LineMov := FindLine('<p align="center"><img src="', MoviePage, 0);
Line := MoviePage.GetString(LineMov);
Line := CadenaEntre(Line, '<p align="center"><img src="', '" ');
Line := EliminaInicio(Line, '../');
GetPicture('http://www.caratulasdecine.com/' + Line, True);
Salir := 1;
Encontrado := 1;
end;
LineNr := LineNr + 1;
if LineNr > 1000 then
Salir := 1;
Line := CaratulasdecinePage.GetString(LineNr);
Line := EliminaInicio(Line, ' ');
until Salir = 1;
if (Encontrado <> 1) then
ShowMessage('Titulo ' + Title + ' no encontrado en ' + 'http://www.caratulasdecine.com/' + PageOfLetter[Index] + '.htm');
end.