bon je viens de faire les modifs, ca marche pour moi .. par contre c'est possible de jeter un oeil vite fait au cas ou j'aurais laissé des erreurs?? (j'ai l'impression que ce script est plus long que le script de depart..)
on a donc les grandes images de allocine.FR (si elle existe ) + la description de allocine + les infos de dvdfr.... le script ultime???
Code: Select all
// GETINFO SCRIPTING
// DVDFR.com import + Allociné.fr description & large image
(***************************************************
* Movie importation script for: *
* DVDFR.com, http://www.dvdfr.com *
* *
* (c) 2002 Antoine Potten antoine@buypin.com *
* Improved by Fabrice FERT : *
* - more fields filled *
* - description from allociné *
* *
* Improved by Nicolas Coquet : *
* - large images from allociné.fr *
* *
* For use with Ant Movie Catalog 3.4.1 *
* (there is a bug in the 3.4.0 that prevents *
* from using this script without serious *
* problems. Please upgrade if you have an *
* old version) *
* 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 DVDFR2;
const
MustImportBitrate = True; // set this to True if you want to take the bitrate information from the site
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) }
var
MovieName: 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: Integer;
Line, Tags, Caption: string;
BeginPos, EndPos: Integer;
begin
Line := GetPage(Address);
if Pos('<title>Dvdfr.com - Recherche DVDFr', Line) > 0 then
begin
PickTreeClear;
if Pos('Vos critères de recherche n''ont produit aucun résultat.', Line) = 0 then
begin
Page := TStringList.Create;
EndPos := Pos('TITLE="Page précédente"', Line) + 5;
if EndPos > 5 then
begin
BeginPos := EndPos - 70;
Tags := Copy(Line, BeginPos, EndPos - BeginPos);
BeginPos := Pos('="..', Tags) + 4;
EndPos := Pos('" TITLE', Tags);
PickTreeAdd('Page précédente', 'http://www.dvdfr.com' + Copy(Tags, BeginPos, EndPos - BeginPos));
end;
EndPos := Pos('TITLE="Page suivante"', Line) + 5;
if EndPos > 5 then
begin
BeginPos := EndPos - 70;
Tags := Copy(Line, BeginPos, EndPos - BeginPos);
BeginPos := Pos('="..', Tags) + 4;
EndPos := Pos('" TITLE', Tags);
PickTreeAdd('Page suivante', 'http://www.dvdfr.com' + Copy(Tags, BeginPos, EndPos - BeginPos));
end;
BeginPos := Pos('<table class="tableSearchResult"', Line);
Delete(Line, 1, BeginPos + Length(Tags) - 1);
BeginPos := Pos('</TR>', Line);
Delete(Line, 1, BeginPos + 5);
EndPos := Pos('</table>', Line);
Delete(Line, EndPos, Length(Line));
while Pos('<TR', Line) > 0 do
begin
BeginPos := Pos('<TR', Line);
EndPos := Pos('</TR>', Line);
Tags := Copy(Line, BeginPos, EndPos - BeginPos);
if Pos('CLASS="tableHeaderLine"', Tags) > 0 then
begin // "Letter"
EndPos := Pos('</span>', Tags);
PickTreeAdd('Films commençant par "' + Copy(Tags, EndPos - 1, 1) + '" :', '');
end else
begin // Movie
Page.Text := Tags;
Tags := Page.GetString(2);
Delete(Tags, 1, 1);
BeginPos := Pos('="..', Tags) + 4;
EndPos := Pos('">', Tags);
Address := Copy(Tags, BeginPos, EndPos - BeginPos);
HTMLRemoveTags(Tags);
Caption := Trim(Tags);
Tags := Page.GetString(3);
Delete(Tags, 1, 1);
HTMLRemoveTags(Tags);
Tags := Trim(Tags);
if Tags <> ' ' then
Caption := Caption + ' (' + Tags + ')';
Tags := Page.GetString(4);
Delete(Tags, 1, 1);
HTMLRemoveTags(Tags);
Tags := Trim(Tags);
if Tags <> ' ' then
Caption := Caption + ', ' + Tags;
PickTreeAdd(Caption, 'http://www.dvdfr.com' + Address);
end;
Delete(Line, 1, Pos('</TR>', Line) + 5);
end;
Page.Free;
end;
if PickTreeExec(Address) then
begin
AnalyzePage(Address);
end;
end else
if Pos('<title>Dvdfr.com - Fiche DVD', Line) > 0 then
begin
SetField(fieldURL, Address);
AnalyzeMoviePage(Line);
end;
end;
procedure AnalyzeMoviePage(PageContents: string);
var
Line, Value: string;
LineNr, BeginPos, EndPos, BeginPos2, EndPos2, i : Integer;
Page: TStringList;
begin
// Picture
BeginPos := Pos('src="../images/dvd/cover', PageContents);
EndPos := Pos('<div class="dvd_categorie">', PageContents);
Line := Copy(PageContents, BeginPos, EndPos - BeginPos);
EndPos := Pos('" ', Line);
Value := Copy(Line, 8, EndPos - 8);
GetPicture('http://www.dvdfr.com' + Value, False);
// Category
BeginPos := Pos('<A class="home_a" TITLE="Rechercher les autres films de même catégorie"', PageContents);
EndPos := Pos('<br><img src="../images/filet_categoriedvd.gif"', PageContents);
Value := Copy(PageContents, BeginPos, EndPos - BeginPos);
HTMLRemoveTags(Value);
SetField(fieldCategory, Trim(AnsiMixedCase(AnsiLowerCase(Value), ' ')));
//
Page := TStringList.Create;
BeginPos := Pos('<!-- Center main area -->', PageContents);
EndPos := Pos('<IMG SRC="../images/tit_pepins.gif"', PageContents);
Page.Text := Copy(PageContents, BeginPos, EndPos);
// Titles
LineNr := FindLine('<div class="dvd_title">', Page, 0);
if LineNr > -1 then
begin
Value := Trim(Page.GetString(LineNr + 1));
HTMLRemoveTags(Value);
SetField(fieldOriginalTitle, Value);
Value := Trim(Page.GetString(LineNr));
HTMLRemoveTags(Value);
Value := AnsiUpFirstLetter(AnsiLowerCase(Value));
if GetField(fieldOriginalTitle) = '' then
SetField(fieldOriginalTitle, Value)
else
SetField(fieldTranslatedTitle, Value);
// Country
Line := Page.GetString(LineNr + 2);
BeginPos := Pos('">', Line) + 2;
EndPos := Pos(' , ', Line);
Value := Copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldCountry, Value);
BeginPos := EndPos + 3;
// Year
EndPos := Pos('<br>', Line);
Value := Copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldYear, Value);
// Producer
Delete(Line, 1, EndPos - 1);
HTMLRemoveTags(Line);
SetField(fieldProducer, Line);
end;
// Note
LineNr := FindLine('/images/vote_dvdfr.gif', Page, LineNr);
if LineNr > -1 then
begin
Value := Trim(Page.GetString(LineNr));
HTMLRemoveTags(Value);
Value := StringReplace(Value, ' ', '');
EndPos := Pos(',', Value);
Line := value;
if EndPos > 0 then
Line := Copy(Value, 1, EndPos - 1);
SetField(fieldRating, Line);
end;
// Director
LineNr := FindLine('<div class="dvd_subtitle">Réalisation</div>', Page, LineNr);
if LineNr > -1 then
begin
Value := Trim(Page.GetString(LineNr + 1));
HTMLRemoveTags(Value);
SetField(fieldDirector, Value);
end;
// Actors
LineNr := FindLine('<div class="dvd_subtitle">Avec...</div>', Page, LineNr);
if LineNr > -1 then
begin
Value := StringReplace(Trim(Page.GetString(LineNr + 1)), '<br>', ',');
HTMLRemoveTags(Value);
SetField(fieldActors, Value);
end;
// Media Label - Reference
LineNr := FindLine('<div class="dvd_subtitle">Référence</div>', Page, LineNr);
if LineNr > -1 then
begin
Value := Trim(Page.GetString(LineNr + 1));
HTMLRemoveTags(Value);
SetField(fieldMedia, Value);
end;
// Length
LineNr := FindLine('<img alt="Durée"', Page, LineNr);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 1);
BeginPos := Pos('>', Line) + 1;
EndPos := Pos(' min', Line);
Value := Copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldLength, Value);
end;
// Discs
LineNr := FindLine('<img alt="Nombre de disques"', Page, LineNr);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 1);
BeginPos := Pos('>', Line) + 1;
EndPos := Pos('</', Line);
Value := Copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldDisks, Value);
end;
// Bitrate
if MustImportBitrate then
begin
LineNr := FindLine('<img alt="Bitrate moyen"', Page, LineNr);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 1);
BeginPos := Pos('<td>', Line) + 4;
EndPos := Pos(' ', Line);
Value := Copy(Line, BeginPos, EndPos - BeginPos);
Value := StringReplace(Value, ',', '') + '0';
SetField(fieldVideoBitrate, Value);
end;
end;
// Media type
LineNr := FindLine('<img alt="Format DVD"', Page, LineNr);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 1);
BeginPos := Pos('>', Line) + 1;
EndPos := Pos('</', Line);
Value := Copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldMediaType, Value);
end;
// Comments
Line := Page.Text;
BeginPos := Pos('</span><br>', Line) + 12;
Delete(Line, 1, BeginPos);
EndPos := Pos('<br>', Line);
Value := Copy(Line, 1, EndPos - 1);
HTMLRemoveTags(Value);
Value := 'Suppléments:' + #13#10 + Trim(Value);
SetField(fieldComments, Value);
// Video format
LineNr := FindLine('title="Format vidéo"', Page, LineNr);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 2);
BeginPos := Pos('alt="', Line) + 17;
EndPos := Pos('" title=', Line);
Value := Copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldResolution, Value);
end;
// Zone
LineNr := FindLine('title="Zone(s) du DVD"', Page, LineNr);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr + 2);
BeginPos := Pos('alt="', Line) + 5;
EndPos := Pos('" title=', Line);
Value := 'DVD ' + Copy(Line, BeginPos, EndPos - BeginPos);
SetField(fieldVideoFormat, Value);
end;
// Standard
LineNr := FindLine('title="Standard vidéo du DVD"', Page, LineNr);
if LineNr > -1 then
begin
Line := StringReplace(Trim(Page.GetString(LineNr + 2)), #9, '');
HTMLRemoveTags(Line);
Value := Value + ' - Standard ' + Line;
SetField(fieldVideoFormat, Value);
end;
// Audio format
LineNr := FindLine('title="Spécifications audio"', Page, LineNr);
if LineNr > -1 then
begin
BeginPos := LineNr + 2;
LineNr := FindLine('</table></td></tr>', Page, LineNr);
if LineNr > -1 then
begin
EndPos := LineNr;
Value := '';
Line := 'DVD ';
for i := BeginPos to EndPos do
begin
BeginPos2 := Pos('<small>', Page.GetString(i));
EndPos2 := Pos('</small>', Page.GetString(i));
if ((BeginPos2 > 0) and (EndPos2 > 0)) then
begin
if not(Value = '') then
Value := Value + ' - ';
Value := Value + Copy(Page.GetString(i), BeginPos2 + 7, EndPos2 - (BeginPos2 + 7));
end;
BeginPos2 := Pos('alt="', Page.GetString(i));
EndPos2 := Pos('" title="', Page.GetString(i));
if ((BeginPos2 > 0) and (EndPos2 > 0)) then
begin
if not(Line = 'DVD ') then
Line := Line + ' - ';
Line := Line + Copy(Page.GetString(i), BeginPos2 + 5, EndPos2 - (BeginPos2 + 5));
end;
end;
SetField(fieldAudioFormat, Line);
SetField(fieldLanguages, Value);
end;
end;
// Sous-titres
LineNr := FindLine('title="Sous-titres disponibles"', Page, LineNr);
if LineNr > -1 then
begin
Line := StringReplace(Trim(Page.GetString(LineNr + 3)), #9, '');
HTMLRemoveTags(Line);
SetField(fieldSubtitles, Line);
end;
//
Page.Free;
end;
procedure AnalyzePage2(Address: string);
var
Page: TStringList;
LineNr: Integer;
Line: string;
BeginPos: Integer;
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
if pos('<TITLE>Recherche', Page.Text) = 0 then
AnalyzeMoviePage2(Page)
else
begin
PickTreeClear;
LineNr := FindLine('AlloCiné</A> : <b>Recherche</b>', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('dans les titres de films', Line);
if BeginPos > 0 then
begin
Delete(Line, 1, BeginPos);
PickTreeAdd('Films déjà sortis', '');
AddMoviesTitles(Line);
end;
BeginPos := pos('dans les films déjà sortis (de ou avec)', Line);
if BeginPos > 0 then
begin
Delete(Line, 1, BeginPos);
PickTreeAdd('Films déjà sortis (de ou avec)', '');
AddMoviesTitles(Line);
end;
BeginPos := pos('dans les prochaines sorties de films', Line);
if BeginPos > 0 then
begin
Delete(Line, 1, BeginPos);
PickTreeAdd('Prochaines sorties', '');
AddMoviesTitles(Line);
end;
BeginPos := pos('dans les prochaines sorties de films (de ou avec)', Line);
if BeginPos > 0 then
begin
Delete(Line, 1, BeginPos);
PickTreeAdd('Prochaines sorties (de ou avec)', '');
AddMoviesTitles(Line);
end;
Line := Page.GetString(LineNr);
BeginPos := pos('<LI><A HREF="rubrique.html?typerecherche=3&', Line);
if BeginPos > 0 then
begin
Delete(Line, 1, BeginPos + 12);
PickTreeMoreLink('http://www.allocine.fr/recherche/' + copy(Line, 1, pos('"', Line) - 1));
end;
if PickTreeExec(Address) then
AnalyzePage2(Address);
end;
end;
Page.Free;
end;
procedure AnalyzeMoviePage2(Page: TStringList);
var
Pageaff: TStringList;
Line, Value: string;
LineNr, IntValue: Integer;
BeginPos, EndPos: Integer;
begin
// Description
LineNr := FindLine('>Synopsis<', Page, LineNr);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
Value := '';
repeat
BeginPos := pos('"size2">', Line);
if BeginPos > 0 then
BeginPos := BeginPos + 8
else
BeginPos := 1;
EndPos := pos('</FONT></DIV>', Line);
if EndPos = 0 then
EndPos := pos('<br>', Line);
if EndPos = 0 then
EndPos := Length(Line) + 1;
if EndPos > 0 then
Value := Value + copy(Line, BeginPos, EndPos - BeginPos) + #13#10;
EndPos := pos('</FONT></DIV>', Line);
if EndPos = 0 then
begin
LineNr := LineNr + 1;
Line := Page.GetString(LineNr);
EndPos := Pos('<SCRIPT', Line);
end;
until EndPos > 0;
HTMLRemoveTags(Value);
SetField(fieldDescription, Value);
end;
// Picture
LineNr := FindLine('allocine.fr/acmedia/medias/nmedia', Page, 0);
if LineNr = -1 then
LineNr := FindLine('&big=1&page=1.html"><', Page, 0);
if LineNR > -1 then
begin
Line := Page.GetString(LineNr);
BeginPos := pos('><A HRef="', Line) + 10;
if BeginPos > 10 then
begin
EndPos := pos('">', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
end;
Pageaff := TStringList.Create;
Pageaff.Text := GetPage('http://www.allocine.fr' + Value);
LineNr := FindLine('<IMG border=0 src="http://img5.allocine.fr/acmedia/medias/', Pageaff, 0);
if LineNR > -1 then
begin
Line := Pageaff.GetString(LineNr);
BeginPos := pos('<IMG border=0 ', Line) + 19;
EndPos := pos('" Zalt=', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
GetPicture(Value, ExternalPictures);
end;
Pageaff.Free;
end;
end;
procedure AddMoviesTitles(var Line: string);
var
MovieTitle, MovieAddress: string;
StartPos, EndPos: Integer;
begin
repeat
StartPos := pos('<LI><A HREF="/film/fichefilm', Line);
if StartPos > 0 then
begin
Delete(Line, 1, StartPos + 12);
MovieAddress := copy(Line, 1, pos('"><FONT color=#003399>', Line) - 1);
StartPos := pos('#003399>', Line) + 8;
MovieTitle := copy(Line, StartPos, pos('</TD>', Line) - StartPos);
HTMLRemoveTags(MovieTitle);
PickTreeAdd(MovieTitle, 'http://www.allocine.fr' + MovieAddress);
end;
until (StartPos < 1) or ((pos('<LI><A HREF="/film/fichefilm', Line) > pos('<FONT class=size2 color=#AA0000>', Line)) and (pos('<FONT class=size2 color=#AA0000>', Line) > 0));
if (pos('Plus...',Line) > 0) and (pos('Plus...',Line) < pos('<FONT class=size4 color=#003399><B>',Line)) and (pos('Plus...',Line) < pos('<FONT class=size2 color=#AA0000><B>',Line)) then
begin
StartPos := pos('rubrique.html', Line);
EndPos := pos('Plus...',Line) - 16;
MovieAddress := copy(Line, StartPos, EndPos - StartPos);
PickTreeAdd('Plus... ', 'http://www.allocine.fr/recherche/' + MovieAddress);
end;
end;
begin
if CheckVersion(3,4,1) then
begin
MovieName := GetField(fieldTranslatedTitle);
if MovieName = '' then
MovieName := GetField(fieldOriginalTitle);
if Input('DVDFR.com Import', 'Entrez le titre du film :', MovieName) then
begin
AnalyzePage('http://www.dvdfr.com/search/search.php?multiname='+UrlEncode(MovieName));
AnalyzePage2('http://www.allocine.fr/recherche/default.html?motcle='+UrlEncode(MovieName));
DisplayResults;
end;
end else
ShowMessage('Ce script requiert la version 3.4.1 ou supérieure de Ant Movie Catalog.');
end.
Nico.