[FR] dvdanime.net (pour les amateurs de mangas)
Posted: 2003-01-13 19:22:23
Bonjour,
voici un petit script pour les amateurs de mangas avec le site
http://www.dvdanime.net/
voici un petit script pour les amateurs de mangas avec le site
http://www.dvdanime.net/
Code: Select all
// GETINFO SCRIPTING
// dvdanime.net import with picture
(***************************************************
* Movie importation script for: *
* dvdanime.net, http://www.dvdanime.net *
* *
* (c) 2002 Rincevent *
* *
* 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 dvdanime;
var
MovieName: 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;
function DelImg(line: string): string;
var
BeginPos, EndPos: Integer;
Line1: string;
begin
while (pos('<img src', line) > 0) do
begin
BeginPos := pos('<img src', line);
result := copy(line, 0, BeginPos);
result := DelFirstBlank(result);
Delete(line, 1, BeginPos-1);
EndPos := pos('</a>', line);
Delete(line, 1, EndPos-1);
line := DelFirstBlank(line);
line := result + line;
end;
result := line;
end;
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
MovieTitle: string;
Line: string;
BeginPos, EndPos: Integer;
begin
Line := GetPage(Address);
if Pos('<TITLE>DVDanime.net', Line) > 0 then
begin
PickTreeClear;
BeginPos := pos('name=titre>', Line);
while (BeginPos > 0) do
begin
//titre := Page.GetString(LineNr);
Delete(Line, 1, BeginPos + 10);
MovieTitle := copy(Line, pos(';', Line) + 1, pos('</TD>', Line) - 6);
HTMLRemoveTags(MovieTitle);
PickTreeAdd(MovieTitle, '');
AddMoviesTitles(Line);
BeginPos := pos('name=titre>', Line);
end;
// PickTreeMoreLink('http://www.allocine.fr/recherche/');
if PickTreeExec(Address) then
begin
Line := GetPage(Address);
SetField(fieldURL, Address);
AnalyzeMoviePage(Line);
end
end;
end;
procedure AddMoviesTitles(var Line: string);
var
MovieTitle, MovieAddress: string;
StartPos, EndPos: Integer;
begin
StartPos := pos('critiqueview.php?id_critique=', Line);
repeat
if StartPos > 0 then
begin
Delete(Line, 1, StartPos - 1);
MovieTitle := copy(Line, 1, pos('<TD align=center', Line));
MovieTitle := '<' + MovieTitle;
HTMLRemoveTags(MovieTitle);
HTMLDecode(MovieTitle);
MovieTitle :=StringReplace(MovieTitle, #09, '');
MovieTitle :=StringReplace(MovieTitle, #13#10 , '');
MovieAddress := copy(Line, 1, pos('"', Line) - 2);
Delete(Line, 1, pos('</TR>', Line));
PickTreeAdd(MovieTitle, 'http://www.dvdanime.net/' + MovieAddress);
end;
StartPos := pos('critiqueview.php?id_critique', Line);
EndPos := pos('name=titre>', Line);
until (StartPos < 1) or ((StartPos > EndPos) and (EndPos > 0));
end;
procedure AnalyzeMoviePage(PageContents: string);
var
Line, Value: string;
LineNr, BeginPos, EndPos: Integer;
Page: TStringList;
begin
// Picture
BeginPos := Pos('images_critiques', PageContents);
delete(PageContents,1,BeginPos - 1);
EndPos := Pos('.jpg', PageContents);
Value := Copy(PageContents, 0, EndPos + 3);
GetPicture('http://www.dvdanime.net/' + Value, False);
//SetField(fieldComments, 'http://www.dvdanime.net/' + Value);
//Bloc Titre
BeginPos := Pos('<!-- //Bloc titre -->', PageContents);
delete(PageContents,1,BeginPos-1);
// Titles traduit
EndPos := Pos('<IMG SRC=images/pix.gif HEIGHT=7>', PageContents);
Value := copy(PageContents, 0, EndPos);
Value :=StringReplace(Value, '<center>', ' ');
HTMLRemoveTags(Value);
Value :=StringReplace(Value, #09, '');
Value :=StringReplace(Value, #13#10 , '');
SetField(fieldTranslatedTitle, Value);
//Realisateur
BeginPos := Pos('Réalisateurs', PageContents);
if (BeginPos > 0) then
begin
delete(PageContents,1,BeginPos + 13);
EndPos := Pos('<BR>', PageContents);
Value := copy(PageContents, 0, EndPos);
HTMLRemoveTags(Value);
Value := DelFirstBlank(Value);
SetField(fieldDirector, Value);
end;
// Fiche de l'animé
BeginPos := Pos('Fiche de l', PageContents);
delete(PageContents,1,BeginPos);
// Country
BeginPos := Pos('Origine :', PageContents);
delete(PageContents,1,BeginPos+8);
EndPos := Pos('<BR>', PageContents);
Value := copy(PageContents, 0, EndPos);
Value :=StringReplace(Value, ' ' , '');
HTMLRemoveTags(Value);
SetField(fieldCountry, Value);
// Titre original
BeginPos := Pos('Titre original :', PageContents);
delete(PageContents,1,BeginPos+15);
EndPos := Pos('<BR>', PageContents);
Value := copy(PageContents, 0, EndPos);
//Value :=StringReplace(Value, ' ' , '');
HTMLRemoveTags(Value);
Value := DelFirstBlank(Value);
if (Value = '(idem vf)') then
Value := GetField(fieldTranslatedTitle);
SetField(fieldOriginalTitle, Value);
// Category
BeginPos := Pos('Type :', PageContents);
delete(PageContents,1,BeginPos+5);
EndPos := Pos('<BR>', PageContents);
Value := copy(PageContents, 0, EndPos);
Value :=StringReplace(Value, ' ' , '');
HTMLRemoveTags(Value);
SetField(fieldCategory, Value);
// Length
BeginPos := Pos('Durée :', PageContents);
delete(PageContents,1,BeginPos+6);
EndPos := Pos('minutes', PageContents);
Value := copy(PageContents, 0, EndPos -1);
Value :=StringReplace(Value, ' ' , '');
HTMLRemoveTags(Value);
SetField(fieldLength, Value);
// Year
BeginPos := Pos('Année de prod. :', PageContents);
delete(PageContents,1,BeginPos+15);
EndPos := Pos('<BR>', PageContents);
Value := copy(PageContents, 0, EndPos);
//Value :=StringReplace(Value, ' ' , '');
HTMLRemoveTags(Value);
SetField(fieldYear, Value);
// Producer
//BeginPos := Pos('Produit par :', PageContents);
BeginPos := Pos('Editeur :', PageContents);
delete(PageContents,1,BeginPos+8);
EndPos := Pos('<BR>', PageContents);
Value := copy(PageContents, 0, EndPos);
//Value :=StringReplace(Value, ' ' , '');
HTMLRemoveTags(Value);
Value := DelFirstBlank(Value);
SetField(fieldProducer, Value);
//NAME=scenario>Scénario
BeginPos := Pos('NAME=scenario>Scénario', PageContents);
if (BeginPos > 0) then
begin
delete(PageContents,1,BeginPos + 21);
EndPos := Pos('<TD VALIGN=MIDDLE VALIGN=TOP ALIGN=CENTER BACKGROUND=images/critique/critiques_note', PageContents);
Value := copy(PageContents, 0, EndPos-1);
Value :=DelImg(Value);
HTMLRemoveTags(Value);
Value :=StringReplace(Value, '’' , #39);
Value :=StringReplace(Value, #09 , '');
Value :=StringReplace(Value, #13#10#13#10 , #13#10);
Value :=DelFirstBlank(Value);
SetField(fieldDescription, Value);
end;
DisplayResults;
end;
begin
if CheckVersion(3,4,1) then
begin
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then
MovieName := GetField(fieldTranslatedTitle);
if Input('dvdanime.net Import', 'Entrez le titre du film :', MovieName) then
begin
AnalyzePage('http://www.dvdanime.net/liste_dvd.php?mode=liste&recherche='+UrlEncode(MovieName));
end;
end else
ShowMessage('Ce script requiert la version 3.4.1 ou supérieure de Ant Movie Catalog.');
end.