(*************************************************** Ant Movie Catalog importation script www.antp.be/software/moviecatalog/ [Infos] Authors=Legrad Title=CineLycos Description= Site=CineLycos.com Language=ES Version=1.0 Requires=3.5.0 Comments= License= GetInfo=1 [Options] ***************************************************) program CineLycos; var MovieName: string; MovieURL: string; //--------------------------------------------------------------------- function Acentos(Acento: string) :string; begin Acento := StringReplace(Acento, 'Ã-' , 'á'); Acento := StringReplace(Acento, 'Ã' , 'á'); Acento := StringReplace(Acento, 'ã¡' , 'á'); Acento := StringReplace(Acento, 'iã³', 'á'); Acento := StringReplace(Acento, 'Ã' , 'á'); Acento := StringReplace(Acento, 'ã', 'á'); Acento := StringReplace(Acento, 'é', 'é'); Acento := StringReplace(Acento, 'ã©' , 'é'); Acento := StringReplace(Acento, 'ãª', 'é'); Acento := StringReplace(Acento, 'í', 'í'); Acento := StringReplace(Acento, 'ã­', 'í'); Acento := StringReplace(Acento, 'ó', 'ó'); Acento := StringReplace(Acento, 'ã³', 'ó'); Acento := StringReplace(Acento, 'á³', 'ó'); Acento := StringReplace(Acento, 'ú', 'ù'); Acento := StringReplace(Acento, 'ñ', 'ñ'); Acento := StringReplace(Acento, 'ã±', 'ñ'); Acento := StringReplace(Acento, 'º', 'º'); Acento := StringReplace(Acento, '&#', ''); Acento := StringReplace(Acento, '39;', ''); Acento := StringReplace(Acento, 'Â', ''); result := Acento; end; //------------------------------------------------------------------------------------ function BorraComillas(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 = '''' then c := ' '; t := t + c; end s := t; result := t; end; //------------------------------------------------------------------ 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('Mostrando 1 -', strPage); if(BeginPos > -1)then begin PickTreeClear; Delete(strPage, 1, BeginPos); BeginPos := Pos('',strPage); EndPoss := Pos(')', strPage); MovieTitle := Copy(strPage,BeginPoss, EndPoss); MovieTitle := TextBetween(MovieTitle ,'', '('); Acentos(MovieTitle); DeleteTags(MovieTitle); PickTreeAdd(MovieTitle, MovieAddr); BeginPos := Pos(''); HTMLDecode(Item); SetField(fieldTranslatedTitle, Trim (Item)); // pais LineNr := FindLine('

películas
', Page, 0); if LineNr > 0 then begin Item := copy(Page.Text, pos('

películas
',Page.Text), length(Page.Text)); Item := TextBetween (Item, ' -  (', '-'); HTMLDecode(Item); Item := StringReplace(Item , 'EE.UU.', 'USA'); SetField(fieldCountry, Trim (Item)); end; // año LineNr := FindLine('

películas
', Page, 0); if LineNr > 0 then begin Item := copy(Page.Text, pos('

películas
',Page.Text), length(Page.Text)); Item := TextBetween (Item, ' - ', ')'); DeleteTags(Item); HTMLDecode(Item); Item := Trim(Item ); HTMLDecode(Item); SetField(fieldYear, Trim (Item)); end; // Titulo Original LineNr := FindLine('Título Original: "', Page, 0); if LineNr <> -1 then begin Line := Page.GetString(LineNr); Item := TextBetween (Line, 'Título Original: "', '".'); HTMLDecode(Item); SetField(fieldOriginalTitle, Trim (Item)); end; // Categoria LineNr := FindLine('Género: ', Page, 0); if LineNr > 0 then begin Item := copy(Page.Text, pos('Género: ',Page.Text), length(Page.Text)); Item := TextBetween (Item, 'Género: ', '.Dirección:', Page, 0); if LineNr > 0 then begin Item := copy(Page.Text, pos('Dirección:',Page.Text), length(Page.Text)); Item := TextBetween (Item, 'Dirección:', '.Reparto:', Page, 0); if LineNr > 0 then begin Item := copy(Page.Text, pos('Reparto:',Page.Text), length(Page.Text)); Item := TextBetween (Item, 'Reparto:', '.'); DeleteTags (Item); Item := Trim(Item ); HTMLDecode(Item); SetField(fieldActors, Trim (Item)); end; // Productor LineNr := FindLine('Producción:', Page, 0); if LineNr > 0 then begin Item := copy(Page.Text, pos('Producción:',Page.Text), length(Page.Text)); Item := TextBetween (Item, 'Producción:', '.Duración:', Page, 0); if LineNr > 0 then begin Item := copy(Page.Text, pos('Duración:',Page.Text), length(Page.Text)); Item := TextBetween (Item, 'Duración:', 'minutos'); Item := Trim(Item ); HTMLDecode(Item); SetField(fieldLength, Trim (Item)); end; // sinopsis LineNr := FindLine('Sinopsis de "', Page, 0); if LineNr > 0 then begin Item := copy(Page.Text, pos('Sinopsis de "',Page.Text), length(Page.Text)); Item := TextBetween (Item, '
', '
'); DeleteTags (Item); Item := Trim(Item ); HTMLDecode(Item); SetField(fieldDescription, Trim (Item)); end; // Guión LineNr := FindLine('Guión:', Page, 0); if LineNr <> -1 then begin Item := copy(Page.Text, pos('Guión:',Page.Text), length(Page.Text)); Item := TextBetween (Item, 'Guión:', '.Fotografía:', Page, 0); if LineNr <> -1 then begin Item := copy(Page.Text, pos('Fotografía:',Page.Text), length(Page.Text)); Item := TextBetween (Item, 'Fotografía:', '.Música:', Page, 0); if LineNr <> -1 then begin Item := copy(Page.Text, pos('Música:',Page.Text), length(Page.Text)); Item := TextBetween (Item, 'Música:', '.Estreno en España:', Page, 0); if LineNr <> -1 then begin Item := copy(Page.Text, pos('Estreno en España:',Page.Text), length(Page.Text)); Item := TextBetween (Item, 'Estreno en España:', '.'); DeleteTags (Item); Item := Trim(Item); HTMLDecode(Item); Comments := Comments + 'Estreno en España: '+Item+#13#10; end; // Estreno LineNr := FindLine('Estreno en USA:', Page, 0); if LineNr <> -1 then begin Item := copy(Page.Text, pos('Estreno en USA:',Page.Text), length(Page.Text)); Item := TextBetween (Item, 'Estreno en USA:', '. -1 then begin Line := Page.GetString(Linenr); Item := TextBetween (Line, 'src="imagenes/carteles/', '.jpg'); GetPicture ('http://cine.lycos.es/imagenes/carteles/'+Item+'_b.jpg'); end; SetField(fieldComments, Comments); 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('CineLycos', 'Buscar:', MovieName); if(GetOption('Sin resultado') = 0) then Input('CineLycos', 'Buscar:', MovieName); AnalyzePage('http://cine.lycos.es/buscador/cine/buscar.php?query=' + UrlEncode(MovieName)+'&search=1'); end.