(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=ScorEpioN - modifié par Raoul_Volfoni, Xenesys
Title=Animeka.com
Description=Recherche d'Animes, staff, synopsis, critiques, épisodes et images animeka ou animenewsnetwork
Site=http://www.animeka.com
Language=FR
Version=43 du 20/02/2010
Requires=3.5.1
Comments=Ce script nécessite le fichier ScorEpioNCommonScript.pas|.==.| : ' ( ( ( ( /\ | "==()))))): © ScorEpioN ©| ( ( ( ( \_/
License=This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
GetInfo=1
[Options]
Choix Image=1|0|0=Image Animeka|1=Image AnimeNewsNetwork (avec choix)|2=Pas d'image
Staff=0|0|0=Liste du Staff dans le champs Commentaires|1=Liste du Staff dans le champs Acteurs|2=Pas de Staff
Type de Lancement=0|0|0=Demande le titre avant de lancer le script|1=Ne demande pas le titre avant de lancer le script|2=Cherche le meilleur résultat sans confirmation|3=Lancement automatique sur l'adresse web
Format du Titre=4|3|0=Titre en minuscule|1=Titre en majuscule|2=Première lettre du titre en majuscule|3=Première lettre de chaque mot du titre en majuscule|4=Ne rien faire
Titre en double=0|0|0=Garde les titres originaux et traduits même identiques|1=Garde les titres originaux si identiques|2=Garde les titres traduits si identiques
Recherche sur le titre=1|0|0=Traduit|1=Original
Fichier de log=1|1|0=Oui|1=Non
Plus de dix huit ans=0|1|0=Oui - Accès aux fiches +18 du site|1=Non - Accès restreint aux fiches -18 du site
Détenteur(s) d'une Licence=0|0|0=Oui - Liste des ayants droits (sociétés) avec les éditions et leur catégorie (BRD/DVD/TV/...)|1=Non - Pas de liste
Fansub=0|0|0=Oui - Liste des équipes de fansub + nb d'épisodes sortis|1=Non - Pas d'information sur le fansub
Liste des épisodes=0|0|0=Oui - Liste des épisodes avec résumé|1=Oui - Liste des épisodes sans résumé|2=Non - Pas de liste
***************************************************)
program ANIMEKA_SEARCH;
uses
ScorEpioNCommonScript;
const
VersionScript = '37 du 17/07/2006';
NomScript = 'ANIMEKA';
urlDomain = 'animeka.com';
urlBase = 'http://www.animeka.com/';
urlSearch = urlBase+'search/index.html?req=';
urlSubmit = '&zone_series=1&go_search=1&cat=search';
sleepAuto = 5000;
sleepManu = 500;
var
MovieName, NomFilm, la_liste, premiere_pageEpisode, Reponse, TypeExec, AnimeName, adresseunique: string;
premiereExecution, i, TimeSleep, compteur : Integer;
listeResultat: TStringList;
test : Boolean;
//------------------------------------------------------------------------------
// ANALYSE DE LA PAGE DE RECHERCHES
//------------------------------------------------------------------------------
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr: Integer;
Line,page_film,titre_film, realisateur_film, annee_film : string;
BeginPos, EndPos, compteur : Integer;
begin
// Vide la liste des films
PickTreeClear;
listeResultat := TStringList.Create;
// Pause pour eviter les time out
sleep(TimeSleep);
// Charge la page
If (GetOption('Plus de dix huit ans') = 0) then
Line := GetPage3(Address, '', 'restrict=false') // si l'option plus dix huit ans est validée alors on a accès au contenu +18
else
Line := GetPage(Address); // sinon non (valeur par défaut)
// Teste s'il y a des films trouvés
BeginPos := Pos('Aucun résultat', Line);
if BeginPos <> 0 then
begin
if (GetOption('Type de Lancement') = 0) then
begin
titre_film := MovieName;
titre_film := StringReplace(titre_film, RC, '');
titre_film := StringReplace(titre_film, ' ', '');
titre_film := Trim(titre_film);
titre_film := AnsiLowerCase(titre_film);
titre_film := AnsiUpFirstLetter(titre_film);
showmessage('Aucun Anime trouvé pour : ' + titre_film);
exit;
end else
begin
SetField(fieldChecked, '');
exit;
end;
end;
// Teste si on a été redirigé vers la fiche de l'anime
BeginPos := Pos('',Line);
page_film := 'http://www.animeka.com' + Copy(Line, 1, EndPos-2 );
if (Pos('fansub',page_film) = 0) then
begin
AnalysePageFilm(page_film);
exit;
end else
begin
AnalyzePageFansub(page_film);
exit;
end;
end;
// Introduction résultats
titre_film := MovieName;
titre_film := StringReplace(titre_film, RC, '');
titre_film := StringReplace(titre_film, ' ', '');
titre_film := Trim(titre_film);
titre_film := AnsiLowerCase(titre_film);
titre_film := AnsiUpFirstLetter(titre_film);
PickTreeAdd('Animes trouvés pour ' + titre_film + ' :', '');
// Compte les résultats
compteur := 0;
repeat
// Recherche du lien de la page du film
BeginPos := Pos('',Line);
page_film := 'http://www.animeka.com' + Copy(Line, 1, EndPos-1 );
// Recherche du nom du film
BeginPos := Pos('">',Line);
Delete(Line, 1, BeginPos+1);
EndPos := Pos('',Line)-1;
titre_film := Copy(Line, 1, EndPos )+ ' (' + TextBetween(Line, 'format : ', '
') + ')';
HTMLdecode(titre_film);
HTMLremovetags(titre_film);
titre_film := StringReplace(titre_film, RC, '');
titre_film := StringReplace(titre_film, ' ', '');
titre_film := Trim(titre_film);
titre_film := AnsiLowerCase(titre_film);
titre_film := AnsiUpFirstLetter(titre_film);
// Ajoute les films
PickTreeAdd(titre_film , page_film);
// Pour le mode batch le titre doit être "propre"
listeResultat.Add(titre_film+'|'+page_film);
compteur := compteur+1;
// Recherche le lien de la page du film
BeginPos := Pos('/animes/detail/',Line);
until BeginPos = 0;
if compteur = 1 then
begin
compteur := 0;
AnalysePageFilm(page_film);
exit;
end;
if (GetOption('Type de Lancement') = 0) or (GetOption('Type de Lancement') = 1) then
begin
begin
if PickTreeExec(Address)=true then
begin
AnalysePageFilm(Address);
end;
end;
end else
begin
if (GetOption('Type de Lancement') = 2) then
begin
Address := trouveResultat(MovieName);
if Address <> '' then
AnalysePageFilm(Address);
end ;
end;
end;
//------------------------------------------------------------------------------
// TROUVE LE BON RESULTAT
//------------------------------------------------------------------------------
function trouveResultat(title : String) : String;
var
oK, couple, titre, adresse : String;
begin
for i:=0 to listeResultat.Count-1 do
begin
couple := listeResultat.GetString(i);
titre := copy(couple,0,pos('|',couple)-1);
adresse := copy(couple,pos('|',couple)+1,length(couple));
oK := compareTitle(title,titre);
if oK = 'OK' then
begin
result := adresse;
exit;
end;
end;
if oK = 'KO' then
result := '';
listeResultat.Free;
end;
//------------------------------------------------------------------------------
// IMPORTE L'IMAGE ANIMEKA
//------------------------------------------------------------------------------
procedure importImageAnimeka(Line: string);
var
BeginPos, EndPos : Integer;
begin
BeginPos := Pos('
0) then
delete(title, 1, pos(', ',title)+1);
if (pos('(',title) > 0) then
delete(title, pos('(',title), length(title));
if (pos(':',title) > 0) then
delete(title, pos(':',title), length(title));
result := trim(title);
end;
//------------------------------------------------------------------------------
// ANALYSE DE LA PAGE FANSUB
//------------------------------------------------------------------------------
procedure AnalyzePageFansub(Address: string);
var
Line ,page_film : string;
BeginPos, EndPos : Integer;
begin
// Pause pour eviter les time out
sleep(TimeSleep);
Line := GetPage(Address);
BeginPos := Pos('"animestitle"', Line);
Delete(Line, 1, BeginPos);
BeginPos := Pos('a href="', Line);
Delete(Line, 1, BeginPos+7);
EndPos := Pos('">',Line);
page_film := 'http://www.animeka.com' + Copy(Line, 1, EndPos-1 );
AnalysePageFilm(page_film);
end;
//------------------------------------------------------------------------------
// ANALYSE DE LA PAGE DU FILM
//------------------------------------------------------------------------------
procedure AnalysePageFilm(Address: string);
var
Line, Line2, page_film,titre_film, titre_original, categorie_film, fansub, realisateur_film, studio_film, annee_film, Liste_editeurs, editeur_html, type_editeur, Distributeur_DVD, Distributeur_TV, Editeur_DVD, Editeur_VHS, Distributeur_VHS, Distributeur_Cine, Distributeur_Blueray, Editeur_Blueray, Distributeur_Web: string;
critique, noteRedaction, pays_film, url_film, saisons, duree, duree_film, nb_episode, duree_totale, episode_anime, page_episodes, page_staff, liste_episodes, acteurs_film, liste_acteurs, description_film, reference_film,public_film,video_film,audio_film,fichier_image,aucun,dur_epis:string;
BeginPos, EndPos, i: Integer;
begin
// Pour le mode Batch
if (GetOption('Fichier de log') = 0) then
beforeUpdate();
// Pause pour eviter les time out
sleep(TimeSleep);
// charge la page
Line := GetPage(Address);
url_film := Address;
// Recherche du nom du film
BeginPos := Pos('"animestitle"', Line);
Delete(Line, 1, BeginPos+39);
EndPos := Pos('',Line);
titre_film := Copy(Line, 1, EndPos-1 );
HTMLdecode(titre_film);
HTMLremovetags(titre_film);
titre_film := StringReplace(titre_film, RC, '');
titre_film := StringReplace(titre_film, ' ', '');
titre_film := Trim(titre_film);
if GetOption('Format du Titre') <> 4 then
begin
titre_film := AnsiLowerCase(titre_film);
titre_film := AnsiMixedCase(titre_film, ' -');
end;
titre_film := nettoieTitre(titre_film);
// Chargement image animeka
if CanSetPicture then
begin
if (GetOption('Choix Image') = 0) then
begin
importImageAnimeka(Line);
end;
end;
// Pour retrouver l'image animeka
fichier_image := Line;
// Recherche du titre original
BeginPos := Pos('
', '');
description_film := deleteBalise(description_film);
description_film := StringReplace(description_film, '’','''');
description_film := StringReplace(description_film, '…','...');
HTMLdecode(description_film);
end;
// Recherche des critiques
BeginPos := Pos('Critiques', Line);
Delete(Line, 1, BeginPos);
if Pos('Non disponible',Line) > 0 then
critique := ''
else
begin
BeginPos := Pos('
', Line);
Delete(Line, 1, BeginPos+21);
EndPos := Pos(' | ',Line);
critique := 'Critiques : ';
critique := critique + Copy(Line, 1, EndPos-1 );
critique := StringReplace(critique, RC, ' ');
critique := StringReplace(critique, '
', ' ');
critique := StringReplace(critique, '
', '');
critique := StringReplace(critique, '', '');
critique := StringReplace(critique, '
', '');
critique := StringReplace(critique, '', '');
critique := StringReplace(critique, ' ', ' ');
critique := StringReplace(critique, '’','''');
critique := StringReplace(critique, '…','...');
critique := StringReplace(critique, 'Critiques :
', 'Critiques : '+RC);
critique := StringReplace(critique, '', RCN(2)+'');
critique := StringReplace(critique, '-', RC+'');
critique := deleteBalise(critique);
HTMLdecode(critique);
description_film := description_film + RCN(2) + critique;
end;
// Recherche de la note de la rédaction
{BeginPos := Pos('Note de la rédaction', Line);
Delete(Line, 1, BeginPos);
if BeginPos = 0 then
begin
noteRedaction := '';
end else
if Pos('>Nous vous',Line) > 0 then
noteRedaction := ''
else
begin
BeginPos := Pos('', Line);
Delete(Line, 1, BeginPos+21);
EndPos := Pos(' | ',Line);
noteRedaction := 'Note de la rédaction : '+RC;
noteRedaction := noteRedaction + Copy(Line, 1, EndPos-1 );
noteRedaction := StringReplace(noteRedaction, '
'+RCN(2)+'
', '');
noteRedaction := StringReplace(noteRedaction, '
', ' ');
noteRedaction := StringReplace(noteRedaction, '
', '');
noteRedaction := StringReplace(noteRedaction, '', '');
noteRedaction := StringReplace(noteRedaction, '
', '');
noteRedaction := StringReplace(noteRedaction, '', '');
noteRedaction := StringReplace(noteRedaction, ' ', ' ');
noteRedaction := deleteBalise(noteRedaction);
noteRedaction := StringReplace(noteRedaction, '’','''');
noteRedaction := StringReplace(noteRedaction, '…','...');
HTMLdecode(noteRedaction);
noteRedaction := StringReplace(noteRedaction, RC+'Nous vous invitons à discuter de l''animé sur le forum !', '');
description_film := description_film + RCN(2) + noteRedaction;
if CanSetField(fieldRating) then
MonSetField(fieldRating, moyenneNote(noteRedaction));
end;}
// Recherche des teams de fansub et les épisodes réalisés
if (GetOption('Fansub')= 0) then
begin
BeginPos := Pos('Fansubbé par', Line);
Delete(Line, 1, BeginPos-1);
if BeginPos = 0 then
begin
aucun := 'Pas de fansub';
end else
begin
BeginPos := Pos('Fansubbé par :', Line);
Delete(Line, 1, BeginPos+18);
EndPos := Pos('Plus de détails',Line);
fansub := 'Fansubbé par : ';
fansub := fansub + Copy(Line, 1, EndPos-1 );
fansub := StringReplace(fansub, '
', ' ');
fansub := StringReplace(fansub, '
', '');
fansub := StringReplace(fansub, '', '');
fansub := StringReplace(fansub, '
', '');
fansub := StringReplace(fansub, '', '');
fansub := StringReplace(fansub, ' ', ' ');
fansub := StringReplace(fansub, '’','''');
fansub := StringReplace(fansub, '…','...');
fansub := Stringreplace(fansub, '[', '- [');
fansub := deleteBalise(fansub);
HTMLdecode(fansub);
fansub := fansub;
end;
end;
// Recherche des Editeurs
if (GetOption('Détenteur(s) d''une Licence')= 0) then
begin
BeginPos := Pos('Licencié par', Line);
Delete(Line, 1, BeginPos-1);
if BeginPos = 0 then
begin
aucun := 'Pas d''éditeurs';
end else
begin
BeginPos := Pos('Licencié par :', Line);
Delete(Line, 1, BeginPos+18);
EndPos := Pos('',Line);
Line2 := Copy(Line, 1, EndPos-1 );
repeat
// Cherche le nom de l'éditeur version HTML
BeginPos := Pos('/animes/editeur/',Line2);
Delete(Line2, 1, BeginPos+15);
EndPos := Pos('">',Line2);
editeur_html := Copy(Line2, 1, EndPos-1 );
// Cherche le type de l'éditeur
BeginPos := Pos('
',Line2);
Delete(Line2, 1, BeginPos+3);
EndPos := Pos('',Line2)-1;
type_editeur := Copy(Line2, 1, EndPos );
type_editeur := StringReplace(type_editeur, #10, '');
type_editeur := StringReplace(type_editeur, #13, '');
// Ajoute à la liste des éditeurs catégorie par catégorie et se recale à la ligne suivante
if Pos('Éditeur BlueRay',type_editeur) > 0 then
begin
if Editeur_Blueray = '' then
Editeur_Blueray := editeur_html
else
Editeur_Blueray := Editeur_Blueray + ', ' + editeur_html;
end;
if Pos('Distributeur BlueRay',type_editeur) > 0 then
begin
if Distributeur_Blueray = '' then
Distributeur_Blueray := editeur_html
else
Distributeur_Blueray := Distributeur_Blueray + ', ' + editeur_html;
end;
if Pos('Distributeur DVD',type_editeur) > 0 then
begin
if Distributeur_DVD = '' then
Distributeur_DVD := editeur_html
else
Distributeur_DVD := Distributeur_DVD + ', ' + editeur_html;
end;
if Pos('Éditeur DVD',type_editeur) > 0 then
begin
if Editeur_DVD = '' then
Editeur_DVD := editeur_html
else
Editeur_DVD := Editeur_DVD + ', ' + editeur_html;
end;
if Pos('Distributeur TV',type_editeur) > 0 then
begin
if Distributeur_TV = '' then
Distributeur_TV := editeur_html
else
Distributeur_TV := Distributeur_TV + ', ' + editeur_html;
end;
if Pos('Éditeur VHS',type_editeur) > 0 then
begin
if Editeur_VHS = '' then
Editeur_VHS := editeur_html
else
Editeur_VHS := Editeur_VHS + ', ' + editeur_html;
end;
if Pos('Distributeur VHS',type_editeur) > 0 then
begin
if Distributeur_VHS = '' then
Distributeur_VHS := editeur_html
else
Distributeur_VHS := Distributeur_VHS + ', ' + editeur_html;
end;
if Pos('Distributeur Ciné',type_editeur) > 0 then
begin
if Distributeur_Cine = '' then
Distributeur_Cine := editeur_html
else
Distributeur_Cine := Distributeur_Cine + ', ' + editeur_html;
end;
if Pos('Distributeur Web',type_editeur) > 0 then
begin
if Distributeur_Web = '' then
Distributeur_Web := editeur_html
else
Distributeur_Web := Distributeur_Web + ', ' + editeur_html;
end;
BeginPos := Pos('
'' then
Liste_editeurs := Liste_editeurs + RC + '- Éditeur Blueray : ' + Editeur_Blueray;
if Distributeur_Blueray <> '' then
Liste_editeurs := Liste_editeurs + RC + '- Distributeur Blueray : ' + Distributeur_Blueray;
if Editeur_DVD <> '' then
Liste_editeurs := Liste_editeurs + RC + '- Éditeur DVD : ' + Editeur_DVD;
if Distributeur_DVD <> '' then
Liste_editeurs := Liste_editeurs + RC + '- Distributeur DVD : ' + Distributeur_DVD;
if Distributeur_TV <> '' then
Liste_editeurs := Liste_editeurs + RC + '- Distributeur TV : ' + Distributeur_TV;
if Distributeur_Cine <> '' then
Liste_editeurs := Liste_editeurs + RC + '- Distributeur Ciné : ' + Distributeur_Cine;
if Editeur_VHS <> '' then
Liste_editeurs := Liste_editeurs + RC + '- Éditeur VHS : ' + Editeur_VHS;
if Distributeur_VHS <> '' then
Liste_editeurs := Liste_editeurs + RC + '- Distributeur VHS : ' + Distributeur_VHS;
if Distributeur_Web <> '' then
Liste_editeurs := Liste_editeurs + RC + '- Distributeur Web : ' + Distributeur_Web;
// Transforme les noms "html" des éditeurs en version compréhensible
Liste_editeurs := TransformEditeur(Liste_editeurs);
Liste_editeurs := 'Licencié par :' + Liste_editeurs + RCN(2);
end;
end;
// Recherche des autres saisons
BeginPos := Pos('Voir aussi', Line);
Delete(Line, 1, BeginPos-1);
if BeginPos = 0 then
begin
aucun := ''
end else
begin
BeginPos := Pos('Voir aussi', Line);
Delete(Line, 1, BeginPos+14);
EndPos := Pos('
| ',Line);
saisons := Copy(Line, 1, EndPos-1 );
saisons := StringReplace(saisons, '
', RC+'• ');
saisons := deleteBalise(saisons);
HTMLdecode(saisons);
saisons := 'A voir aussi :'+RC+'• '+saisons +RCN(2);
end;
// Recherche du staff
BeginPos := Pos('/animes/staff/', Line);
Delete(Line, 1, BeginPos-1);
if BeginPos = 0 then
begin
liste_acteurs := 'Pas de staff pour le moment';
end else
begin
EndPos := Pos('" class',Line);
page_staff := 'http://www.animeka.com'+Copy(Line, 1, EndPos-1 );
sleep(TimeSleep);
Line2 := GetPage(page_staff);
BeginPos := Pos(' >Staff de', Line2);
Delete(Line2, 1, BeginPos);
if BeginPos = 0 then
begin
liste_acteurs := 'Pas de staff pour le moment';
end else
begin
BeginPos := Pos('
',Line2);
liste_acteurs := '';
liste_acteurs := liste_acteurs + Copy(Line2, 1, EndPos-1 );
liste_acteurs := StringReplace(liste_acteurs, RC, ' ');
liste_acteurs := StringReplace(liste_acteurs, '- ', ' (');
liste_acteurs := StringReplace(liste_acteurs, ' | ', '),');
liste_acteurs := StringReplace(liste_acteurs, '
', ' ');
liste_acteurs := StringReplace(liste_acteurs, '
', '');
liste_acteurs := StringReplace(liste_acteurs, '', '');
liste_acteurs := StringReplace(liste_acteurs, '
', '');
liste_acteurs := StringReplace(liste_acteurs, '', '');
liste_acteurs := StringReplace(liste_acteurs, ' ', ' ');
liste_acteurs := StringReplace(liste_acteurs, '’','''');
liste_acteurs := StringReplace(liste_acteurs, '…','...');
liste_acteurs := deleteBalise(liste_acteurs);
liste_acteurs := StringReplace(liste_acteurs, '),',')'+RC);
HTMLdecode(liste_acteurs);
liste_acteurs := 'Staff :'+RC+' '+liste_acteurs;
end;
end;
// Recherche des épisodes
if (GetOption('Liste des épisodes')= 0) or (GetOption('Liste des épisodes')= 1) then
begin
BeginPos := Pos('/animes/epis/', Line);
Delete(Line, 1, BeginPos-1);
if BeginPos = 0 then
begin
aucun := 'Pas de listing d''épisodes pour le moment';
end else
begin
EndPos := Pos('" class',Line);
page_episodes := 'http://www.animeka.com'+Copy(Line, 1, EndPos-1 );
premiere_pageEpisode := page_episodes;
liste_episodes := 'Liste des épisodes :'+RC;
la_liste := '';
TrouveEpisode(page_episodes);
liste_episodes := liste_episodes + la_liste;
end;
end;
// Charge les résultats dans la fenêtre
if CanSetField(fieldTranslatedTitle) then
SetField( fieldTranslatedTitle,formatTitre(articleDebutTitre2(titre_film,' (',')'),GetOption('Format du Titre')));
if CanSetField(fieldOriginalTitle) then
SetField( fieldOriginalTitle,formatTitre(titre_original,GetOption('Format du Titre')));
if titre_original = '' then
begin
if CanSetField(fieldOriginalTitle) then
SetField( fieldOriginalTitle,formatTitre(articleDebutTitre2(titre_film,'(',')'),GetOption('Format du Titre')));
end;
if CanSetField(fieldURL) then
SetField( fieldURL,url_film);
if CanSetField(fieldCategory) then
SetField( fieldCategory,categorie_film);
if CanSetField(fieldDirector) then
SetField( fieldDirector,realisateur_film);
if CanSetField(fieldYear) then
SetField( fieldYear,annee_film);
if CanSetField(fieldCountry) then
SetField( fieldCountry,pays_film);
if CanSetField(fieldActors) then
SetField( fieldActors,duree_film);
if CanSetField(fieldActors) and (GetOption('Staff') = 1) then
SetField( fieldActors,duree_film+RCN(2)+liste_acteurs);
if CanSetField(fieldDescription) then
SetField( fieldDescription,description_film);
if CanSetField(fieldProducer) then
SetField( fieldProducer,studio_film);
if CanSetField(fieldComments) and (GetOption('Staff') = 0) and (liste_acteurs <> '') then
SetField( fieldComments, saisons + fansub + Liste_editeurs + liste_acteurs + RC + liste_episodes )
else if CanSetField(fieldComments) and ((GetOption('Staff') = 2) or (GetOption('Staff') = 1)) then
SetField( fieldComments, saisons + fansub + Liste_editeurs + liste_episodes);
// Chargement de l'image AnimeNewsNetwork ou Animeka
if CanSetPicture then
begin
if (GetOption('Choix Image') = 1) then
begin
AnimeName := GetField(fieldOriginalTitle);
AnimeName := cleanTitle(DelFirstBlank(AnimeName));
AnalyzePage2('http://www.animenewsnetwork.com/encyclopedia/search.php?searchbox='+UrlEncode(AnimeName));
if test = False then
begin
if (ShowConfirmation('Voulez vous récupérer l''image Animeka ?') = True) then
importImageAnimeka(fichier_image)
else
exit;
end;
end;
end;
// Pour le mode Batch
if (GetOption('Fichier de log') = 0) then
afterUpdate();
// Affichage des titres si original et traduit identique
titreDouble(GetOption('Titre en double'));
end;
//------------------------------------------------------------------------------
// FONCTION MOYENNE SUR DIX
//------------------------------------------------------------------------------
function moyenneNote(Note : String) : String;
var
lesNotes : TStringList;
laNote, NoteI : String;
Position, i : Integer;
begin
lesNotes := TStringList.Create; // création de la liste
if pos('/10', Note) <> 0 then // s'il y a une note
begin
Note := StringReplace(Note, ',','.');
Position := pos('/10', Note);
repeat
if (copy(Note,Position-2,1) = '.') then
laNote := copy(Note,Position-4,4) // si note avec décimale
else
laNote := copy(Note,Position-1,1)+'.0'; // si note sans décimale
laNote := StringReplace(laNote, ',','.'); // au cas où le séparateur est une virgule
lesNotes.Add(laNote); // la note est ajoutée à la liste des notes
delete(Note, pos('/10', Note), length('/10'));
Position := pos('/10', Note);
until (pos('/10', Note) = 0);
if lesNotes.Count <> 1 then // si plus d'une seule note
begin
for i:=0 to lesNotes.Count-1 do
begin
NoteI := lesNotes.GetString(i);
if i = 0 then
Note := NoteI // première boucle
else
Note := sommeNote(NoteI,Note); // somme des notes
end;
Note := FloatToStr(StrToFloat(Note)/lesNotes.Count);// calcul de la moyenne
end else
Note := laNote; // si une seule note
result := Note;
end else
result := Note; // si pas note
lesNotes.Free; // suppression de la liste
end;
function sommeNote(NoteA, NoteB : string) : String; // calcul la somme des deux notes
var
unite1, decimale1, unite2, decimale2 : Integer;
begin
unite1 := uniteValue(NoteA);
decimale1 := decimaleValue(NoteA);
unite2 := uniteValue(NoteB);
decimale2 := decimaleValue(NoteB);
unite1 := unite1+unite2; // Somme des deux moyennes
decimale1 := decimale2+decimale1;
if decimale1 = 10 then
begin
decimale1 := 0;
unite1 := unite1+1;
end else if decimale1 > 10 then
begin
decimale1 := decimale1-10;
unite1 := unite1+1;
end;
result := IntToStr(unite1)+'.'+IntToStr(decimale1);
end;
function uniteValue(Note : string) : Integer; // retourne la valeur des chiffres avant la virgule
var
unite : Integer;
begin
unite := 0;
if pos('.',Note) <> 0 then
Note := copy(Note,1,pos('.',Note)-1);
unite := StrToInt(Note,0);
result := unite;
end;
function decimaleValue(Note : string) : Integer; // retourne la valeur des chiffres après la virgule
var
decimale : Integer;
begin
decimale := 0;
if pos('.',Note) <> 0 then
begin
Note := copy(Note,pos('.',Note)+1,length(Note));
decimale := StrToInt(Note,0);
end;
result := decimale;
end;
//------------------------------------------------------------------------------
// ANALYSE DE LA PAGE DES EPISODES
//------------------------------------------------------------------------------
procedure TrouveEpisode(page_episodes: string);
var
Line, episode_anime, liste_episodes, aucun, resume, titre_episode:string;
BeginPos, EndPos, i: Integer;
begin
// pour eviter les time-out
sleep(TimeSleep);
// charge la page
Line := GetPage(page_episodes);
// compteur
i := 0;
// liste les épisodes
repeat
i := i+1;
BeginPos := Pos('
', Line);
Delete(Line, 1, BeginPos+49);
EndPos := Pos(' | ',Line);
if BeginPos=0 then
aucun := '<'
else
aucun := Copy(Line, 1, 1 );
// pour n'avoir que les épisodes
if aucun = '<' then
begin
exit;
end else
begin
// Numéro et titre épisode
titre_episode := Copy(Line, 1, EndPos-1 );
titre_episode := deleteKanji(titre_episode);
titre_episode := StringReplace(titre_episode, RC,'');
la_liste := la_liste + titre_episode + RC;
// Pour le résumé
if (GetOption('Liste des épisodes')= 0) then
begin
BeginPos := Pos('
| ', Line);
Delete(Line, 1, BeginPos+62);
EndPos := Pos(' |
',Line);
resume := '';
resume := Copy(Line, 1, EndPos-1 );
HTMLremovetags(resume);
resume := StringReplace(resume, '’','''');
resume := StringReplace(resume, '…','...');
resume := StringReplace(resume, RC,' ');
if resume <> '' then
begin
la_liste := la_liste + resume + RCN(2);
end;
end;
end;
until i = 25;
// Si 25 épisodes et + alors page suivante
if i = 25 then
begin
BeginPos := Pos('
', Line);
Delete(Line, 1, BeginPos+49);
EndPos := Pos(' | ',Line);
aucun := Copy(Line, 1, 1 );
// Si il y a juste 25 épisodes
if aucun = '<' then
begin
exit;
end else
begin
// Numéro et titre épisode
titre_episode := Copy(Line, 1, EndPos-1 );
titre_episode := deleteKanji(titre_episode);
titre_episode := StringReplace(titre_episode, RC,'');
la_liste := la_liste + titre_episode + RC;
// Pour le résumé
if (GetOption('Liste des épisodes')= 0) then
begin
BeginPos := Pos('
| ', Line);
Delete(Line, 1, BeginPos+62);
EndPos := Pos(' |
',Line);
resume := Copy(Line, 1, EndPos-1 );
HTMLremovetags(resume);
resume := StringReplace(resume, '’','''');
resume := StringReplace(resume, '…','...');
resume := StringReplace(resume, RC,' ');
if resume <> '' then
begin
la_liste := la_liste + resume + RCN(2);
end;
end;
// Cherche la page suivante
BeginPos := Pos('Précédent', Line);
Delete(Line, 1, BeginPos+9);
BeginPos := Pos('/animes/epis/', Line);
if BeginPos <> 0 then
begin
Delete(Line, 1, BeginPos-1);
EndPos := Pos('">',Line);
page_episodes := 'http://www.animeka.com'+Copy(Line, 1, EndPos-1 );
if page_episodes <> premiere_pageEpisode then
begin
TrouveEpisode(page_episodes);
end;
end;
end;
end;
end;
//------------------------------------------------------------------------------
// MEILLEUR AFFICHAGE DU NOMBRE D'EPISODES, OAV...
//------------------------------------------------------------------------------
function bestView(la_ligne : String; la_duree : String) : string;
begin
la_ligne := StringReplace(la_ligne, 'DURÉE :','Format :');
la_ligne := StringReplace(la_ligne, 'EPS','épisodes');
la_ligne := StringReplace(la_ligne, 'OAV','oav');
la_ligne := StringReplace(la_ligne, 'FILM','film');
la_ligne := StringReplace(la_ligne, 'TV-S','épisode(s) (spécial télé)');
la_ligne := StringReplace(la_ligne, 'CLIP','clip');
la_ligne := StringReplace(la_ligne, 'mins','minutes.');
if la_duree <> '' then
begin
la_ligne := StringReplace(la_ligne, la_duree+' minutes','de '+la_duree+' minutes');
end;
la_ligne := Trim(la_ligne);
result := la_ligne;
end;
//------------------------------------------------------------------------------
// SUPPRESSION DES BALISES
//------------------------------------------------------------------------------
function deleteBalise (la_ligne : String) : string;
var
i,j, fin : Integer;
la_chaine_sans_balise, aucun : String;
begin
la_chaine_sans_balise := '';
fin := Length(la_ligne);
repeat
i := pos('<',la_ligne);
if i <> 0 then
begin
aucun := copy(la_ligne,i+1,fin);
delete(aucun,2,fin);
// pour être sûr d'avoir affaire à une balise
if aucun = ' ' then
begin
la_chaine_sans_balise := la_chaine_sans_balise + copy (la_ligne,1,i);
delete(la_ligne,1,i);
end else
begin
j := pos('>',la_ligne);
fin := Length(la_ligne);
la_chaine_sans_balise := la_chaine_sans_balise + copy (la_ligne,1,i-1);
delete(la_ligne,1,j);
end;
end;
until i = 0;
fin := Length(la_ligne);
la_chaine_sans_balise := la_chaine_sans_balise + copy (la_ligne,1,fin);
result := la_chaine_sans_balise;
end;
//------------------------------------------------------------------------------
// SUPPRESSION DES CARACTERES JAPONAIS DANS LES NOMS D'EPISODES
//------------------------------------------------------------------------------
function deleteKanji (la_ligne : String) : string;
var
i : Integer;
begin
i:=pos('',la_ligne); // ces symboles caractérisent un caractère asiatique
if i <> 0 then
begin
la_ligne := copy(la_ligne,1,i-2);
end;
result := la_ligne;
end;
//------------------------------------------------------------------------------
// NETTOIE LE TITRE
//------------------------------------------------------------------------------
function nettoieTitre(le_titre : String) : string;
var
i : Integer;
begin
i:=pos('(1',le_titre);
if i <> 0 then
begin
le_titre := copy(le_titre,1,i-1);
le_titre := Trim(le_titre);
result := le_titre;
end;
i:= 0;
i:=pos('(2',le_titre);
if i <> 0 then
begin
le_titre := copy(le_titre,1,i-1);
le_titre := Trim(le_titre);
result := le_titre;
end else
result := le_titre;
end;
//------------------------------------------------------------------------------
// DETERMINE LE TIME-OUT SUIVANT LE TYPE DE LANCEMENT
//------------------------------------------------------------------------------
procedure timeSleepProc();
begin
compteur := compteur+1;
if compteur = 9 then
begin
compteur := 0;
sleep(sleepAuto*10);
end;
if (GetOption('Type de Lancement') = 0) or (GetOption('Type de Lancement') = 1) then
TimeSleep := sleepManu
else if (GetOption('Type de Lancement') = 2) or (GetOption('Type de Lancement') = 3) then
TimeSleep := sleepAuto;
end;
//------------------------------------------------------------------------------
// COMPARE LE TITRE PASSE ET LE TITRE TROUVE
//------------------------------------------------------------------------------
function compareTitle(titleAllo, title : String) : String;
begin
title := supprimeAccents(trim(AnsiLowerCase(title)));
titleAllo := supprimeAccents(trim(AnsiLowerCase(titleAllo)));
if (title = titleAllo) then
begin
result := 'OK';
end else
begin
result := 'KO';
end;
end;
//------------------------------------------------------------------------------
// Fonction TextBetween (retourne le texte entre BeforeText et AfterText (sans ces 2 chaines)
//------------------------------------------------------------------------------
function TextBetween(WholeText: string; BeforeText: string; AfterText: string): string;
var
FoundPos: Integer;
WorkText, RemainingText: string;
begin
RemainingText := WholeText;
Result := '';
FoundPos := Pos(BeforeText, WholeText);
if FoundPos = 0 then
Exit;
WorkText := Copy(WholeText, FoundPos + Length(BeforeText), Length(WholeText));
FoundPos := Pos(AfterText, WorkText);
if FoundPos = 0 then
Exit;
Result := Copy(WorkText, 1, FoundPos - 1);
RemainingText := Copy(WorkText, FoundPos + Length(AfterText), Length(WorkText));
end;
//------------------------------------------------------------------------------
// début récup image animenewsnetwork (Merci Baffab)
//------------------------------------------------------------------------------
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 Add_album_on_list(Address: string;Compteur2: Integer): Integer;
var
AnimeTitle,Value,Url: string;
Line: string;
BeginPos, EndPos: Integer;
begin
Line := GetPage(Address);
if Pos('results', Line) > 0 then
begin
// Recherche le premier album trouvé
BeginPos := pos('results', Line);
Delete(Line, 1, BeginPos-1);
BeginPos := pos('
0) and (pos('
BeginPos) do
begin
BeginPos := pos('>', Line)+1;
EndPos := pos('', Line);
Value := copy(Line, BeginPos, EndPos - BeginPos);
// Parse pour avoir le titre
AnimeTitle := Value;
HTMLRemoveTags(AnimeTitle);
HTMLDecode(AnimeTitle);
// Parse pour avoir l'url
Url := copy(Line,1,pos('>',Line));
Delete(Url, 1, pos('
0) then
begin
if (Res = 1) then
begin
AnalyzeAnimePage(adresseunique);
exit;
end;
// Affiche fenetre de selection
if PickTreeExec(Address)= False then
begin
test := False;
exit;
end else
begin
if (pos('id', Address) >0) then
begin
// On a selectionné un anime
AnalyzeAnimePage(Address);
end else
// On a selectionné page suivante.
AnalyzePage2(Address);
end
end;
end;
procedure AnalyzeAnimePage(Address:string);
var
Value, PageContents: string;
BeginPos: Integer;
begin
PageContents := GetPage(Address);
Sleep(500);
// Images
BeginPos := Pos('/fit200', PageContents);
if (BeginPos > 0) then
begin
Value := findInfo ('/fit200', ' ', PageContents, '0');
Value := 'http://www.animenewsnetwork.com/thumbnails/fit200' + Value;
delete(Value,length(Value),1);
Value := StringReplace(Value,'thumbnails/fit200x200','images');
GetPicture(Value);
test := True;
end;
end;
//------------------------------------------------------------------------------
// Fin récup image animenewnetwork (Merci Baffab)
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Transforme la version html de l'éditeur en version compréhensible
// en récupérant la base des éditeurs directement sur le site d'Animeka
//------------------------------------------------------------------------------
function TransformEditeur(editeurs : String) : string;
var
editeur_html, Editeur_NOTV, Editeur_TV, editeur : string;
BeginPos, EndPos : Integer;
begin
Editeur_NOTV := GetPage('http://www.animeka.com/animes/editeur/index.html');
BeginPos := Pos('>Liste des éditeurs français',Editeur_NOTV);
Delete(Editeur_NOTV, 1, BeginPos);
// se cale au bon endroit
BeginPos := Pos('',Editeur_NOTV);
Delete(Editeur_NOTV, 1, BeginPos-1);
// Charge la partie TV des éditeurs dans Editeur_TV
BeginPos := Pos('editeur/tv', Editeur_NOTV);
EndPos := Pos('', Editeur_NOTV);
Editeur_TV := Copy(Editeur_NOTV, BeginPos, EndPos-BeginPos);
// Charge l'autre Partie dans Editeur_NOTV
Editeur_NOTV := Copy(Editeur_NOTV, 1 , BeginPos-150);
// se cale au début de la partie TV, début de la boucle
repeat
BeginPos := Pos(' | ',Editeur_TV);
Delete(Editeur_TV, 1, BeginPos);
// Cherche le nom de l'éditeur version HTML
BeginPos := Pos('/animes/editeur/',Editeur_TV);
Delete(Editeur_TV, 1, BeginPos+15);
EndPos := Pos('">',Editeur_TV);
editeur_html := Copy(Editeur_TV, 1, EndPos-1 );
// Cherche le nom de l'éditeur version compréhensible
BeginPos := Pos('">',Editeur_TV);
Delete(Editeur_TV, 1, BeginPos+1);
EndPos := Pos(' | ',Editeur_TV)-1;
editeur := Copy(Editeur_TV, 1, EndPos );
// Vire les [EX trucmuch] si il y en a
if Pos(' [EX', editeur) <> 0 then
begin
BeginPos := Pos(' [EX', editeur);
EndPos := Pos(']', editeur);
Delete(editeur, BeginPos, (EndPos-BeginPos)+1);
end;
// Remplace éventuellement editeurs et se recale à la ligne suivante
editeurs := StringReplace(editeurs, editeur_html, editeur);
BeginPos := Pos('animestxthl',Editeur_TV);
Delete(Editeur_TV, 1, BeginPos);
until BeginPos = 0;
// se cale au début de l'autre partie, début de la boucle
repeat
BeginPos := Pos(' | ',Editeur_NOTV);
Delete(Editeur_NOTV, 1, BeginPos);
// cherche le nom de l'éditeur version HTML
BeginPos := Pos('/animes/editeur/',Editeur_NOTV);
Delete(Editeur_NOTV, 1, BeginPos+15);
EndPos := Pos('">',Editeur_NOTV);
editeur_html := Copy(Editeur_NOTV, 1, EndPos-1 );
// cherche le nom de l'éditeur version compréhensible
BeginPos := Pos('">',Editeur_NOTV);
Delete(Editeur_NOTV, 1, BeginPos+1);
EndPos := Pos(' | ',Editeur_NOTV)-1;
editeur := Copy(Editeur_NOTV, 1, EndPos );
// Vire les [EX trucmuch] s'il y en a
if Pos(' [EX', editeur) <> 0 then
begin
BeginPos := Pos(' [EX', editeur);
EndPos := Pos(']', editeur);
Delete(editeur, BeginPos, (EndPos-BeginPos)+1);
end;
// Remplace éventuellement editeurs et se recale à la ligne suivante
editeurs := StringReplace(editeurs, editeur_html, editeur);
BeginPos := Pos('animestxthl',Editeur_NOTV);
Delete(Editeur_NOTV, 1, BeginPos);
until BeginPos = 0;
// Donne le résultat
result := editeurs;
end;
//------------------------------------------------------------------------------
// REMET LES ARTICLES EN DEBUT DE TITRE (existe déjà dans ScorEpioNCommonScript, mais réécris pour éviter un reformatage des chiffres romains ex: III devient Iii)
//------------------------------------------------------------------------------
function articleDebutTitre2(title,Debut,Fin : String) : String;
var
Articles: array of string;
i: integer;
begin
//title := AnsiLowerCase(title);
Articles := initLesArticles2();
for i := 0 to GetArrayLength(Articles)-1 do
begin
if Pos(Debut+trim(Articles[i])+Fin, title) <> 0 then
begin
title := Articles[i]+title;
title := StringReplace(title, Debut+trim(Articles[i])+Fin, '');
Break;
end;
end;
result := title;
end;
//------------------------------------------------------------------------------
// INITIALISE LA LISTE DES ARTICLES (existe déjà dans ScorEpioNCommonScript, mais réécris pour éviter un reformatage des chiffres romains ex: III devient Iii)
//------------------------------------------------------------------------------
function initLesArticles2() : array of string;
var
Articles: array of string;
i: integer;
begin
SetArrayLength(Articles,64);
Articles[0]:='le ';
Articles[1]:='la ';
Articles[2]:='l''';
Articles[3]:='l ';
Articles[4]:='les ';
Articles[5]:='des ';
Articles[6]:='un ';
Articles[7]:='une ';
Articles[8]:='the ';
Articles[9]:='a ';
Articles[10]:='an ';
Articles[11]:='der ';
Articles[12]:='das ';
Articles[13]:='die ';
Articles[14]:='dem ';
Articles[15]:='den ';
Articles[16]:='ein ';
Articles[17]:='eine ';
Articles[18]:='einen ';
Articles[19]:='einer ';
Articles[20]:='eines ';
Articles[21]:='einem ';
Articles[22]:='uno ';
Articles[23]:='una ';
Articles[24]:='el ';
Articles[25]:='los ';
Articles[26]:='las ';
Articles[27]:='unos ';
Articles[28]:='unas ';
Articles[29]:='il ';
Articles[30]:='lo ';
Articles[31]:='i ';
Articles[32]:='Le ';
Articles[33]:='La ';
Articles[34]:='L''';
Articles[35]:='L ';
Articles[36]:='Les ';
Articles[37]:='Des ';
Articles[38]:='Un ';
Articles[39]:='Une ';
Articles[40]:='The ';
Articles[41]:='A ';
Articles[42]:='An ';
Articles[43]:='Der ';
Articles[44]:='Das ';
Articles[45]:='Die ';
Articles[46]:='Dem ';
Articles[47]:='Den ';
Articles[48]:='Ein ';
Articles[49]:='Eine ';
Articles[50]:='Einen ';
Articles[51]:='Einer ';
Articles[52]:='Eines ';
Articles[53]:='Einem ';
Articles[54]:='Uno ';
Articles[55]:='Una ';
Articles[56]:='El ';
Articles[57]:='Los ';
Articles[58]:='Las ';
Articles[59]:='Unos ';
Articles[60]:='Unas ';
Articles[61]:='Il ';
Articles[62]:='Lo ';
Articles[63]:='I ';
result := Articles;
end;
//------------------------------------------------------------------------------
// PROGRAMME PRINCIPAL
//------------------------------------------------------------------------------
begin
if CheckVersion(3,5,1) then
begin
// Pour une mise à jour automatique du script
// Début
if GetOption('Auto-Update') = 0 then
begin
AutoUpdate(GetStatic('LastUPD'), VersionScript, NomScript);
SetStatic('LastUPD',GetField(fieldDate));
end;
// Fin
if GetOption('Mise à jour') = 0 then
begin
execMenuMAJ(VersionScript,NomScript);
exit;
end;
// Pour ne pas avoir l'alerte sur le type de lancement à chaque fois mais uniquement à la première execution
// Début
TypeExec := GetStatic('LastExec');
if (TypeExec <> IntToStr(GetOption('Type de Lancement'))) then
begin
if (ShowConfirmation('Vous exécutez le script avec le type de lancement << '+IntToStr(GetOption('Type de Lancement'))+' >> pour la première fois.'+RCN(2)+'Cliquer sur ''''OUI'''' pour continuer.') = False) then
exit
else
SetStatic('LastExec',IntToStr(GetOption('Type de Lancement')));
end;
// Fin
NomFilm := recupTitreRecherche(GetOption('Recherche sur le titre'));
timeSleepProc();
// Pour la création du fichier log
// Début
if (GetOption('Fichier de log') = 0) and (premiereExecution = 0) then
begin
premiereExecution := -1;
batch(NomScript);
AddToLog('Les animes ayant été mis à jour sont maintenant cochés');
end;
// Fin
if (GetOption('Type de Lancement') = 0) then
begin
if Input(NomScript+' by ScorEpioN', 'Entrez le titre de l''anime :', NomFilm) then
begin
if Pos(urlDomain, NomFilm) > 0 then
begin
AnalysePageFilm(NomFilm);
end else
begin
MovieName := NomFilm;
NomFilm := supprimeLesArticles(NomFilm);
NomFilm := supprimeLesAccents(NomFilm);
NomFilm := StringReplace(NomFilm, '''', '+');
NomFilm := StringReplace(NomFilm, ' ', '+');
NomFilm := urlSearch+ UrlEncode(NomFilm)+urlSubmit;
AnalyzePage(NomFilm);
end;
end;
end else
if (GetOption('Type de Lancement') = 3) then
begin
NomFilm := GetField(fieldURL);
if Pos(urlDomain, NomFilm) > 0 then
AnalysePageFilm(NomFilm);
end else
begin
MovieName := NomFilm;
NomFilm := supprimeLesArticles(NomFilm);
NomFilm := supprimeLesAccents(NomFilm);
NomFilm := StringReplace(NomFilm, ' ', '+');
AnalyzePage(urlSearch+ UrlEncode(NomFilm)+urlSubmit);
end;
end else
ShowMessage('Ce script requiert une version plus récente de Ant Movie Catalog (au moins la version 3.5.1)');
end. |