Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=Legrad
Title=elitefreak
Description=
Site=www.elitefreak.net
Language=ES
Version=1.0
Requires=3.5.0
Comments=
License=
GetInfo=1
[Options]
***************************************************)
program elitefreak;
Uses StringUtils7552;
var
MovieName: string;
MovieURL: string;
//------------------------------------------------------------------------------------
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);
// quitamos los tabuladores
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;
//---------------------------------------
function UpFirstLetterWord(texto:string):string;
var espaco:integer;
sst:string;
begin
texto:=AnsiUpFirstLetter(AnsiLowerCase(texto));
repeat
espaco:=Pos(' ',texto);
sst:=AnsiUpperCase(Copy(texto,espaco+1,1));
texto:=Copy(texto,1,espaco-1)+'/|\'+sst+Copy(texto,espaco+2,length(texto));
until Pos(' ',texto)=0;
texto := StringReplace(texto, '/|\', ' ');
if Copy(texto,1,1)=' ' then
texto:=Copy(texto,2,length(texto));
result:=texto;
end;
//---------------------------------------------------------
procedure AnalyzePage(Address: string);
var
strPage, strPages, MovieAddr, MovieTitle, MovieDate, MovieID: string;
BeginPos, EndPos, BeginPo, EndPo: Integer;
Line: string;
LineNr: Integer;
Page: TStringList;
begin
strPage := GetPage(Address);
BeginPos := Pos('<select name="calidad" class="buscacali" onChange="consul(1);">', strPage);
if(BeginPos > -1)then
begin
PickTreeClear;
Delete(strPage, 1, BeginPos);
BeginPos := Pos('<A HREF="peliculas/', strPage);
EndPos := 1;
while ((BeginPos > 0) and (EndPos > 0)) do
begin
Delete(strPage, 1, BeginPos);
EndPos := Pos('">', strPage);
MovieId := Copy(strPage, +19, EndPos-19);
MovieAddr := 'http://www.elitefreak.net/peliculas/' + MovieId;
BeginPos := Pos('.htm',strPage);
EndPos := Pos('</tr>', strPage);
MovieTitle := Copy(strPage,BeginPos, EndPos);
MovieTitle := TextBetween (MovieTitle , '">', '</td></tr>');
MovieTitle := StringReplace (MovieTitle ,#13#10, '--');
MovieTitle := UpFirstLetterWord(MovieTitle );
HTMLRemoveTags(MovieTitle);
PickTreeAdd(MovieTitle, MovieAddr);
PickTreeSort;
BeginPos := Pos('<A HREF="peliculas/', strPage);
if(Pos('</body>', strPage) < BeginPos) then
BeginPos := -1;
end;
end;
PickTreeExec(Address)
AnalyzeMoviePage(Address);
SetField(fieldURL, Address);
end;
//------------------------------------------------------------------------------------
procedure AnalyzeMoviePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
Line: string;
Item: string;
Comments: string;
Actors: string;
Directors: string;
Description: string;
BaseURL2: string;
Beginpos: string;
titre_film: string;
EndPos: string;
Movie: string;
begin
Description := '';
Comments := '';
// URL
SetField(fieldURL, Address);
Page := TStringList.Create;
Page.Text := GetPage(Address);
//Titulo Traducido
LineNr := FindLine('<title>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<title>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<title>', '.');
Item := StringReplace (Item,#13#10,'');
Item := StringReplace (Item,'EliteFreak - ','');
Item := Trim(Item );
DeleteTags(Item);
HTMLDecode(Item);
SetField(fieldOriginalTitle, Trim (Item));
SetField(fieldTranslatedTitle, Trim (Item));
end;
//Género
LineNr := FindLine('<div align="right"><b>Genero:</b></div>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<div align="right"><b>Genero:</b></div>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<td width="43%">', '</td>');
Item := Trim(Item );
HTMLDecode(Item);
SetField(fieldCategory, trim (Item));
end;
// Año
LineNr := FindLine('<div align="right"><b>Año:</b></div>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<div align="right"><b>Año:</b></div>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<td width="43%">', '</td>');
Item := Trim(Item );
HTMLRemoveTags(Item);
HTMLDecode(Item);
SetField(fieldYear, trim (Item));
end;
// Formato Video
LineNr := FindLine('<div align="right"><b>Formato:</b></div>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<div align="right"><b>Formato:</b></div>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<td width="34%">', '</td>');
Item := Trim(Item );
HTMLRemoveTags(Item);
HTMLDecode(Item);
SetField(fieldMediaType, trim (Item));
end;
// Calificación
LineNr := FindLine('http://www.imdb.com/title/', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('http://www.imdb.com/title/',Page.Text), length(Page.Text));
Item := TextBetween (Item, '>', '/');
Item := Trim(Item );
HTMLRemoveTags(Item);
HTMLDecode(Item);
SetField(fieldRating, trim (Item));
end;
// Director
LineNr := FindLine('<div align="right"><b>Calidad:</b></div>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<div align="right"><b>Director:</b></div>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<td colspan="3">', '</tr>');
Item := StringReplace(Item ,#13#10,'');
Item := Trim(Item );
DeleteTags(Item);
HTMLDecode(Item);
SetField(fieldDirector, trim (Item));
end;
// Tamaño
LineNr := FindLine('<U>BitTorrent</U>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<U>BitTorrent</U>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '</A> (', ')</td></tr>');
HTMLDecode(Item);
SetField(fieldSize, trim (Item));
end;
// Reparto
LineNr := FindLine('Actores:</b></div>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('Actores:</b></div>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<td colspan="3">', '</td>');
Item := StringReplace(Item , ')',')*');
Item := StringReplace(Item , '*',#13#10);
Item := StringReplace(Item , ', ',#13#10);
Item := Trim(Item );
HTMLRemoveTags(Item);
HTMLDecode(Item);
SetField(fieldActors, trim (Item));
end;
//Sinopsis
LineNr := FindLine('<td style="TEXT-ALIGN: justify" colspan="2">', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<td style="TEXT-ALIGN: justify" colspan="2">',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<td style="TEXT-ALIGN: justify" colspan="2">', '</td>');
HTMLRemoveTags(Item);
HTMLDecode(Item);
SetField(fieldDescription, Trim (Item));
end;
// Calidad
LineNr := FindLine('<div align="right"><b>Calidad:</b></div>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<div align="right"><b>Calidad:</b></div>',Page.Text), length(Page.Text));
Item := TextBetween (Item, '<td width="43%">', '</td>');
Comments := Comments + 'CALIDAD: ' + Item + #13#10+'*********************'+#13#10;
end;
// Vinculo1
LineNr := FindLine('<b>Archivo:</b>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<b>Archivo:</b>',Page.Text), length(Page.Text));
Item := TextBetween (Item, 'HREF="', '"><U>');
Comments := Comments + 'EDONKEY:' + Item + #13#10+'*********************'+#13#10;
end;
// Vinculo2
LineNr := FindLine('<U>eDonkey/eMule</U>', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<U>eDonkey/eMule</U>',Page.Text), length(Page.Text));
Item := TextBetween (Item, 'HREF="', '"><U>');
Comments := Comments + 'TORRENT: ' + Item + #13#10;
end;
// Picture
LineNr := FindLine('<td width="18%"><img src="images/fichas/peliculas/', Page, 0);
if LineNr <> -1 then
begin
Item := copy(Page.Text, pos('<td width="18%"><img src="images/fichas/peliculas/',Page.Text), length(Page.Text));
Item := TextBetween (Item, 'src="', '" width');
HTMLDecode(Item);
GetPicture ('http://www.elitefreak.net/'+Item);
end;
HTMLDecode(Comments);
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('elitefreak', 'Buscar:', MovieName);
if(GetOption('') = 0) then Input('elitefreak', 'Buscar:', MovieName);
AnalyzePage('http://www.elitefreak.net/elitefreak.php?cod=peliculas&bus1=Titulo&bus2=' + UrlEncode(MovieName));
end.