Voici les 2 scripts que j'utilise (ils sont assez complémentaires et quand il ya pas l'info sur un site, il y a sur l'autre)
Pour BDNet
Code: Select all
// GETINFO SCRIPTING
// BDnet
(***************************************************
***************************************************)
program BDNET;
const
MustImportBitrate = False; // set this to True if you want to take the bitrate information from the site
BaseURL = 'http://www.bdnet.com';
newLine = #13#10;
var
BDName: string;
procedure GetBdReferences(Address: string; CleanTree: Integer);
var
Page: TStringList;
LineNr: Integer;
Line, Tags, Url, Caption: string;
SubL1, SubL2: string;
BeginPos, EndPos: Integer;
begin
// Get Page contents
Line := GetPage(Address);
if Pos('<TITLE>Votre Recherche:', Line) > 0 then
begin
if CleanTree = 1 then
begin
PickTreeClear;
PickTreeAdd('BD trouvées :', '');
end;
Tags := '<TABLE WIDTH="100%" BORDER="1" VSPACE="0" HSPACE="0" HEIGHT="0" BORDERCOLOR="#FFC271" CELLPADDING="0" CELLSPACING="0">';
// Look if we get the correct page
if Pos(Tags, Line) > 0 then
begin
// We have the correct page
// Delete the start of the page that we do not need
BeginPos := Pos(Tags, Line);
Delete(Line, 1, BeginPos + Length(Tags));
// Find the interessting parts in the page
EndPos := Pos('<CENTER>', Line);
// SubL1 contains the part of the page with the title references
SubL1 := Copy(Line, 1, EndPos);
// In SubL1, look for references
while Pos('<TR', SubL1) > 0 do
begin
// Isolate TR block
BeginPos := Pos('<TR', SubL1);
EndPos := Pos('</TR>', SubL1);
// SubL2 contains TR block
SubL2 := Copy(SubL1, BeginPos, EndPos - BeginPos);
// Look for URL
BeginPos := Pos('<A HREF="', SubL2);
Delete(SubL2, 1, BeginPos + Length('<A HREF="')-1);
EndPos := Pos('">', SubL2);
Url := BaseURL + Copy(SubL2, 1, EndPos-1);
// Look for Description
EndPos := Pos('<A HREF="', SubL2);
Delete(SubL2, 1, EndPos + Length('<A HREF="'));
EndPos := Pos('<B>', SubL2);
Delete(SubL2, 1, EndPos + Length('<B>')-1);
EndPos := Pos('</B>', SubL2);
Caption := Copy(SubL2, 1, EndPos-1);
// Add description and URL to Tree
PickTreeAdd(Caption, Url);
// Look for next block
EndPos := Pos('</TABLE>', SubL1);
Delete(SubL1, 1, EndPos + Length('</TABLE>'));
EndPos := Pos('</TABLE>', SubL1);
Delete(SubL1, 1, EndPos + Length('</TABLE>'));
end;
// Test the presence of other pages
Tags := '</B> pages trouv';
if Pos (Line, Tags) = 0 then
begin
// There are other pages withe references
EndPos := Pos(Tags, Line);
Delete(Line, 1, EndPos + Length(Tags));
EndPos := Pos('IMG', Line);
// Put in SubL1 the part that contains reference to other pages
SubL1 := Copy(Line, 1, EndPos);
// Parse references
while Pos('<A href="', SubL1) > 0 do
begin
Tags := '/recherche.htm';
EndPos := Pos(Tags, SubL1);
Delete(SubL1, 1, EndPos-1);
EndPos := Pos('"', SubL1);
Url := BaseURL + Copy(SubL1, 1, EndPos-1);
Delete(SubL1, 1, EndPos);
EndPos := Pos('>', SubL1);
Delete(SubL1, 1, EndPos);
EndPos := Pos('<', SubL1);
Caption := Copy(SubL1, 1, EndPos-1);
if Caption = '>' then
begin
// Only save reference of "Next" Page
PickTreeMoreLink(Url);
end;
Tags := '</A>';
EndPos := Pos(SubL1, SubL1);
Delete(SubL1, 1, EndPos + Length(Tags));
end;
end;
// Show references found to users
if PickTreeExec(Address) then
begin
GetBdReferences(Address, 0);
end;
end;
end else
begin
SetField(fieldURL, Address);
AnalyzeBdPage(Line);
end;
end;
procedure AnalyzeBdPage(Line: string);
var
Page: TStringList;
LineNr: Integer;
StartTag, EndTag : string;
SubL1, SubL2, SubL3, SubL4: string;
BeginPos, EndPos: Integer;
begin
// Get interessting part from page
StartTag := 'function pop(';
EndTag := 'function go(';
BeginPos := Pos (StartTag, Line);
EndPos := Pos (EndTag, Line);
SubL1 := Copy (Line, BeginPos, EndPos);
// Get Picture
StartTag := '<TD WIDTH="150" VALIGN="MIDDLE"><img src="';
if Pos (StartTag, SubL1) > 0 then
begin
EndTag := '" border=1 align=left>';
BeginPos := Pos (StartTag, SubL1);
SubL2 := Copy ( SubL1, BeginPos + Length(StartTag)-1, Length(SubL1));
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, EndPos, Length(SubL2));
GetPicture(SubL2, False);
end;
// Year
StartTag := 'Paru en: ';
if Pos (StartTag, SubL1) > 0 then
begin
EndTag := '</FONT>';
BeginPos := Pos (StartTag, SubL1);
SubL2 := Copy ( SubL1, BeginPos + Length(StartTag)-1, Length(SubL1));
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, EndPos, Length(SubL2));
Delete ( SubL2, 1, Length(SubL2)-4);
SetField( fieldActors, SubL2);
end;
// Get Serie name
StartTag := '<B>Série: </B>';
if Pos (StartTag, SubL1) > 0 then
begin
EndTag := '>';
BeginPos := Pos (StartTag, SubL1);
SubL2 := Copy ( SubL1, BeginPos + Length(StartTag)-1, Length(SubL1));
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, 1, EndPos);
StartTag := '">';
EndTag := '</A><BR>';
BeginPos := Pos (StartTag, SubL2);
Delete ( SubL2, 1, BeginPos + Length(StartTag)-1);
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, EndPos, Length(SubL2));
SetField( fieldSource, SubL2);
end;
// Get Dessinateur
StartTag := '<B>Dessinateur:</B>';
if Pos (StartTag, SubL1) > 0 then
begin
EndTag := '>';
BeginPos := Pos (StartTag, SubL1);
SubL2 := Copy ( SubL1, BeginPos + Length(StartTag)-1, Length(SubL1));
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, 1, EndPos);
StartTag := '">';
EndTag := '</A><BR>';
BeginPos := Pos (StartTag, SubL2);
Delete ( SubL2, 1, BeginPos + Length(StartTag)-1);
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, EndPos, Length(SubL2));
SetField( fieldProducer, SubL2);
end;
// Get Scenariste
StartTag := '<B>Scénariste:</B>';
if Pos (StartTag, SubL1) > 0 then
begin
EndTag := '>';
BeginPos := Pos (StartTag, SubL1);
SubL2 := Copy ( SubL1, BeginPos + Length(StartTag)-1, Length(SubL1));
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, 1, EndPos);
StartTag := '">';
EndTag := '</A><BR>';
BeginPos := Pos (StartTag, SubL2);
Delete ( SubL2, 1, BeginPos + Length(StartTag)-1);
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, EndPos, Length(SubL2));
SetField( fieldDirector, SubL2);
end;
// Get Genre
StartTag := '<B>Genre:</B>';
if Pos (StartTag, SubL1) > 0 then
begin
EndTag := '>';
BeginPos := Pos (StartTag, SubL1);
SubL2 := Copy ( SubL1, BeginPos + Length(StartTag)-1, Length(SubL1));
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, 1, EndPos);
StartTag := '">';
EndTag := '</A><BR>';
BeginPos := Pos (StartTag, SubL2);
Delete ( SubL2, 1, BeginPos + Length(StartTag)-1);
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, EndPos, Length(SubL2));
SetField( fieldCategory, SubL2);
end;
// Get Editeur
StartTag := '<B>Editeur:</B>';
if Pos (StartTag, SubL1) > 0 then
begin
EndTag := '>';
BeginPos := Pos (StartTag, SubL1);
SubL2 := Copy ( SubL1, BeginPos + Length(StartTag)-1, Length(SubL1));
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, 1, EndPos);
StartTag := '">';
EndTag := '</A><BR>';
BeginPos := Pos (StartTag, SubL2);
Delete ( SubL2, 1, BeginPos + Length(StartTag)-1);
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, EndPos, Length(SubL2));
SetField( fieldCountry, SubL2);
end;
// Get Tome#
StartTag := ', tome ';
if Pos (StartTag, SubL1) > 0 then
begin
EndTag := '</B>';
BeginPos := Pos (StartTag, SubL1);
SubL2 := Copy ( SubL1, BeginPos + Length(StartTag)+2, Length(SubL1)+1);
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, EndPos, Length(SubL2));
SetField( fieldYear, SubL2);
end;
// Get Titre
StartTag := 'SIZE="4" COLOR="#3366CC">';
if Pos (StartTag, SubL1) > 0 then
begin
EndTag := '</FONT>';
BeginPos := Pos (StartTag, SubL1);
SubL2 := Copy ( SubL1, BeginPos + Length(StartTag), Length(SubL1));
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, EndPos, Length(SubL2));
SetField( fieldOriginalTitle, SubL2);
end;
// Get Résumé
StartTag := 'Commentaires:</FONT>';
if Pos (StartTag, SubL1) > 0 then
begin
EndTag := '"Cliquez pour agrandir">';
BeginPos := Pos (StartTag, SubL1);
SubL2 := Copy ( SubL1, BeginPos + Length(StartTag)-1, Length(SubL1));
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, 1, EndPos);
StartTag := '<FONT FACE="Verdana, Arial, Helvetica, sans-serif" SIZE="2">';
EndTag := '</FONT>';
BeginPos := Pos (StartTag, SubL2);
Delete ( SubL2, 1, BeginPos + Length(StartTag)-1);
EndPos := Pos (EndTag, SubL2);
Delete ( SubL2, EndPos, Length(SubL2));
SetField( fieldDescription, SubL2);
end;
end;
begin
if CheckVersion(3,4,1) then
begin
BDName := GetField(fieldOriginalTitle);
if Input('BDnet Import', 'Entrez le titre de la BD :', BDName) then
begin
// AnalyzePage(BaseURL + '/recherche.htm?u=BDNET:RECHERCHE&type=titre&recherche='+UrlEncode(BDName));
GetBdReferences(BaseURL + '/recherche.htm?u=BDNET:RECHERCHE&type=titre&recherche='+UrlEncode(BDName),1);
end;
end else
ShowMessage('Ce script requiert la version 3.4.1 ou supérieure de Ant Movie Catalog.');
end.
Pour BDParadisio:
Code: Select all
// GETINFO SCRIPTING
// BD Paradisio import
program BDParadisio;
const
MustImportBitrate = False; // set this to True if you want to take the bitrate information from the site
BaseURL = 'http://www.bdparadisio.com/';
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 GetReferences(Address: string; QueryType: Integer);
var
Page: TStringList;
LineNr: Integer;
Line, StartTag, EndTag, Url, Caption: string;
SubL1, SubL2, SubL3, SubL4: string;
BeginPos, EndPos: Integer;
begin
// Get search page. Get it twice due to cookie problems
Line := GetPage(Address);
Line := GetPage(Address);
if Pos('<A HREF="detailbd.cfm', Line) > 0 then
begin
// We have the correct page.
// Some initialisation
PickTreeClear;
StartTag := '<Table border=0 cellpadding=5>';
EndTag := '</TABLE>';
BeginPos := Pos ( StartTag, Line );
EndPos := Pos ( EndTag, Line );
SubL1 := Copy ( Line, BeginPos, EndPos-BeginPos-Length(StartTag) );
while Pos( '<A HREF="detailbd.cfm', SubL1 ) > 0 do
begin
// Get the URL
StartTag := 'A HREF="';
EndTag := '">';
BeginPos := Pos ( StartTag, SubL1 );
EndPos := Pos ( EndTag, SubL1 );
Url := BaseURL + 'scripts/' + Copy ( SubL1, BeginPos + Length(StartTag), EndPos-BeginPos-Length(StartTag) );
// get the caption
StartTag := '">';
EndTag := '</A>';
BeginPos := Pos ( StartTag, SubL1 );
EndPos := Pos ( EndTag, SubL1 );
Caption := Copy ( SubL1, BeginPos + Length(StartTag), EndPos-BeginPos-Length(StartTag) );
// Add the entry to the tree
PickTreeAdd(Caption, Url);
// Remove processes parts
EndTag := '</A>';
EndPos := Pos ( EndTag, SubL1 );
Delete ( SubL1, 1, EndPos );
end;
if PickTreeExec(Address) then
begin
AnalyseBdPage(Address);
end;
end else
begin
if QueryType = 1 then
begin
GetReferences(BaseURL + 'scripts/albums.cfm?DateFrom=1/1/50&iEditeur=all&sCollection=&sSerie=&Tri=DateSortie&resumeOnly=yes&sTitre='+UrlEncode(BDName), 2);
end else
begin
ShowMessage('Aucune références trouvées');
end;
end;
end;
procedure AnalyseBdPage(Address: string);
var
Page: TStringList;
LineNr: Integer;
Line, StartTag, EndTag, Url, Caption: string;
SubL1, SubL2, SubL3, SubL4: string;
BeginPos, EndPos: Integer;
begin
SetField(fieldUrl, Address);
Line := GetPage(Address);
if Pos('<TITLE>BdParadisio : BD Detail</TITLE>', Line) > 0 then
begin
// Get Title
StartTag := '<h2>';
EndTag := '</H2> ';
BeginPos := Pos ( StartTag, Line );
EndPos := Pos ( EndTag, Line );
SetField(fieldOriginalTitle, Copy(Line, BeginPos+Length(StartTag), EndPos-BeginPos-Length(StartTag)));
// Get data part of the page
StartTag := '<table>';
EndTag := '</table>';
BeginPos := Pos ( StartTag, Line );
EndPos := Pos ( EndTag, Line );
SubL1 := Copy ( Line, BeginPos, EndPos-BeginPos-Length(StartTag) );
// Get Picture
StartTag := '<IMG src="';
EndTag := '" ';
BeginPos := Pos ( StartTag, SubL1 );
Delete ( SubL1, 1, BeginPos+Length(StartTag));
EndPos := Pos ( EndTag, SubL1 );
SubL2 := Copy(SubL1, 1, EndPos-1);
GetPicture(BaseURL + SubL2, False);
// Get serie name
StartTag := 'Serie : ';
BeginPos := Pos ( StartTag, SubL1 );
Delete ( SubL1, 1, BeginPos+Length(StartTag));
StartTag := '">';
EndTag := '</A>';
BeginPos := Pos ( StartTag, SubL1 );
EndPos := Pos ( EndTag, SubL1 );
SubL2 := Copy ( SubL1, BeginPos+Length(StartTag), EndPos-BeginPos-Length(StartTag) );
SetField ( fieldSource, Trim(SubL2) );
Delete ( SubL1, 1, EndPos);
// Parution
StartTag := 'Date de parution :';
BeginPos := Pos ( StartTag, SubL1 );
Delete ( SubL1, 1, BeginPos+Length(StartTag));
EndTag := '<br>';
EndPos := Pos ( EndTag, SubL1 );
SubL2 := Copy ( SubL1, 1, EndPos-1);
SetField ( fieldActors, Trim(SubL2) );
Delete ( SubL1, 1, EndPos);
// Tome #
StartTag := 'album :';
BeginPos := Pos ( StartTag, SubL1 );
Delete ( SubL1, 1, BeginPos+Length(StartTag));
EndTag := '<br>';
EndPos := Pos ( EndTag, SubL1 );
SubL2 := Copy ( SubL1, 1, EndPos-1);
SetField ( fieldYear, Trim(SubL2) );
Delete ( SubL1, 1, EndPos);
// # pages
StartTag := 'Nombre de pages :';
BeginPos := Pos ( StartTag, SubL1 );
Delete ( SubL1, 1, BeginPos+Length(StartTag));
EndTag := '<br>';
EndPos := Pos ( EndTag, SubL1 );
SubL2 := Copy ( SubL1, 1, EndPos-1);
SetField ( fieldLength, Trim(SubL2) );
Delete ( SubL1, 1, EndPos);
// Editeur
StartTag := 'Edition :';
BeginPos := Pos ( StartTag, SubL1 );
Delete ( SubL1, 1, BeginPos+Length(StartTag));
EndTag := '<br>';
EndPos := Pos ( EndTag, SubL1 );
SubL2 := Copy ( SubL1, 1, EndPos-1);
SetField ( fieldCountry, Trim(SubL2) );
Delete ( SubL1, 1, EndPos);
// Auteurs
StartTag := 'Auteurs :';
BeginPos := Pos ( StartTag, SubL1 );
Delete ( SubL1, 1, BeginPos+Length(StartTag));
StartTag := '<A HREF=';
EndTag := '<a href="CriticsAdd.';
BeginPos := Pos ( StartTag, SubL1 );
EndPos := Pos ( EndTag, SubL1 );
SubL2 := Copy ( SubL1, BeginPos+Length(StartTag), EndPos-BeginPos-Length(StartTag) );
// Look to see if scenariste and dessisnateur are the same
if Pos ('alt="Scénariste" hspace=2><img src="/IcoDes.gif"', SubL2) > 0 then
begin
// Get Scenariste & Dessinateur
StartTag := '">';
BeginPos := Pos ( StartTag, SubL2 );
EndTag := '</A>';
EndPos := Pos ( EndTag, SubL2 );
SubL3 := Copy ( SubL2, BeginPos+Length(StartTag), EndPos-BeginPos-Length(StartTag) );
SetField(fieldDirector, Trim(SubL3));
SetField(fieldProducer, Trim(SubL3));
end else
begin
// Get Scenariste
StartTag := '">';
BeginPos := Pos ( StartTag, SubL2 );
EndTag := '</A>';
EndPos := Pos ( EndTag, SubL2 );
SubL3 := Copy ( SubL2, BeginPos+Length(StartTag), EndPos-BeginPos-Length(StartTag) );
SetField(fieldDirector, Trim(SubL3));
// Get Dessinateur
Delete ( SubL2, 1, EndPos+Length(EndTag));
StartTag := '">';
BeginPos := Pos ( StartTag, SubL2 );
EndTag := '</A>';
EndPos := Pos ( EndTag, SubL2 );
SubL3 := Copy ( SubL2, BeginPos+Length(StartTag), EndPos-BeginPos-Length(StartTag) );
SetField(fieldProducer, Trim(SubL3));
end;
// Résumé
StartTag := '<a href="CriticsAdd.cfm?Id=';
BeginPos := Pos ( StartTag, SubL1 );
Delete ( SubL1, 1, BeginPos+Length(StartTag));
StartTag := '<p>';
Delete ( SubL1, 1, Pos ( StartTag, SubL1 )+Length(StartTag));
Delete ( SubL1, 1, Pos ( StartTag, SubL1 )+Length(StartTag));
SubL2 := DelFirstBlank ( SubL1 );
EndPos := Pos ( #10, SubL2 );
SubL3 := Copy ( SubL2, 1, EndPos);
HTMLRemoveTags(SubL3);
SetField(fieldDescription,Trim(SubL3));
end;
end;
begin
if CheckVersion(3,4,1) then
begin
BDName := GetField(fieldOriginalTitle);
if Input('BD Paradisio Import', 'Entrez le titre de la BD :', BDName) then
begin
// Look for Series
GetReferences(BaseURL + 'scripts/albums.cfm?DateFrom=1/1/50&iEditeur=all&sCollection=&Tri=DateSortie&sTitre=&resumeOnly=yes&sSerie='+UrlEncode(BDName), 1);
end;
end else
ShowMessage('Ce script requiert la version 3.4.1 ou supérieure de Ant Movie Catalog.');
end.
Jekkil