Code: Select all
// GETINFO SCRIPTING
// cyberdvdx (FR) - Recherche de films - by Bobo
program CyberDvdX;
ConfirmTitre = 1;
{ 1: Demande le titre avant de lancer le script
2: Ne demande pas le titre avant de lancer le script, 0 : Ne demande aucune comfirmation, 3 : Aucune Confirmation Premier Film si multiples resultats}
// Pour récupérer ou non un champs
TitreTraduitConst = False;
TitreOrignalConst = True;
CategorieConst = True;
AdresseWebConst = True;
SynopsisConst = True;
var
url_recherche, MovieName, Adresse, AdressePlus, La_liste, LaAllocine_FR, LaPremiereGrandeImage, Reponse, AdresseSuivant, AdressePrecedent, LePremierFilmAdresse, strTemp, aucunAmazon : string;
numPage, numPageG, numPageR, grandeTaille, premiereTaille, compteur, premiereExecution, numTemp : Integer;
//------------------------------------------------------------------------------
// ANALYSE DE LA PAGE D'ACCUEIL
//------------------------------------------------------------------------------
function AnalyzePageAccueil(url_accueil : String) : string;
var
debut, fin : Integer;
Page: TStringList;
temp, Line, Line2 : String;
begin
Page := TStringList.Create;
Page.Text := GetPage(url_accueil);
debut := pos('<FORM method="GET" action="/GSWeb/microcom.gswa', Page.Text)+10;
Line := copy(Page.Text,debut,length(Page.Text)-debut+1);
debut := pos('<FORM method="GET" action="/GSWeb/microcom.gswa', Line)+10;
Line := copy(Line,debut,length(Line)-debut+1);
debut := pos('<FORM method="GET" action="/GSWeb/microcom.gswa', Line);
Line := copy(Line,debut,400);
debut := pos('/', Line);
fin := pos('">', Line);
Line := copy(Line,debut,fin-debut);
result := 'http://www.cyberdvdx.com'+Line+'?1.1.3.3.11.7.1.1='+MovieName+'&SearchType=title&1.1.3.3.11.7.1.14.x=51&1.1.3.3.11.7.1.14.y=12';
end;
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
Line: string;
BeginPos, EndPos : Integer;
begin
Page := TStringList.Create;
Launch(Address, ''); // si on enlève ça, ça ne marche plus :(
Page.Text := GetPage(Address);
// 1) pas de résultat
if (pos('<b>Résultat de la recherche</b>',Page.Text) <> 0) and (pos('<!-- Small film -->', Page.Text) = 0) then
begin
if (ConfirmTitre = 1) or (ConfirmTitre = 2) then
begin
showmessage('Aucun film trouvé pour : '+MovieName);
exit;
end else
begin
SetField(fieldURL, 'cyberdvdx : aucun résultat');
exit;
end;
end;
// 2) résultat unique et donc la page de résulat est celle du film
if pos('<b>Résultat de la recherche</b>',Page.Text) = 0 then
begin
showmessage('résultat unique');
exit;
end;
// 3) sinon
showmessage('résultat multiple');
exit;
end;
//------------------------------------------------------------------------------
// NETTOIE LE TITRE DU FICHIER POUR AVOIR LE TITRE DE FILM
//------------------------------------------------------------------------------
function cleanTitle(title : String) : string;
var
i,j, fin : Integer;
temp : String;
begin
title := AnsiUpperCase(title);
if title <> '' then
begin
// Nettoie les tags fichiers, merci Atmosfear pour les tags
i:=pos('.DVD',title);
if i <> 0 then
begin
title := copy(title,1,i-1);
end;
i:=pos('.DIVX',title);
if i <> 0 then
begin
title := copy(title,1,i-1);
end;
i:=pos('.FREN',title);
if i <> 0 then
begin
title := copy(title,1,i-1);
end;
i:=pos('.GERM',title);
if i <> 0 then
begin
title := copy(title,1,i-1);
end;
i:=pos('.INT',title);
if i <> 0 then
begin
title := copy(title,1,i-1);
end;
i:=pos('.LIM',title);
if i <> 0 then
begin
title := copy(title,1,i-1);
end;
i:=pos('.PROP',title);
if i <> 0 then
begin
title := copy(title,1,i-1);
end;
i:=pos('.REPACK',title);
if i <> 0 then
begin
title := copy(title,1,i-1);
end;
i:=pos('.SUBB',title);
if i <> 0 then
begin
title := copy(title,1,i-1);
end;
i:=pos('.UNSUB',title);
if i <> 0 then
begin
title := copy(title,1,i-1);
end;
i:=pos('.WS',title);
if i <> 0 then
begin
title := copy(title,1,i-1);
end;
i:=pos('.XVID',title);
if i <> 0 then
begin
title := copy(title,1,i-1);
end;
i:=pos('.AC3',title);
if i <> 0 then
begin
title := copy(title,1,i-1);
end;
i:=pos('.UNRAT',title);
if i <> 0 then
begin
title := copy(title,1,i-1);
end;
title := StringReplace(title, '.', ' ');
title := StringReplace(title, ',', ' ');
title := StringReplace(title, ':', '');
title := StringReplace(title, '-', '');
title := StringReplace(title, ' ', ' ');
i := 0;
// Nettoie les tags de team
if (pos('(',title) <> 0) then
begin
i := pos('(',title);
temp := copy(title,0,i-1);
j := pos(')',title);
fin := Length(title);
title := temp + copy(title,j+1,fin);
end;
if (pos('[',title) <> 0) then
begin
i := pos('[',title);
temp := copy(title,1,i-1);
j := pos(']',title);
fin := Length(title);
title := temp + copy(title,j+1,fin);
end;
title := AnsiLowerCase(title);
title := AnsiUpFirstLetter(title);
title := AnsiMixedCase(title,' -');
end;
result := title;
end;
//------------------------------------------------------------------------------
// PROGRAMME PRINCIPAL
//------------------------------------------------------------------------------
begin
if CheckVersion(3,4,0) then
begin
numPageR := 1;
MovieName := GetField(fieldTranslatedTitle);
if MovieName = '' then
MovieName := GetField(fieldOriginalTitle);
MovieName := cleanTitle(MovieName);
if (ConfirmTitre = 1) then
begin
if Input('DVD Maxxx', 'Entrez le titre du film :', MovieName) then
begin
url_recherche := AnalyzePageAccueil('http://www.cyberdvdx.com/GSWeb/microcom.gswa');
AnalyzePage(url_recherche);
end;
end;
end;
end;