(*************************************************** Ant Movie Catalog importation script www.antp.be/software/moviecatalog/ [Infos] Authors=Draco31.fr, bbullot, The Jedi, bad4u, raoul_volfoni Title=CinEmotions / CineMoteur Description=Recherche CineMoteur ou CinEmotions / Données CinEmotions Site=http://www.cinemotions.com/ Language=FR Version=0.9.9.7 du 14/07/2010 Requires=3.5 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] 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=Lancement automatique sur l'adresse web Moteur de recherche=0|0|0=CinEmotions|1=CineMoteur Format du Titre=3|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=Formatage identique au site d'origine Recherche sur le titre=0|0|0=Traduit|1=Original Affiche=1|0|0=Prend la petite affiche|1=Prend la grande affiche Liste des Acteurs=1|0|0=Courte|1=Longue Note=2|2|0=Note de CinEmotions|1=Note des membres|2=Note moyenne Liste des notes=1|0|0=Pas de détail des notes|1=Liste des notes (CinEmotions, Membres) dans le champ commentaire Critiques=1|1|0=Oui|1=Non ***************************************************) program CinEmotions; uses ScorEpioNCommonScript; const VersionScript = '0.8.9_mod du 16/11/2008'; NomScript = 'CinEmotions'; urlDomain = 'http://www.cinemotions.com'; urlCESearch = 'http://www.cinemotions.com/recherche/'; pathCESearch = '/cinema-tv-dvd/film-serie-acteur-actrice-realisateur/'; urlCESearchGo = '1.html'; urlCMSearch = 'http://www.cinemoteur.com/cine-tv-dvd/resultats/1/'; urlCMSearchGo = '1.html'; timetosleep = 500; var MovieName, Titre, urlTitre, Resume, APage, CPage, Comments : string; CxNote, compteur, premiereExecution, numTemp, lien_URL, Critique : Integer; NoteC, NoteM, Note, NumPage: real; listeResultat : TStringList; //--OK-------------------------------------------------------------------------- // ANALYSE RESULTAT DE RECHERCHE CineMoteur //------------------------------------------------------------------------------ procedure AnalyzeCMSearchPage(urlSearch: string); var Line, PageNo, temp : string; nbchoix : integer; begin Line := GetPage(urlSearch); // MonDebug('CE', Line); PickTreeClear; // Controle le nb de résultat dans la liste nbchoix := 0; urlTitre := ''; Titre := ''; // Prend le numéro de la page en cours if Pos('page',urlSearch) > 0 then temp := Copy(urlSearch,Pos('page',urlSearch)+4,1) else temp := Copy(urlSearch,Pos('.html',urlSearch)-1,1); //temp := MonFindInfo('','',Line,0); NumPage := StrToFloat(temp); // Supprimme le haut de la page Delete(Line,1,Pos('Pages :',Line)); // Supprimme les liens vers les pages précédentes Delete(Line,1,Pos('class="smallblue">'+FloatTostr(NumPage-1)+'',Line)); // Supprimme la fin de la page (doublons) Delete(Line,Pos('Pages :',Line),Length(Line)); // Test si existe page suivante if ( Pos(urlCMSearch,Line) > 0 ) Then begin urlTitre := MonFindInfo('',Line,0); PickTreeMoreLink(urlTitre); PageNo := ' (Page N°'+temp+')'; // NumPage := NumPage+1; end else begin if (NumPage = 1) Then PageNo := '' else PageNo := ' (Dernière Page)'; // NumPage := -1; end PickTreeAdd('Résultat trouvé pour : '+MovieName+PageNo,''); // Ne garde que le tableau de résultats Delete(Line,1,Pos('',Line)); // Condition pour fin de la liste de résultats //While (Pos('
',Line) > 1) do While (Pos('',Line)); end // Verifie qu'un titre est trouvé if nbchoix = 0 Then ShowInformation('Aucun titre correspondant à "'+MovieName+'" !'+#13#10+'Relancez le script en donnant un autre mot clé !'); if ( NumPage > 1) Then PickTreeAdd('<< Page Précédente',StringReplace(Copy(urlSearch,1,Pos('.html',urlSearch)-1)+'.html','page'+FloatToStr(Numpage),'page'+FloatToStr(Numpage-1))) else begin if (nbchoix = 1) Then begin AnalyzeMoviePage(urlTitre); nbchoix := 0; end end // Affiche la liste de choix puis verifie qu'il y a une selection if (nbchoix <> 0) Then begin if (PickTreeExec(urlTitre)) then begin // Si choisie, lance la recherche sur la page suivante if (pos(urlCMSearch,urlTitre) > 0) Then begin nbchoix := 0; AnalyzeCMSearchPage(urlTitre); end else // Analyse la page du film selectionné AnalyzeMoviePage(urlTitre); end end end; //--OK-------------------------------------------------------------------------- // ANALYSE RESULTAT DE RECHERCHE CinEmotions //------------------------------------------------------------------------------ procedure AnalyzeCESearchPage(urlSearch: string); var Line, PageNo, temp, urlPageSuiv : string; nbchoix : integer; begin Line := GetPage(urlSearch); PickTreeClear; // Controle le nb de résultat dans la liste nbchoix := 0; urlTitre := ''; Titre := ''; // Supprime le haut de la page Delete(Line,1,Pos('
',Line) > 1) do begin TraiteInfoM(Line); if (pos(': le jeu',Titre) = 0) Then PickTreeAdd(Titre,urlTitre); nbchoix := nbchoix+1; // Supprimme jusqu'à la prochaine ligne du tableau Delete(Line,1,Pos('',Line)); // Supprimme l'url supplémentaire si il y a une affiche Delete(Line,1,Pos('
',Line)); // Prend le numéro de la page en cours temp := Copy(urlSearch,Pos('.html',urlSearch)-1,1); NumPage := StrToFloat(temp); // Test si existe page suivante if ( Pos('',Line)); // Condition pour fin de la liste de résultats While (Pos('
',Line) > 1) do begin // Supprime jusqu'à la prochaine ligne du tableau Delete(Line,1,Pos('
',Line)); // Récupère titre et url TraiteInfoC(Line); if (pos(': le jeu',Titre) = 0) Then PickTreeAdd(Titre,urlTitre); nbchoix := nbchoix+1; if Pos('
',Line) = 0 then Delete(Line,1,Pos('
',Line)-1); end // Supprime jusqu'à la fin de la page Delete(Line,1,Pos('Pages de résultats:',Line)); // Supprime jusqu'à la prochaine page Delete(Line,1,Pos('',Line)); // Sauve l'url de la page suivante si possible if ( Pos(''+FloatToStr(Numpage+1),Line,0); PickTreeMoreLink(urlPageSuiv); end // Verifie qu'un titre est trouvé if nbchoix = 0 Then ShowInformation('Aucun titre correspondant à "'+MovieName+'" !'+#13#10+'Relancez le script en donnant un autre mot clé !'); if ( NumPage > 1) Then PickTreeAdd('<< Page Précédente',Copy(urlSearch,1,Pos('.html',urlSearch)-2)+FloatToStr(NumPage-1)+'.html') else begin if (nbchoix = 1) Then begin AnalyzeMoviePage(urlTitre); nbchoix := 0; end end // Affiche la liste de choix puis verifie qu'il y a une selection if (nbchoix <> 0) Then begin if (PickTreeExec(urlTitre)) then begin // Si choisie, lance la recherche sur la page suivante if (pos(urlCESearch,urlTitre) > 0) Then begin nbchoix := 0; AnalyzeCESearchPage(urlTitre); end else // Analyse la page du film selectionné AnalyzeMoviePage(urlTitre); end end end; //--OK-------------------------------------------------------------------------- // TRAITE L'INFO CINEMOTEUR : SEPARE L'URL DU TITRE //------------------------------------------------------------------------------ procedure TraiteInfoM(infos: string); var temp1, temp2: string; begin urlTitre := ''; Titre := ''; infos := Copy(infos,1,Pos('',temp)) And (Pos('',temp) <> 0)) Then t1 := t1+' ('+MonFindInfo('','',temp,0)+')'; // Supprimme les données de cet acteur dans temp Delete(temp,1,Pos('',temp)); end t1 := Copy(t1,3,length(t1)); end end end else begin Delete(Line,1,Pos('Réalisation :',Line)); t1 := MonFindInfo('avec : ','',Line,0); { While Pos('','',temp,0); t2 := MonFindInfo('(',')',temp,0); t1 := t1+' ('+t2+')'; Delete(temp,1,Pos(t2+')',temp)); end } HTMLDecode(t1); HTMLRemoveTags(t1); t1 := StringReplace(t1,'avec : ',''); t1 := StringReplace(t1,#13,''); t1 := StringReplace(t1,#10,''); t1 := StringReplace(t1,#09,''); end NoHTML(t1); SetField(fieldActors,t1); //--OK-------------------------------------------------------------------------- // Prend les critiques si il y en a if (GetOption('Critiques') = 0) and CanSetField(fieldComments) Then begin temp := ''; t1 := ''; t2 := ''; t3 := ''; t3 := StringReplace(url,urlDomain,''); t3 := StringReplace(t3,'.html','/critiques.html'); if Pos (t3,Line) > 0 Then begin CPage := GetPage(urlDomain+t3); temp := MonFindInfo('','
',infos)-1); urlTitre := MonFindInfo('HREF="','" rel="nofollow"',infos,0); urlTitre := StringReplace(urlTitre, '--','-'); urlTitre := StringReplace(urlTitre, 'http://www.cinemoteur.fr/redirect_film/', 'http://www.cinemotions.com/modules/Films/fiche/')+'.html'; // 25/06/2009 temp1 := MonFindInfo('ALT="','">',infos,0); temp2 := MonFindInfo('
','',infos,0); Titre := temp1+' '+temp2; Titre := StringReplace(Titre,'\',''); end; //--OK-------------------------------------------------------------------------- // TRAITE L'INFO CINEMOTION : SEPARE L'URL DU TITRE //------------------------------------------------------------------------------ procedure TraiteInfoC(infos: string); var temp1, temp2, temp3 : string; begin urlTitre := ''; Titre := ''; //infos := Copy(infos,1,Pos('',infos)-1); //Delete(infos,1,Pos('',infos)); urlTitre := MonFindInfo('','',infos,0); //Delete(infos,1,Pos('',infos)); temp2 := MonFindInfo('
','',infos,0); if Pos('
',temp2) = 0 then Delete(temp2,Pos(' -',temp2),length(temp2)-Pos(' -',temp2)+1); Delete(temp2, 1, Pos('
',temp2)-1); Delete(temp2,Pos(' -',temp2),length(temp2)-Pos(' -',temp2)+1); temp2 := FullTrim(StringReplace(temp2, '
','')); if Length(temp2) <> 4 then temp2 := ''; Titre := temp1+' ('+temp2+')'; Titre := StringReplace(Titre,'\',''); end; //------------------------------------------------------------------------------ // ANALYSE LA PAGE DU FILM //------------------------------------------------------------------------------ procedure AnalyzeMoviePage(url : string); var t1, t2, t3, min, heure, annee, temp, Line, pays, le_type, duree, prod, Titre_Traduit, Titre_Original : string; i, j : Real; ImageCE : TStringList; begin temp := ''; Comments := ''; Line := GetPage(url); // Supprimme les parties inutiles Delete(Line,1,Pos('
', Line, '4'); SetField(fieldTranslatedTitle,FormatTitre(FullTrim(FindInfo('" >','',Titre_Traduit,'0')),GetOption('Format du Titre'))); //--OK-------------------------------------------------------------------------- // Recherche et Prend le titre original if (Pos('',Line) > 0) Then SetField(fieldOriginalTitle,FormatTitre(Fulltrim(FindInfo('','',Titre_Traduit,'0')),GetOption('Format du Titre'))) else SetField(fieldOriginalTitle,''); // Récupère Année + Pays + Genre + Durée temp := MonFindInfo('','',Line,0); // temp := StringReplace(temp,' ',''); temp := StringReplace(temp,#13#10,''); temp := StringReplace(temp,Copy(temp,1,1),''); //--OK-------------------------------------------------------------------------- // Prend l'année Annee := Copy(temp,1,4); SetField(fieldYear,Annee); //--OK-------------------------------------------------------------------------- // Prend le pays pays := MonFindInfo('- ','- ',temp,0); temp := Copy(temp,Pos(pays,temp)+length(pays),length(temp)); pays := AnsiLowerCase(pays); pays := StringReplace(pays, 'états-unis', 'USA'); pays := StringReplace(pays, 'etats-unis', 'USA'); pays := StringReplace(pays, 'hong kong', 'Hong-Kong'); pays := StringReplace(pays,' / ',', '); pays := StringReplace(pays,'/',', '); pays := transformCountry(pays); SetField(fieldCountry,pays); //--OK-------------------------------------------------------------------------- // Prend le genre le_type := MonFindInfo('- ','- ',temp,0); le_type := StringReplace(le_type,'/',', '); SetField(fieldCategory,le_type); temp := Copy(temp,Pos(le_type,temp)+length(le_type),length(temp)); //--OK-------------------------------------------------------------------------- // Prend la durée duree := Copy(temp,Pos('- ',temp)+2,length(temp)); duree := StringReplace(duree,' ',''); duree := StringReplace(duree,#13#10,''); if Pos('h',duree) > 0 Then begin heure := Copy(duree,1,Pos('h',duree)-1); min := Copy(duree,Pos('h',duree)+1,length(duree)); i := StrToFloat(heure); j := StrToFloat(min); Setfield(fieldLength,FloatToStr(i*60+j)); end else begin duree := StringReplace(duree,'mn',''); duree := StringReplace(duree,'min',''); if Pos('x',duree) > 0 Then begin heure := Copy(duree,1,Pos('x',duree)-1); min := Copy(duree,Pos('x',duree)+1,length(duree)-2); i := StrToFloat(heure); j := StrToFloat(min); SetField(fieldLength,FloatToStr(j)); if i <> 0 Then begin Comments := 'Format : '+heure+' épisode(s) de '+min+' minutes'; SetField(fieldComments,Comments); end end else begin Setfield(fieldLength,duree); end; end; //--OK-------------------------------------------------------------------------- // Prend la compagnie temp := MonFindInfo('Sociétés de production','
',Line,1); Prod := ''; While (Pos('',Temp) > 0) do begin Prod := Prod+', '+MonFindInfo('','',temp,0); Delete(temp,1,Pos('',temp)); end Setfield(fieldProducer,Copy(Prod,3,length(Prod))); //--OK-------------------------------------------------------------------------- // Prend les notes CxNote := GetOption('Note'); Note := -1; // Stoque chaque note temp := ''; temp := MonFindInfo('CinEmotions','
',Line,1); // Note CinEmotion t1 := MonFindInfo('ALT="','">',temp,0); if (t1 = 'Pas encore noté') Then NoteC := -1 else NoteC := StrToFloat(MonFindInfo('Moyenne : ','(',t1,0)); // Note Membre Delete(temp,1,Pos('Membres',temp)); t2 := MonFindInfo('ALT="','">',temp,0); if (t2 = 'Pas encore noté') Then NoteM := -1 else NoteM := StrToFloat(MonFindInfo('Moyenne : ','(',t2,0)); // Donne le détail des notes dans le champ commentaire if GetOption('Liste des notes') = 1 Then begin if Comments <> '' Then Comments := Comments+#13#10#13#10; if NoteC <> -1 Then Comments := Comments+StringReplace(t1,'Moyenne','Note CinEmotions')+#13#10; if NoteM <> -1 Then Comments := Comments+StringReplace(t2,'Moyenne','Note Membres')+#13#10; Comments := Comments+#13#10; NoHTML(Comments); SetField(fieldComments,Comments); end // Rempli le champ Note suivant l'option selectionnée // Reteste tant qu'une note n'est pas choisie While CxNote <> -1 Do begin if ((NoteC = -1) and (NoteM = -1)) Then CxNote := -1 else begin // Moyenne NoteC + NoteM if (CxNote = 2) Then begin // Test si les 2 notes existent if ((NoteC <> -1) and (NoteM <> -1)) Then begin Note := (NoteC+NoteM)/2; CxNote := -1; end else begin // Si que la note CinEmotions, la prend par défaut if (NoteC > NoteM) Then begin Note := NoteC; CxNote := -1; end else begin // Test si la note Membre existe et la prend par défaut if (NoteM <> -1) Then begin Note := NoteM; CxNote := -1; end else // Si pas de Note CinEmotions ou Membre : pas de note CxNote := -1; end end end else begin // Si Note CinEmotion voulue if CxNote = 0 Then begin if NoteC <> -1 Then Note := NoteC; CxNote := -1; end else begin // Si Note Membres voulue if CxNote = 1 Then begin if NoteM <> -1 Then Note := NoteM; CxNote := -1; end end end end end if Note <> -1 Then // NB: La Note du site est sur 20 ! SetField(fieldRating,FloatToStr(Note/2)); //--OK-------------------------------------------------------------------------- // Prend les réalisateurs temp := ''; t1 := ''; temp := MonFindInfo('Réalisation :','',Line,0); // Merci Chapichapo While Pos('','',temp,0); Delete(temp,1,Pos('',temp)); end SetField(fieldDirector,Copy(t1,3,length(t1))); //--OK-------------------------------------------------------------------------- // Prend le synopsis temp := ''; temp := MonFindInfo('>L''histoire<','
',Line,1); temp := MonFindInfo('','',temp,0); NoHTML(temp); temp := stringreplace(temp, #13#10#13#10#13#10, #13#10); Setfield(fieldDescription,temp); //--OK-------------------------------------------------------------------------- // Prend la liste des acteurs temp := ''; t1 := ''; t2 := ''; t3 := ''; if GetOption('Liste des Acteurs') = 1 Then begin t3 := StringReplace(url,urlDomain,''); t3 := StringReplace(t3,'.html','/artistique.html'); t3 := StringReplace(t3,'(',''); t3 := StringReplace(t3,')',''); if Pos (t3,Line) > 0 Then begin if CanSetField(fieldActors) Then begin APage := GetPage(urlDomain+t3); temp := MonfindInfo('','
',APage,0); While Pos('','',temp,0); Delete(temp,1,Pos('',temp)); // Prend son rôle si il existe if ((Pos('',temp) < Pos('
',CPage,0); if Pos('

A Notre Avis ...

',temp) > 0 Then begin t1 := t1+'Critique CinEmotions :'+#13#10+#13#10; Delete(temp,1,Pos('',temp)); t2 := MonFindInfo('class=link10>','',temp,0); t1 := t1+'"'+t2+'"'+' par '+MonFindInfo('','',temp,0)+#13#10; t2 := ''; t1 := t1+MonFindInfo('','',temp,0)+#13#10+#13#10; Delete(temp,1,Pos('
',temp)); // Delete(temp,1,Pos('
',temp)); end if Pos('

A Votre Avis ...

',temp) > 0 Then begin t1 := t1+#13#10+'Critique(s) Spectateur(s):'+#13#10+#13#10; Delete(temp,1,Pos('

A Votre Avis ...

',temp)); While Pos('',temp) > 0 Do begin if (Pos('class=link10>',temp) < Pos('',temp)) and (Pos('class=link10>',temp) <> 0) Then t2 := '"'+MonFindInfo('class=link10>','',temp,0)+'" ' else // begin // if (Pos('',temp) < Pos('class=journal_link2>',temp)) and (Pos('',temp) <> 0) then // t2 := '' // else t2 := '"'+MonFindInfo('class=link10>','',temp,0)+'" '; // end t1 := t1+t2+'par '+MonFindInfo('','',temp,0)+#13#10; t2 := ''; t1 := t1+MonFindInfo('','',temp,0)+#13#10+#13#10; Delete(temp,1,Pos('

',temp)); end end t1 := Comments+t1+#13#10; NoHTML(t1); SetField(FieldComments,t1); end end end; //--OK-------------------------------------------------------------------------- // Supprimme les balises HTML //------------------------------------------------------------------------------ procedure NoHTML(var page: string); begin page := StringReplace(page,'
',#13#10); page := StringReplace(page,'',''); page := StringReplace(page,'',''); page := StringReplace(page,'',''); page := StringReplace(page,'',''); page := StringReplace(page,'',''); page := StringReplace(page,'',''); page := StringReplace(page,'
',''); HTMLDecode(page); end; //--OK-------------------------------------------------------------------------- // TROUVE LA CHAINE VOULUE (Merci ScorEpioN) // option = 1 : Garde début et fin // option = 0 : NE garde PAS début et fin //------------------------------------------------------------------------------ function MonFindInfo(Debut, Fin, Line : string ; option : integer) : string; var infos : String; BeginPos, EndPos : Integer; begin infos := ''; BeginPos := pos(Debut, Line); if BeginPos > 0 then begin if (option = 1) then // Garde 'Debut' et 'Fin' begin delete(Line, 1, BeginPos-1); EndPos := pos(Fin, Line); infos := copy(Line,0,EndPos+length(Fin)-1); end else // Supprimme 'Debut' et 'Fin' // Vérifie si paramètre 'option' n'est pas invalide if (option = 0) then begin delete(Line, 1, BeginPos+length(Debut)-1); EndPos := pos(Fin, Line); infos := copy(Line,0,EndPos-1); end end result := Trim(infos); end; //--OK-------------------------------------------------------------------------- // Formatte les textes (Merci ScorEpioN) //------------------------------------------------------------------------------ procedure Format(name : string); var option: integer; begin option := GetOption('Format du Titre'); name := formatTitre(name,option); end; //------------------------------------------------------------------------------ // Removes tabs and linebreaks in addition of spaces on both sides of the string // antp rewritten by bad4u (copier à partir du fichier StringUtils1.pas) //------------------------------------------------------------------------------ function FullTrim(Value: string): string; var ExitLoop: Boolean; begin Result := ''; ExitLoop := False; repeat case copy(Value, 1, 1) of ' ', #9, #10, #13: Value := copy(Value, 2, Length(Value)-1); else ExitLoop := True; end; until ExitLoop; ExitLoop := False; repeat case copy(Value, Length(Value), 1) of ' ', #9, #10, #13: Value := copy(Value, 1, Length(Value)-1); else ExitLoop := True; end; until ExitLoop; Result := Value; end; //--OK-------------------------------------------------------------------------- // PROGRAMME PRINCIPAL //------------------------------------------------------------------------------ begin if CheckVersion(3,5,1) then begin NumPage := 1; Comments := ''; MovieName := recupTitreRecherche(GetOption('Recherche sur le titre')); // Choix du lancement // Demande du titre if (GetOption('Type de Lancement') = 0) then begin if Input(NomScript+' par draco31.fr', 'Entrez le titre du film :',MovieName) then begin if Pos(urlDomain, MovieName) > 0 then AnalyzeMoviePage(MovieName) else begin if (GetOption('Moteur de recherche') = 1) Then AnalyzeCMSearchPage(urlCMSearch+urlEncode(MovieName)+'/'+FloatToStr(NumPage)+'.html') else AnalyzeCESearchPage(urlCESearch+urlEncode(MovieName)+'/'+FloatToStr(NumPage)+'.html'); end end end else begin // Ne demande pas le titre if (GetOption('Type de Lancement') = 1) then begin if (GetOption('Moteur de recherche') = 1) Then // Recherche CineMoteur AnalyzeCMSearchPage(urlCMSearch+urlEncode(MovieName)+'/'+FloatToStr(NumPage)+'.html') else // Recherche CinEmotions AnalyzeCESearchPage(urlCESearch+urlEncode(MovieName)+'/'+FloatToStr(NumPage)+'.html'); end else begin // Directement sur l'adresse web if (GetOption('Type de Lancement') = 2) then begin urlTitre := GetField(fieldURL); if Pos(urlDomain,urlTitre) > 0 Then AnalyzeMoviePage(urlTitre) else ShowError('L''adresse web ne correspond pas à une page web de CinEmotions !'); end end end end else ShowMessage('Ce script requiert une nouvelle version d''Ant Movie Catalog (au minimum la version 3.5.1)'); end.