Voilà je viens de mettre à jour mon script pendant ma pause déjeuner...
Code: Select all
// GETINFO SCRIPTING
// JeuxVideo.com import v1.1
(***************************************************
* Game importation script for: *
* JeuxVideo.com, http://www.jeuxvideo.com *
* *
* Script by Crevette 05/02/04 *
* *
* For use with Ant Movie Catalog 3.4.2 *
* 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 JeuxVideo;
const
ConfirmTitre = True; // False : ne demande pas de confirmation du titre avant recherche
ExternalPictures = False;
{ True: Les images seront stockées en tant que fichiers dans le même dossier que le catalogue
False: Les images seront stockées dans le catalogue (seulement pour les fichiers .amc)
}
IsDisplayResults = False; // True : permet de selectionner les champs à importer dans la fiche
var
GameName: string;
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;
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr, Count: Integer;
Line, GameAddress, Value: string;
BeginPos, EndPos: Integer;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
if pos('Test avec JeuxVideo.com</title>', Page.Text) > 0 then
AnalyzeGamePage(Page);
if pos('<img height=21 src="pics/', Page.Text) > 0 then
begin
// Titre Original
LineNr := FindLine('<b><font face="verdana, arial, helvetica, sans-serif" size="4">', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<b><font face="verdana, arial, helvetica, sans-serif" size="4">', Line) + 63;
EndPos := pos('</font></b></td>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldOriginalTitle, Value);
end;
// Adresse de la jaquette chez Alapage.com
LineNr := FindLine('Cliquez pour acheter ce jeu!', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('F&REF_NOVA=', Line) + 11;
EndPos := pos('" target=', Line);
Value := 'http://www.alapage.com/get_img.php?cgi=disque_l&num_ref=' + copy(Line, BeginPos, EndPos - BeginPos) + 'r.jpg';
GetPicture(Value, ExternalPictures);
end;
// Adresse du Test Complet
LineNr := FindLine('Test Complet', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<a href="', Line) + 9;
EndPos := pos('"><b>', Line);
Address := copy(Line, BeginPos, EndPos - BeginPos);
AnalyzePage(Address);
end else
SetField(fieldDescription, 'JeuxVideo.com n''a pas encore de Test Complet pour ' + GameName +'.');
end else
begin
PickTreeClear;
// Liste des Jeux Trouvés
LineNr := FindLine('<br>Nous avons trouvé ', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('color="#FF3300">', Line) + 16;
EndPos := pos('</font></b></font>', Line);
if (EndPos - BeginPos > 0) then
begin
PickTreeAdd(copy(Line, BeginPos, EndPos - BeginPos) +' jeux trouvés pour ' + GameName + ' :', '');
Count := StrToInt(copy(Line, BeginPos, EndPos - BeginPos), 0);
Delete(Line, 1, EndPos + 18);
While (Count > 0) do
begin
LineNr := FindLine('<p><img src="/pics/', Page, LineNr) ;
Line := Page.GetString(LineNr);
BeginPos := pos('<font size="4">', Line) + 15;
EndPos := pos('</font></b></font><br>', Line);
PickTreeAdd(copy(Line, BeginPos, EndPos - BeginPos), '');
Delete(Line, 1, EndPos + 22);
LineNr := FindLine('<a href="http://www.jeuxvideo.com/jeux/', Page, LineNr);
Repeat
Line := Page.GetString(LineNr);
BeginPos := pos('<a href="http://www.jeuxvideo.com/jeux/', Line) + 9;
If BeginPos > 9 then
begin
EndPos := pos('">', Line);
GameAddress := copy(Line, BeginPos, EndPos - BeginPos);
BeginPos := EndPos + 2;
EndPos := pos('</a><br>', Line);
PickTreeAdd(copy(Line, BeginPos, EndPos - BeginPos), GameAddress);
Delete(Line, 1, EndPos + 8);
Count := Count - 1;
end;
LineNr := LineNr + 1;
Until (pos('</font></p></blockquote>', Page.GetString(LineNr)) <> 0);
end;
end;
if PickTreeExec(Address) then
AnalyzePage(Address);
end;
end;
Page.Free;
end;
procedure AnalyzeGamePage(Page: TStringList);
var
Pageaff: TStringList;
Line, Value: string;
LineNr: Integer;
IntValue: Integer;
BeginPos: Integer;
EndPos: Integer;
Offset, Count: Integer;
begin
// Editeur
LineNr := FindLine('<font color="#CC0000">Editeur:', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('target="_blank">', Line) + 16;
EndPos := pos('</a><br>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldProducer, Value);
end;
// Développeur
LineNr := FindLine('<font color="#CC0000">Développeur', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('target="_blank">', Line) + 16;
EndPos := pos('</a><br>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldDirector, Value);
end;
// Site Web Officiel
LineNr := FindLine('<font color="#CC0000">Site web officiel', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('<a href="', Line) + 9;
EndPos := pos('" target=', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldUrl, Value);
end;
// Type de Jeu
LineNr := FindLine('<font color="#CC0000">Type', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('target=_new>', Line) + 12;
EndPos := pos('</a>', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldCategory, Value);
end;
// Date de Sortie
LineNr := FindLine('<font color="#CC0000">Sortie', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr+1);
SetField(fieldSource, Line);
end;
// Test Complet (Description)
LineNr := FindLine('<p align="justify">', Page, 0);
if LineNr > -1 then
begin
Value := '';
LineNr := LineNr + 1;
repeat
Line := Page.GetString(LineNr);
Value := Value + Line + #13#10#13#10;
LineNr := LineNr + 3;
until (pos('<', Page.GetString(LineNr)) <> 0);
SetField(fieldDescription, Value);
end;
// En Bref... (Commentaires)
LineNr := FindLine('En bref...', Page, 0);
if LineNr > -1 then
begin
Value := '';
// Graphisme
Line := Page.GetString(LineNr);
BeginPos := pos('color="#009900">', Line) + 16;
EndPos := pos('</font></b><br>', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + ' : ';
// Note
Line := Page.GetString(LineNr + 2);
BeginPos := pos('face="Tahoma, Arial, Helvetica, sans-serif">', Line) + 44;
EndPos := pos('</font><font face=', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + '/20' + #13#10;
// Commentaire
Line := Page.GetString(LineNr + 1);
BeginPos := pos('<font size="1" face="Tahoma, Arial, Helvetica, sans-serif">', Line) + 59;
EndPos := pos('</font></td>', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + #13#10#13#10;
LineNr := LineNr + 3;
// Jouabilité
Line := Page.GetString(LineNr);
BeginPos := pos('color="#009900">', Line) + 16;
EndPos := pos('</font></strong>', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + ' : ';
// Note
Line := Page.GetString(LineNr + 1);
BeginPos := pos('face="Tahoma, Arial, Helvetica, sans-serif">', Line) + 44;
EndPos := pos('</font><font face=', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + '/20' + #13#10;
// Commentaire
Line := Page.GetString(LineNr + 1);
BeginPos := 1;
EndPos := pos('</font></td>', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + #13#10#13#10;
LineNr := LineNr + 2;
// Durée de vie
Line := Page.GetString(LineNr);
BeginPos := pos('color="#009900">', Line) + 16;
EndPos := pos('</font></strong>', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + ' : ';
// Note
Line := Page.GetString(LineNr + 2);
BeginPos := pos('face="Tahoma, Arial, Helvetica, sans-serif">', Line) + 44;
EndPos := pos('</font><font face=', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + '/20' + #13#10;
// Commentaire
Line := Page.GetString(LineNr + 1);
BeginPos := pos('<font size="1" face="Tahoma, Arial, Helvetica, sans-serif">', Line) + 59;
EndPos := pos('</font></td>', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + #13#10#13#10;
LineNr := LineNr + 3;
// Bande son
Line := Page.GetString(LineNr);
BeginPos := pos('color="#009900">', Line) + 16;
EndPos := pos('</font></strong>', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + ' : ';
// Note
Line := Page.GetString(LineNr + 2);
BeginPos := pos('face="Tahoma, Arial, Helvetica, sans-serif">', Line) + 44;
EndPos := pos('</font><font face=', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + '/20' + #13#10;
// Commentaire
Line := Page.GetString(LineNr + 1);
BeginPos := pos('<font face="Tahoma, Arial, Helvetica, sans-serif">', Line) + 50;
EndPos := pos('</font></font></td>', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + #13#10#13#10;
LineNr := LineNr + 3;
// Scénario
Line := Page.GetString(LineNr);
BeginPos := pos('color="#009900">', Line) + 16;
EndPos := pos('</font></strong>', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + ' : ';
// Note
Line := Page.GetString(LineNr + 2);
BeginPos := pos('face="Tahoma, Arial, Helvetica, sans-serif">', Line) + 44;
EndPos := pos('</font><font face=', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + '/20' + #13#10;
// Commentaire
Line := Page.GetString(LineNr + 1);
BeginPos := pos('<font face="Tahoma, Arial, Helvetica, sans-serif">', Line) + 50;
EndPos := pos('</font></font></td>', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + #13#10#13#10;
LineNr := LineNr + 3;
// Note générale
Line := Page.GetString(LineNr);
BeginPos := pos('color="#FF0000" size="4">', Line) + 25;
EndPos := pos('</font></strong>', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + ' : ';
// Note
Line := Page.GetString(LineNr + 2);
BeginPos := pos('color="#FF0000">', Line) + 16;
EndPos := pos('</font><font face=', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + '/20' + #13#10;
SetField(fieldRating, IntToStr(StrToInt(copy(Line, BeginPos, EndPos - BeginPos),0) div 2));
// Commentaire
Line := Page.GetString(LineNr + 1);
BeginPos := pos('<font size="1" face="Tahoma, Arial, Helvetica, sans-serif">', Line) + 59;
EndPos := pos('</font></td>', Line);
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + #13#10#13#10;
SetField(fieldComments, Value);
end;
if IsDisplayResults then
DisplayResults;
end;
begin
if CheckVersion(3,4,2) then
begin
GameName := GetField(fieldOriginalTitle);
if GameName = '' then
GameName := GetField(fieldTranslatedTitle);
if ConfirmTitre then
begin
if Input('JeuxVideo.com Import', 'Entrez le nom du jeu :', GameName) then
AnalyzePage('http://www.jeuxvideo.com/schr.htm?textfield='+UrlEncode(GameName)+'&range=-');
end else
AnalyzePage('http://www.jeuxvideo.com/schr.htm?textfield='+UrlEncode(GameName)+'&range=-');
end else
ShowMessage('Ce script requiert la version 3.4.2 ou supérieure de Ant Movie Catalog.');
end.