Voici le fichier script "BD land.ifs" complet.
Code: Select all
// GETINFO SCRIPTING
// BD land (BD FR) import with picture
(***************************************************
* Movie importation script for: *
* bdland.com, http://www.bdland.com/ *
* *
* (c) 2003 Rincevent *
* *
* For use with Ant Movie Catalog 3.4.1 *
* 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 bdland;
var
BDName: string;
function DelFirstBlank(line: string): string;
begin
while ( (pos(' ', line) = 1)
or (pos(#09, line) = 1)
or (pos(#13, line) = 1)
or (pos(#10, line) = 1) ) do
Delete(line, 1, 1);
result := line;
end;
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
BDTitle: string;
Line: string;
BeginPos, EndPos: Integer;
begin
Line := GetPage(Address);
if Pos('<title>BDLand', Line) > 0 then
begin
PickTreeClear;
// Supprime le debut jusqu'a la liste des albums
BeginPos := pos('<Span class=rubtitre>Résultat de Recherche...</Span>', Line);
Delete(Line, 1, BeginPos - 1);
BeginPos := pos('</table>' , Line);
Delete(Line, 1, BeginPos - 1);
BeginPos := pos('</table>' , Line);
Delete(Line, 1, BeginPos - 1);
BeginPos := pos('<p align="center" Class=rubTexteGras>', Line);
while (BeginPos > 0) do
begin
Delete(Line, 1, BeginPos);
Delete(Line, 1, pos('>', Line));
BDTitle := copy(Line, 1, pos('</p>', Line) - 1);
HTMLRemoveTags(BDTitle);
HTMLDecode(BDTitle);
PickTreeAdd(BDTitle, '');
AddBDTitles(Line);
BeginPos := pos('<p align="center" Class=rubTexteGras>', Line);
end;
// PickTreeMoreLink('http://www.allocine.fr/recherche/');
if PickTreeExec(Address) then
begin
Line := GetPage(Address);
SetField(fieldURL, Address);
AnalyzeBDPage(Line);
end
end;
end;
procedure AddBDTitles(var Line: string);
var
BDTitle, BDAddress: string;
StartPos, EndPos: Integer;
begin
StartPos := pos('<a Class=Rub href="/cgi-bin/albumaff.cgi', Line);
repeat
if StartPos > 0 then
begin
Delete(Line, 1, StartPos - 1);
BDTitle := copy(Line, 1, pos('</a>', Line));
//MovieTitle := '<' + MovieTitle;
HTMLRemoveTags(BDTitle);
HTMLDecode(BDTitle);
BDAddress := copy(Line, 1, pos('">', Line) - 1);
BDAddress :=StringReplace(BDAddress, '.cgi?', '.cgi?na=1&');
Delete(BDAddress, 1, pos('"', BDAddress));
PickTreeAdd(BDTitle, 'http://www.bdland.com' + BDAddress);
end;
Delete(Line, 1, pos('>', Line));
StartPos := pos('<a Class=Rub href="/cgi-bin/albumaff.cgi', Line);
EndPos := pos('<p align="center" Class=rubTexteGras>', Line);
until (StartPos < 1) or ((StartPos > EndPos) and (EndPos > 0));
end;
procedure AnalyzeBDPage(PageContents: string);
var
Line, Value: string;
LineNr, BeginPos, EndPos: Integer;
Page: TStringList;
begin
// Titre
BeginPos := Pos('<td class=rubentete', PageContents);
delete(PageContents,1,BeginPos - 1);
Value := copy(PageContents, 1, pos('</td>',PageContents)-1);
HTMLRemoveTags(Value);
HTMLDecode(Value);
BeginPos := Pos('(Tome', Value);
if (BeginPos > 0) then
begin
Value := 'T' + copy(Value,BeginPos +5, pos(')',Value) - BeginPos-5) + ': ' + Value;
Value := copy(Value,1, pos('(',Value) -1);
if (pos(':',Value) > 4) then
Value := StringReplace(Value,'T ', 'T');
end;
SetField(fieldOriginalTitle, Value);
//Série
BeginPos := Pos('<td valign=top bgcolor=#DBDBFF class=rubtextegras>', PageContents);
delete(PageContents,1,BeginPos - 1);
delete(PageContents,1, pos('</td>',PageContents) +4);
Value := Copy(PageContents, 1, pos('</td>',PageContents) -1 );
HTMLRemoveTags(Value);
HTMLDecode(Value);
Value := StringReplace(Value,' ', '');
SetField(fieldSource, Value);
//Editeur
BeginPos := Pos('<td valign=top bgcolor=#DBDBFF class=rubtextegras>', PageContents);
delete(PageContents,1,BeginPos - 1);
delete(PageContents,1, pos('</td>',PageContents) -1);
Value := Copy(PageContents, 1, pos('</a>',PageContents) -1 );
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldCountry, Value);
//Genre
BeginPos := Pos('<td valign=top bgcolor=#DBDBFF class=rubtextegras>', PageContents);
delete(PageContents,1,BeginPos - 1);
delete(PageContents,1, pos('</td>',PageContents) +4);
Value := Copy(PageContents, 1, pos('</td>',PageContents) -1 );
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldCategory, Value);
//Scénariste
BeginPos := Pos('<td valign=top bgcolor=#DBDBFF class=rubtextegras>', PageContents);
delete(PageContents,1,BeginPos - 1);
delete(PageContents,1, pos('</td>',PageContents) +4);
Value := Copy(PageContents, 1, pos('</a>',PageContents) -1 );
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldDirector, Value);
Value := Copy(PageContents, 1, pos('</td>',PageContents) -1 );
Value := StringReplace(Value,'</a>', #13+#10);
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldActors, Value);
//Dessinateur
BeginPos := Pos('<td valign=top bgcolor=#DBDBFF class=rubtextegras>', PageContents);
delete(PageContents,1,BeginPos - 1);
delete(PageContents,1, pos('</td>',PageContents) +4);
Value := Copy(PageContents, 1, pos('</a>',PageContents) -1 );
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldProducer, Value);
Value := Copy(PageContents, 1, pos('</td>',PageContents) -1 );
Value := StringReplace(Value,'</a>', #13+#10);
HTMLRemoveTags(Value);
HTMLDecode(Value);
Value := GetField(fieldActors) + Value;
SetField(fieldActors, Value);
//Date édition
BeginPos := Pos('<td valign=top bgcolor=#DBDBFF class=rubtextegras>', PageContents);
delete(PageContents,1,BeginPos - 1);
delete(PageContents,1, pos('</td>',PageContents) +4);
Value := Copy(PageContents, 1, pos('</td>',PageContents) -1 );
HTMLRemoveTags(Value);
HTMLDecode(Value);
BeginPos := Pos('/', Value);
if (BeginPos > 0) then
delete(Value,1,BeginPos);
SetField(fieldYear, Value);
//Présentation
BeginPos := Pos('<td valign=top bgcolor=#DBDBFF class=rubtextegras>', PageContents);
delete(PageContents,1,BeginPos - 1);
delete(PageContents,1, pos('</td>',PageContents) +4);
Value := Copy(PageContents, 1, pos('</td>',PageContents) -1 );
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldMediaType, Value);
//Langue :
//Public :
//Disponibilité
//Images
BeginPos := Pos('<img src="/images/Album/' , PageContents);
if (BeginPos > 0) then
begin
delete(PageContents,1,BeginPos - 1);
delete(PageContents,1, pos('"',PageContents));
Value := Copy(PageContents, 1, pos('"',PageContents) -1 );
GetPicture('http://www.bdland.com/' + Value, False);
//SetField(fieldComments, 'http://www.bdland.com/' + Value);
end;
//Nb de pages
BeginPos := Pos('<Span class=rubtextegras>Description' , PageContents);
//SetField(fieldComments, PageContents);
if (BeginPos>0) then
begin
delete(PageContents,1,BeginPos - 1);
delete(PageContents,1, pos('pages',PageContents) -10);
delete(PageContents,1, pos('>',PageContents));
Value := Copy(PageContents, 1, pos(' pages',PageContents) -1 );
Value := StringReplace(Value,#13+#10, '');
//SetField(fieldComments, Value);
SetField(fieldLength, Value);
end;
//Résumé
BeginPos := Pos('<Span class=rubtextegras>Résumé' , PageContents);
if (BeginPos>0) then
begin
delete(PageContents,1,BeginPos - 1);
delete(PageContents,1, pos('</span>',PageContents) -1);
Value := Copy(PageContents, 1, pos('</div>',PageContents) -1 );
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldDescription, Value);
end;
//DisplayResults;
end;
begin
if CheckVersion(3,4,1) then
begin
BDName := GetField(fieldOriginalTitle);
if BDName = '' then
BDName := GetField(fieldTranslatedTitle);
if Input('BDLand.com Import', 'Entrez le titre de la BD/Série :', BDName) then
begin
AnalyzePage('http://www.bdland.com/cgi-bin/find.cgi?serie=-1000&x=r&titre='+UrlEncode(BDName)+'&collection='+UrlEncode(BDName)+'&genre=-1&presentation=-1&date=exact&langue=-1&nombre=50&traitement=or&affichage=simple');
end;
end else
ShowMessage('Ce script requiert la version 3.4.1 ou supérieure de Ant Movie Catalog.');
end.