(*************************************************** Ant Movie Catalog importation script www.antp.be/software/moviecatalog/ [Infos] Authors=ScorEpioN --- (Mod)ifié par Raoul Volfoni Title=Allociné Description=Données allocine.fr, Affiche allocine.fr, amazon.fr ou cinefil.com Site=http://www.allocine.fr Language=FR Version=V83 du 06/07/10 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] Mode Films ou Séries=0|0|0=Films|1=Séries (Toutes Saisons)|2=Séries (Choix Saison) Type de Lancement=1|1|0=Cherche le meilleur résultat sans confirmation|1=Demande le titre avant de lancer le script|2=Ne demande pas le titre avant de lancer le script|3=Lancement automatique sur l'adresse web 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 Titre en double=0|2|0=Garde les titres originaux et traduits même identiques|1=Garde les titres originaux si identiques|2=Garde les titres traduits si identiques Choix Image=4|2|0=Pas d'affiche|1=Petite affiche allociné|2=Grande affiche allociné|3=Grande affiche amazon.fr|4=Grande affiche Cinefil.com Choix Date=0|0|0=Année de production|1=Date de sortie ou de 1ere diffusion en France Acteurs=2|2|0=Ne prend pas la liste des acteurs|1=Prend les noms des acteurs de la page principale|2=Prend la liste complète des acteurs ainsi que leur rôle et le nom du producteur|3=Prend la liste complète des acteurs et le nom du producteur Secrets de tournage=2|2|0=Ne prend pas les secrets de tournage|1=Prend les secrets de tournage de la page principale|2=Prend la liste complète des secrets de tournage Note=0|0|0=Moyenne note des spectateurs & des critiques|1=Note des spectateurs (de préférence)|2=Notes des critiques (de préférence) Type de note=3|0|0=notation sur 4 sans décimales|1=notation sur 4 avec décimales|2=notation sur 10 sans décimales|3=notation sur 10 avec décimales Detail Note=1|1|0=Ne met pas le détail des notes dans le champs commentaire|1=Détail des notes dans le champs commentaire Critiques Presse=2|0|0=Aucune critique|2=Critiques presse complètes Critiques Spectateurs=2|0|0=Aucune critique|2=Critiques spectateurs de la page principale Bande-Annonce=0|0|0=Pas de lien vers la B.A.|1=Lien vers la B.A. dans l'url|2=Lien vers la B.A. dans les commentaires Fiche technique=0|0|0=Oui|1=Non ListePays=1|1|0=Ne prend que le premier pays de la liste|1=Prend la liste de tous les pays, séparés par des virgules ListeCategories=1|1|0=Ne prend que la première catégorie de la liste|1=Prend la liste de toutes les catégories, séparées par des virgules Disposition=1|1|0=Synopsis et Secrets de tournage dans le champs description|1=Les informations sont dispatchées Fichier de log=1|1|0=Oui|1=Non Casting Saison [Partie Série]=1|1|0=Sans les acteurs récurrents de la saison|1=Avec les acteurs récurrents de la saison Résumé épisodes [Partie Série]=1|1|0=Avec résumé des épisodes|1=Sans résumé des épisodes ***************************************************) program Allocine_FR; uses ScorEpioNCommonScript, StringUtils1; const VersionScript = '52 du 17/07/2006'; NomScript = 'ALLOCINE'; urlDomain = 'allocine.fr'; urlAllocine = 'http://www.allocine.fr'; urlFicheFilm = 'http://www.allocine.fr/film/fichefilm-'; urlAllocineSearch = urlAllocine+'/recherche/'; urlAllocineSearchEndFilm = '1/?q='; urlAllocineSearchEndSeries = '6/?q='; urlAllocineCriSpec = '/film/critiquepublic_gen_cfilm='; urlAllocineCriSpecS ='/series/critiquePublic_gen_cserie='; urlAmazonImage = 'http://ec1.images-amazon.com/images/I/'; debug = False; // mode debug on/off (Un grand MERCI à Scorpion7552 pour cette astuce géniale) debugrep = 'c:\temp\'; // répertoire de stockage des fichiers pour le mode debug timetosleep = 500; nbDecimal = 2; var MovieName, ID, AdressePlus, La_liste, LaGrandeImage, LaPremiereGrandeImage, Reponse, AdresseSuivant, AdressePrecedent, LePremierFilmAdresse, strTemp, aucunAmazon, lannee, lanneeCinefil, TypeExec, MessageInput : string; numPage, numPageG, numPageR, grandeTaille, premiereTaille, compteur, premiereExecution, numTemp, i, occurence : Integer; listeResultat : TStringList; listeMessagesF, listeMessagesS : array of string; //------------------------------------------------------------------------------ // CONVERSION DE L'URL //------------------------------------------------------------------------------ function convertURL(url : String) : string; begin SetArrayLength(listeMessagesF,5); SetArrayLength(listeMessagesS,5); listeMessagesF[0] := 'fichefilm_gen_cfilm'; listeMessagesS[0] := 'ficheserie_gen_cserie'; listeMessagesF[1] := 'fichefilm.html'; listeMessagesS[1] := 'ficheserie.html'; listeMessagesF[2] := '/film/fichefilm_gen_cfilm='; listeMessagesS[2] := '/series/ficheserie_gen_cserie='; listeMessagesF[3] := 'cfilm='; listeMessagesS[3] := 'cserie='; // Converti les url http://www.allocine.fr/film/fichefilm.html?cfilm=3746 en http://www.allocine.fr/film/fichefilm_gen_cfilm=3746.html if pos(listeMessagesF[0],url) <> 0 then result := url else if pos(listeMessagesF[1],url) <> 0 then result := urlAllocine+listeMessagesF[2]+copy(url,pos(listeMessagesF[3],url)+length(listeMessagesF[3]),length(url)-1)+'.html' else if pos(listeMessagesS[0],url) <> 0 then result := url else if pos(listeMessagesS[1],url) <> 0 then result := urlAllocine+listeMessagesS[2]+copy(url,pos(listeMessagesS[3],url)+length(listeMessagesS[3]),length(url)-1)+'.html'; end; //------------------------------------------------------------------------------ // RETOURNE ELEMENT FILMS OU SERIES //------------------------------------------------------------------------------ function retourneElement(j : Integer) : string; begin if (GetOption('Mode Films ou Séries') = 0) then result := listeMessagesF[j] else if (GetOption('Mode Films ou Séries') = 1) then result := listeMessagesS[j] else if (GetOption('Mode Films ou Séries') = 2) then result := listeMessagesS[j]; end; //------------------------------------------------------------------------------ // CALCUL DE LA NOTE //------------------------------------------------------------------------------ function calculMoyenne(Value : String; Echelle : Integer) : string; begin result := FloatToStr(((StrToInt(Value,3)*10) / Echelle)); end; //------------------------------------------------------------------------------ // CALCUL DE LA NOTE 2 Ajouté V53 //------------------------------------------------------------------------------ function calculMoyenne_2(Value : Extended; Echelle : Integer) : Extended; begin result := (((Value)*10) / Echelle); //ShowMessage(FloatToStr(result)); end; //------------------------------------------------------------------------------ // ANALYSE DE LA PAGE DE RECHERCHES //------------------------------------------------------------------------------ procedure AnalyzePage(Address: string); var Line: string; BeginPos, EndPos : Integer; begin //Address := stringreplace(Address, '%2B', '+'); // pour Dedej ou tout utilisateur de "Movie Cat" Line := GetPage(Address); SetArrayLength(listeMessagesF,3); SetArrayLength(listeMessagesS,3); listeMessagesF[0] := 'Aucun film trouvé'; listeMessagesS[0] := 'Aucune série trouvée'; listeMessagesF[1] := '/>Films<'; listeMessagesS[1] := UTF8Encode('/>Séries TV<'); listeMessagesF[2] := urlAllocineSearchEndFilm; listeMessagesS[2] := urlAllocineSearchEndSeries; if pos('Recherche : ""', Line) <> 0 then exit; if pos(UTF8Encode('Oups, on n''a pas trouvé'),Line) <> 0 then begin if (GetOption('Type de Lancement') = 1) or (GetOption('Type de Lancement') = 2) then begin if Input(NomScript+' by ScorEpioN', retourneElement(0)+' pour '''+MovieName+''' :', MovieName) then begin if Pos(urlDomain, MovieName) > 0 then AnalyzeMoviePage(convertURL(MovieName)) else AnalyzePage(urlAllocineSearch+retourneElement(2)+UrlEncode(TitrePlus(UTF8Encode(MovieName)))); end else exit; //showmessage(retourneElement(0)+' pour : '+MovieName); //exit; end else begin SetField(fieldChecked, ''); exit; end; end; if pos(UTF8Encode(': 1 résultat'), Line) > 0 then begin Address := findInfo('
', 'alt=', Line, '4'); Address := urlAllocine+findInfo(' 0 then AddMoviesTitles(findInfo('Merci de', 'Rechercher', Line,'1')); //menuScorEpioN(); if compteur = 1 then begin compteur := 0; AnalyzeMoviePage(copy(listeResultat.GetString(0),pos('|',listeResultat.GetString(0))+1,pos('[',listeResultat.GetString(0))-pos('|',listeResultat.GetString(0))-1)); exit; end else if (GetOption('Type de Lancement') = 1) or (GetOption('Type de Lancement') = 2) then begin begin if PickTreeExec(Address) then begin //if execMenuScorEpioN(urlDomain, Address) = False then //begin if (Address = AdressePlus) then begin numPageR := numPageR+1; AnalyzePage(AdressePlus); end else if (Address = AdressePrecedent) then begin numPageR := numPageR-1; AnalyzePage(AdressePrecedent); end else if (Address = AdresseSuivant) then begin numPageR := numPageR+1; AnalyzePage(AdresseSuivant); end else begin AnalyzeMoviePage(Address); end; //end; end else exit; end; end else begin if (GetOption('Type de Lancement') = 0) and (pos(UTF8Encode(': 0 résultat'),Line) = 0) then begin sleep(timetosleep); if trouveResultat(MovieName) <> '' then AnalyzeMoviePage(trouveResultat(MovieName)); end ; 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,pos('[',couple)-pos('|',couple)-1); oK := compareTitle(title,titre); if oK = 'OK' then begin lannee := copy(couple,pos('[',couple),length(couple)); result := adresse; exit; end; end; if oK = 'KO' then result := ''; listeResultat.Free; end; //------------------------------------------------------------------------------ // Remplace les virgules par des points Ajouté V53 //------------------------------------------------------------------------------ function convert_STF (ligne : String ) : extended; begin if pos(',',ligne) > 0 then ligne := stringreplace(ligne,',','.'); result := StrToFloat(ligne); end; //------------------------------------------------------------------------------ // Arrondi à la valeur décimale souhaité Ajouté V53 //------------------------------------------------------------------------------ function Arrondir(nombre : extended ; nbDecim : integer) : extended; var p10 : extended; begin p10 := Power(10,nbDecim); result := round(nombre * p10) / p10; end; //------------------------------------------------------------------------------ // Fonction Puissance (mathématique) Ajouté V53 //------------------------------------------------------------------------------ function Power(base : extended ; puissance : integer): extended; var temp : extended; i : integer; begin temp := base; if puissance > 0 then begin for i:= 2 to puissance do temp := temp * base; end else begin if puissance = 0 then temp := 1 else for i:= puissance to 0 do temp := temp / base; end; result := temp; end; //------------------------------------------------------------------------------ // ANALYSE DE LA PAGE DU FILM //------------------------------------------------------------------------------ procedure AnalyzeMoviePage(Adresse : String); var Line, Line2, Value, Value2, aucun, Avertissement, Note1, Note11, Note2, Note22 : String; AdresseCasting, AdresseBA, AdresseSecret, AdressePresse, AdresseGalerie, Secret, NumeroFilm : String; IntValue, BeginPos, EndPos, FinPos, coefficient : Integer; Note111, Note222, NotePublic, NotePresse, diviseur, not4, not3, not2, not1, not0 : Extended; begin // Pour le mode Batch if (GetOption('Fichier de log') = 0) then beforeUpdate(); SetArrayLength(listeMessagesF,1); SetArrayLength(listeMessagesS,1); listeMessagesF[0] := '/film/fichefilm_gen_cfilm='; listeMessagesS[0] := '/series/ficheserie_gen_cserie='; // Charge la page Line := GetPage(Adresse); Avertissement := ''; if pos(listeMessagesF[0],Adresse) <> 0 then ID := findInfo(listeMessagesF[0], '.html', Adresse,'0') else if pos(listeMessagesS[0],Adresse) <> 0 then ID := findInfo(listeMessagesS[0], '.html', Adresse,'0'); if (pos('ficheserie',Adresse) <> 0) then begin AnalyzeSeriePage(Adresse,Line); exit; end; // Récupération des urls optionnelles if (GetOption('Bande-Annonce') <> 0) then AdresseBA := ladressedelaBA(Line); if (GetOption('Acteurs') =2) or (GetOption('Acteurs') =3) then AdresseCasting := ladresseduCasting(Line); if (GetOption('Secrets de tournage') = 2) then AdresseSecret := ladressedesSecrets(Line); if (GetOption('Critiques Presse') = 2) then AdressePresse := ladressedesCritiques(Line); // URL if CanSetField(fieldURL) then SetField(fieldURL, URLEncode(Adresse)); // Bande-Annonce (option 1) if (GetOption('Bande-Annonce') = 1) and CanSetField(fieldURL) and (AdresseBA <> '') then SetField(fieldURL, URLEncode(AdresseBA)); //translated title if CanSetField(fieldTranslatedTitle) then MonSetField(fieldTranslatedTitle, formatTitre(FullTrim(UTF8Decode(findInfo('

', '

', Line,'0'))),GetOption('Format du Titre'))); //showmessage(UTF8Decode(FullTrim(findInfo('

', '

', Line,'0')))); // Original Title if CanSetField(fieldOriginalTitle) then begin Value := UTF8Decode(findInfo('Titre original : ', '', Line,'0')); if (Value <> '') then MonSetField(fieldOriginalTitle, formatTitre(Value,GetOption('Format du Titre'))) else SetField(fieldOriginalTitle, GetField(fieldTranslatedTitle)); end; // Picture aucunAmazon := 'aucune image'; if CanSetPicture then begin if GetOption('Recherche sur le titre') = 0 then Value := GetField(fieldTranslatedTitle) else Value := GetField(fieldOriginalTitle); if (GetOption('Choix Image') = 3) then begin imageAmazon(Value); //if aucunAmazon = 'ok' then // mode debug image //SetField(fieldSource, ('Image Amazon récupérée')); // Insère la phrase dans le champ Origine si image Amazon OK returnGrandeImage(Line); returnPetiteImage(Line); end else if (GetOption('Choix Image') = 4) then begin anneeFilmCourant(Line); imageCinefil(Value); //if aucunAmazon = 'ok' then // mode debug image //SetField(fieldSource, ('Image Cinéfil récupérée')); // Insère la phrase dans le champ Origine si image Cinéfil OK returnGrandeImage(Line); returnPetiteImage(Line); end else if (GetOption('Choix Image') = 1) then begin returnPetiteImage(Line); end else if (GetOption('Choix Image') = 2) then begin returnGrandeImage(Line); returnPetiteImage(Line); end; end; // CanSetPicture // Director if CanSetField(fieldDirector) then MonSetField(fieldDirector, formatTitre(UTF8Decode(findInfo(UTF8Encode('Réalisé par '), '
', Line,'0')),GetOption('Format du Titre'))); //showmessage(UTF8Decode(findInfo(UTF8Encode('Réalisé par '), '', Line,'0'))); // Actors if CanSetField(fieldActors) and (GetOption('Acteurs') = 1) then begin aucun := UTF8Decode(findInfo('Avec ', 'plus', Line,'0')); aucun := copy(aucun,1,length(aucun)-1)+'.'; MonSetField(fieldActors, formatTitre(aucun, GetOption('Format du Titre'))); end; //showmessage(UTF8Decode(findInfo('Avec ', 'plus', Line,'0'))); //Country if CanSetField(fieldCountry) then begin //showmessage(formatTitre(StringReplace(transformCountry(deleteEnd(RemoveSpaces(UTF8Decode(findInfo(UTF8Encode('Long-métrage'), 'Genre', Line,'0')), True),'.')), ',', ', '), GetOption('Format du Titre'))); if pos(UTF8Encode('Long-métrage :'), Line) > 0 then MonSetField(fieldCountry, formatTitre(StringReplace(transformCountry(deleteEnd(deleteEnd(RemoveSpaces(UTF8Decode(findInfo(UTF8Encode('Long-métrage :'), 'Genre', Line,'0')), True),'.'), ' ')), ' , ', ', '), GetOption('Format du Titre'))) else MonSetField(fieldCountry, formatTitre(StringReplace(transformCountry(deleteEnd(deleteEnd(RemoveSpaces(UTF8Decode(findInfo(UTF8Encode('Long-métrage'), 'Genre', Line,'0')), True),'.'), ' ')), ' , ', ', '), GetOption('Format du Titre'))); end; if GetOption('ListePays') = 0 then MonSetField(fieldCountry,copy(GetField(fieldCountry), 1, pos(',',GetField(fieldCountry))-1)); // Category if CanSetField(fieldCategory) then begin //showmessage(formatTitre(StringReplace(RemoveSpaces(UTF8Decode(findInfo('Genre', '
', Line,'0')), True), ',', ', '), GetOption('Format du Titre'))); if pos(('Genre :'), Line) > 0 then // Merci à Malo56 MonSetField(fieldCategory, formatTitre(StringReplace(RemoveSpaces(UTF8Decode(findInfo('Genre :', '
', Line,'0')), True), ' , ', ', '), GetOption('Format du Titre'))) else MonSetField(fieldCategory, formatTitre(StringReplace(RemoveSpaces(UTF8Decode(findInfo('Genre', '
', Line,'0')), True), ' , ', ', '), GetOption('Format du Titre'))); end; if GetOption('ListeCategories') = 0 then MonSetField(fieldCategory,copy(GetField(fieldCategory), 1, pos(',',GetField(fieldCategory))-1)); // Length aucun := Line; if CanSetField(fieldLength) then begin if pos(UTF8Encode('Durée :'), Line) > 0 then // Merci à Malo56 Line := FullTrim(findInfo(UTF8Encode('Durée :'), UTF8Encode('
'), Line, '0')) else Line := FullTrim(findInfo(UTF8Encode('Durée'), UTF8Encode('
'), Line, '0')); Line := Copy(Line, 1, Pos('min', Line)+2); if pos('h', Line) > 0 then IntValue := StrToInt(copy(Line, pos('h', Line)-1, 1), 0) * 60; if pos('min', Line) > 0 then begin delete(Line,1,pos('h', Line)); Value := copy(Line, 1, pos('min',Line)-1); Value := StringReplace(Value, ' ', ''); IntValue := IntValue + StrToInt(Value, 0); end; SetField(fieldLength, IntToStr(IntValue)); end; Line := aucun; // Year if CanSetField(fieldYear) then begin if pos(UTF8Encode('Année de production :'), Line) > 0 then // Merci à Malo56 Value := FullTrim(findInfo(UTF8Encode('Année de production :'), '', Line,'0')) else Value := FullTrim(findInfo(UTF8Encode('Année de production'), '', Line,'0')); if (GetOption('Choix Date') = 1) then begin if pos(UTF8Encode('Date de sortie cinéma :'), Line) > 0 then Value2 := FullTrim(findInfo(UTF8Encode('Date de sortie cinéma :'), '', Line,'1')) else Value2 := FullTrim(findInfo(UTF8Encode('Date de sortie cinéma'), '', Line,'1')); Value2 := FullTrim(Value2); delete(Value2,1,length(Value2)-4); Value2 := isDate(Value2); Value := valueNotEmpty(Value2, Value); end; MonSetField(fieldYear, Value); Value := ''; Value2 := ''; end; // Exact Year {if GetOption('Choix Date d''ajout') = 1 then begin if pos(UTF8Encode('Date de sortie cinéma :'), Line) > 0 then Value := FullTrim(findInfo(UTF8Encode('Date de sortie cinéma :'), '', Line,'0')) else Value := FullTrim(findInfo(UTF8Encode('Date de sortie cinéma'), '', Line,'0')); if Value <> '' then begin Value := ReplaceMonth(Value); Value := StringReplace(Value, ' ', '/'); if Length(Value) = 10 then MonSetField(fieldDate, Value) else MonSetField(fieldDate, '01/01/1900'); end; end;} // Avertissement aucun := Line; BeginPos := pos('Interdit aux moins de', Line); if (BeginPos > 0) then begin Delete(Line, 1, BeginPos-1); EndPos := pos('ans', Line); Avertissement := copy(Line, 1, EndPos +2)+#13#10#13#10; if CanSetField(fieldComments) then SetField(fieldComments, Trim(Avertissement)); end; Line := aucun; // Productor + More actors if ((GetOption('Acteurs') = 2) or (GetOption('Acteurs') = 3)) AND (AdresseCasting <> '') then castingComplet(AdresseCasting); // Rating aucun := Line; // if (pos('notesrecos&', Line) <> 0) then begin Note1 := ''; Note2 := ''; if pos('Revue de presse : les critiques', Line) = 0 then Avertissement := Avertissement else begin Line2 := TextBetween(Line, 'Revue de presse : les critiques', '

'); Note1 := findInfo('>(', ')', Line2,'0'); if (GetOption('Type de note') = 0) then Note11 := floatToStr(arrondir((convert_STF(Note1)),0)); if (GetOption('Type de note') = 1) then Note11 := floatToStr(arrondir((convert_STF(Note1)),nbDecimal)); if (GetOption('Type de note') = 2) then Note11 := FloatToStr(arrondir((calculMoyenne_2((convert_STF(Note1)),4)),0)); if (GetOption('Type de note') = 3) then Note11 := FloatToStr(arrondir((calculMoyenne_2((convert_STF(Note1)),4)),nbDecimal)); if (GetOption('Detail Note') = 1) and ((GetOption('Type de note') = 0) or (GetOption('Type de note') = 1)) then Avertissement := Avertissement + 'Note de la presse : ' + Note11 + '/4 '; if (GetOption('Detail Note') = 1) and ((GetOption('Type de note') = 2) or (GetOption('Type de note') = 3)) then Avertissement := Avertissement + 'Note de la presse : ' + Note11 + '/10 '; end; if pos('Critiques, notes, avis des spectateurs', Line) = 0 then Avertissement := Avertissement else begin Line2 := TextBetween(Line, 'Critiques, notes, avis des spectateurs', '

'); if pos('yenne:', Line2) > 0 then // Détail et nombre de votes des spectateurs begin Note2 := findInfo('>(', ')', Line2,'0'); end; if (GetOption('Type de note') = 0) then Note22 := floatToStr(arrondir((convert_STF(Note2)),0)); if (GetOption('Type de note') = 1) then Note22 := floatToStr(arrondir((convert_STF(Note2)),nbDecimal)); if (GetOption('Type de note') = 2) then Note22 := FloatToStr(arrondir((calculMoyenne_2((convert_STF(Note2)),4)),0)); if (GetOption('Type de note') = 3) then Note22 := FloatToStr(arrondir((calculMoyenne_2((convert_STF(Note2)),4)),nbDecimal)); if (GetOption('Detail Note') = 1) and ((GetOption('Type de note') = 0) or (GetOption('Type de note') = 1)) then Avertissement := Avertissement + #13#10 + 'Note des spectateurs : ' + Note22 + '/4 '; if (GetOption('Detail Note') = 1) and ((GetOption('Type de note') = 2) or (GetOption('Type de note') = 3)) then Avertissement := Avertissement + #13#10 + 'Note des spectateurs : ' + Note22 + '/10 '; end; if CanSetField(fieldComments) and (GetOption('Detail Note') = 1) then // Détail des notes dans les commentaires begin Line2 := TextBetween(Line, 'Critiques, notes, avis des spectateurs', '
'); if pos('yenne:', Line) > 0 then // Détail et nombre de votes des spectateurs begin Value2 := ''; Value := findInfo('pour ', ' notes', Line2,'0'); Value2 := ' (Pour '+Value+' notes : '; if pos('stars=4">', Line2) > 0 then Value2 := Value2 + findInfo('stars=4">', '<', Line2, '0') +' de ****, '; if pos('stars=3">', Line2) > 0 then Value2 := Value2 + findInfo('stars=3">', '<', Line2, '0') +' de ***, '; if pos('stars=2">', Line2) > 0 then Value2 := Value2 + findInfo('stars=2">', '<', Line2, '0') +' de **, '; if pos('stars=1">', Line2) > 0 then Value2 := Value2 + findInfo('stars=1">', '<', Line2, '0') +' de *, '; if pos('stars=0">', Line2) > 0 then Value2 := Value2 + findInfo('stars=0">', '<', Line2, '0') +' de °'; Value2 := Value2 + ')'; Value2 := StringReplace(Value2, ', )', ')'); end; if Value2 <> '' then begin Avertissement := Avertissement + Value2 + #13#10#13#10; SetField(fieldComments, Avertissement); end; end; if CanSetField(fieldRating) then // Notes dans le champs note begin Note111 := convert_STF(Note11); Note222 := convert_STF(Note22); if (GetOption('Type de note') = 0) or (GetOption('Type de note') = 1) then coefficient := 4 else coefficient := 10; if GetOption('Note') = 1 then begin if Note2 <> '' then SetField(fieldRating,FloatToStr(arrondir((calculMoyenne_2((convert_STF(Note22)),coefficient)),1))) else if Note1 <> '' then SetField(fieldRating,FloatToStr(arrondir((calculMoyenne_2((convert_STF(Note11)),coefficient)),1))); end else if GetOption('Note') = 2 then begin if Note1 <> '' then SetField(fieldRating,FloatToStr(arrondir((calculMoyenne_2((convert_STF(Note11)),coefficient)),1))) else if Note2 <> '' then SetField(fieldRating,FloatToStr(arrondir((calculMoyenne_2((convert_STF(Note22)),coefficient)),1))); end else if GetOption('Note') = 0 then begin if (Note1 <> '') and (Note2 <> '') then begin Note111 := Note111+Note222; SetField(fieldRating,FloatToStr(arrondir((calculMoyenne_2(((Note111)),(coefficient*2))),1))); end else if (Note1 <> '') then begin Note111 := Note111+Note111; SetField(fieldRating,FloatToStr(arrondir((calculMoyenne_2(((Note111)),(coefficient*2))),1))); end else if (Note2 <> '') then begin Note111 := Note222+Note222; SetField(fieldRating,FloatToStr(arrondir((calculMoyenne_2(((Note111)),(coefficient*2))),1))); end; end; end; end; Line := aucun; // Bande-Annonce (option 2) if CanSetField(fieldComments) and(GetOption('Bande-Annonce') = 2) and (AdresseBA <> '') then begin Avertissement := Avertissement+'Bande Annonce : '+AdresseBA+#13#10#13#10; SetField(fieldComments, Avertissement); end; // Fiche technique if CanSetField(fieldComments) and (GetOption('Fiche technique') = 0) then begin if Pos('>Fiche technique', Line) > 0 then begin Value := GetPage(urlFicheFilm+ID+'/technique/'); if pos('> Fiche technique', Value) > 0 then begin delete(Value, 1 ,pos('> Fiche technique', Value)); Value := UTF8Decode(findInfo('
', '
', Value, '1')); Value := StringReplace(Value, '

', '##'); HTMLRemoveTags(Value); Value := RemoveSpaces(Value, True); Value := StringReplace(Value, '##', #13#10); Avertissement := Avertissement+'Fiche technique :'+#13#10#13#10+Value+#13#10; MonSetField(fieldComments, Avertissement); end; end; end; // Description if CanSetField(fieldDescription) then begin if pos('Synopsis :', Line) > 0 then begin //showmessage(UTF8Decode(findInfo('Synopsis :', '

', Line,'-1'))); MonSetField(fieldDescription, (FullTrim(UTF8Decode(findInfo('Synopsis :', '

', Line,'-1'))))); end; end; // Commments if CanSetField(fieldComments) then begin if (pos('

Secrets de tournage

', Line) > 0) and (GetOption('Secrets de tournage') = 1) then begin Value := Line; Value := TextBetween(Value, '

Secrets de tournage

', ''); Secret := Avertissement+'Secrets de tournage :'+#13#10#13#10; BeginPos := pos('

', Value); repeat delete(Value, 1, BeginPos-1); // titre aucun := UTF8Decode(findInfo('', '', Value,'0')); Secret := Secret+formatTitre(aucun,GetOption('Casse Choisie'))+#13#10; // secret aucun := FullTrim(UTF8Decode(findInfo('
', '

', Value,'0'))); Secret := Secret+aucun+#13#10#13#10; delete(Value, 1, pos('', Value)); BeginPos := pos('

', Value); until (BeginPos = 0); SetField(fieldComments, Trim(Secret)); end else if (AdresseSecret <> '') and (GetOption('Secrets de tournage') = 2) then begin La_liste := Avertissement+'Secrets de tournage :'+#13#10#13#10; numPage := 1; secretComplet(AdresseSecret); end; end; // Critiques presse if CanSetField(fieldComments) then begin if ((GetOption('Critiques Presse') <> 0) and (pos('Revue de presse : les critiques', Line) > 0)) then begin Value := GetField(fieldComments)+'Critiques Presse :'+#13#10#13#10; delete(Line,1, pos('>Critiques Presse', Line)+length('>Critiques Presse')+1); if (GetOption('Critiques Presse') =1) then begin repeat // Début boucle BeginPos := pos('

', Line); delete(Line, 1, BeginPos-1); // Journal et nom du critique aucun := findInfo('

', '

', Line,'0'); Value := Value+formatTitre(aucun,GetOption('Casse Choisie')); // Note aucun := findInfo('etoile_', '"', Line,'0'); Value := Value+' - Note : '+aucun+ '/4 '+#13#10; // la critique aucun := findInfo('
', Line,'0'); delete(aucun, 1, pos('>', aucun)); aucun := StringReplace(aucun, ' ', ''); Value := Value+aucun+#13#10#13#10; // Fin Boucle delete(Line, 1, length('

')); BeginPos := pos('

', Line); until (BeginPos = 0); SetField(fieldComments, Trim(Value)); end else if (GetOption('Critiques Presse') = 2) and (adressePresse <> '') then begin La_liste := Value; numPage := 1; critiquesPresseComplet(adressePresse); end; end; end; // Critiques Spectateurs if CanSetField(fieldComments) then begin if ((GetOption('Critiques Spectateurs') <> 0) and (pos('Critiques, notes, avis des spectateurs', Line) > 0)) then begin Value := GetField(fieldComments)+'Critiques Spectateurs :'+#13#10#13#10; Line2 := Line; Line := TextBetween(Line, 'Critiques, notes, avis des spectateurs', 'Toutes les critiques spectateurs'); BeginPos := pos('', Line); if (GetOption('Critiques Spectateurs') =2) then begin repeat // Début boucle delete(Line, 1, BeginPos-1); // nom du spectateur et date aucun := Fulltrim(UTF8Decode(findInfo('
', '', Line,'0'))); Value := Value+formatTitre(aucun,GetOption('Casse Choisie')); delete(Line, 1, pos('Sa note :', Line)); // Note aucun := findInfo('stareval n', '0 on4', Line,'0'); Value := Value+' - Note : '+aucun+ '/4 '+#13#10; delete(Line, 1, pos('Sa critique :', Line)); // la critique aucun :=(findInfo('', '

', Line,'4')); if pos('&#', aucun) > 0 then HTMLDecode(aucun) else aucun := UTF8Decode(aucun); aucun := FullTrim(aucun); Value := Value+aucun+#13#10#13#10; // Fin Boucle delete(Line, 1, pos('', Line)); BeginPos := pos('', Line); until (BeginPos = 0); SetField(fieldComments, Trim(Value)); end else if (GetOption('Critiques Spectateurs') = 1) then begin panelCritiquesSpectateurs(Line); end; end; Line := Line2; end; // Pour avoir le synopsis et les secrets de tournage dans le champs descriptions if (GetOption('Disposition') = 0) then moveComments(); // Pour purger la fin des commentaires de retours à la ligne en trop Avertissement := GetField(fieldComments); repeat Avertissement := deleteEnd(Avertissement, #13#10); Until (copy(Avertissement,length(Avertissement)-length(#13#10)+1,length(Avertissement)) <> #13#10); SetField(fieldComments, Avertissement); // Pour le mode Batch if (GetOption('Fichier de log') = 0) then begin AddToLog('Nouvelle Image : '+aucunAmazon); afterUpdate(); end; // Affichage des titres si original et traduit identique titreDouble(GetOption('Titre en double')); end; //------------------------------------------------------------------------------ // ANALYSE DE LA PAGE DE LA SERIE //------------------------------------------------------------------------------ procedure AnalyzeSeriePage(Adresse, Line : String); var Value, Value2, Ligne, Line2, Note2, Note22, Avertissement, DiffFR, DiffORI, Secret, AdresseSecret : string; BeginPos, coefficient : Integer; listeInfos : TStringList; begin // URL if CanSetField(fieldURL) then SetField(fieldURL, URLEncode(Adresse)); //translated title if CanSetField(fieldTranslatedTitle) then MonSetField(fieldTranslatedTitle, formatTitre(FullTrim(UTF8Decode(findInfo('

', '

', Line,'0'))),GetOption('Format du Titre'))); // Original Title if CanSetField(fieldOriginalTitle) then begin Value := findInfo('Titre original : ', '
', Line,'0'); if (Value <> '') then MonSetField(fieldOriginalTitle, formatTitre(Value,GetOption('Format du Titre'))) else SetField(fieldOriginalTitle, GetField(fieldTranslatedTitle)); end; //Country if CanSetField(fieldCountry) then Value := TextBetween(Line, 'Titre original :' , 're :'); MonSetField(fieldCountry, formatTitre(transformCountry(deleteEnd(RemoveSpaces(UTF8Decode(findInfo(UTF8Encode('Série'), 'Gen', Value,'0')), True),'.')),GetOption('Format du Titre'))); if GetOption('ListePays') = 0 then MonSetField(fieldCountry,copy(GetField(fieldCountry), 1, pos(',',GetField(fieldCountry))-1)); // Category if CanSetField(fieldCategory) then MonSetField(fieldCategory, formatTitre(RemoveSpaces(UTF8Decode(findInfo('Genre :', '.', Line,'0')), True),GetOption('Format du Titre'))); if GetOption('ListeCategories') = 0 then MonSetField(fieldCategory,copy(GetField(fieldCategory), 1, pos(',',GetField(fieldCategory))-1)); // le producteur if CanSetField(fieldProducer) then begin Value := UTF8Decode(findInfo(UTF8Encode('Créée par '), '', Line,'0')); MonSetField(fieldProducer, formatTitre(Value,GetOption('Format du Titre'))); end; // Year if CanSetField(fieldYear) then begin Value := UTF8Decode(findInfo(UTF8Encode('Créée par '), '
', Line,'0')); Delete(Value,1,pos(' en ',Value)+length(' en ')-1); if (GetOption('Choix Date') = 1) then begin Value2 := findInfo(UTF8Encode('Première diffusion en France'), '
', Line,'0'); delete(Value2,1,length(Value2)-4); Value2 := isDate(Value2); Value := valueNotEmpty(Value2, Value); end; MonSetField(fieldYear, Value); Value := ''; Value2 := ''; end; // Length if CanSetField(fieldLength) then SetField(fieldLength, findInfo('Format : ', 'mn', Line, '0')); // Description if CanSetField(fieldDescription) then begin if pos('Synopsis :', Line) > 0 then begin MonSetField(fieldDescription, (FullTrim(UTF8Decode(findInfo('Synopsis :', '

', Line,'-1'))))); end; end; // Actors if CanSetField(fieldActors) then begin if (GetOption('Acteurs') = 1) and (GetOption('Mode Films ou Séries') = 1) then begin //MonSetField(fieldActors, formatTitre(UTF8Decode(findInfo('Avec : ', 'plus...', Line,'0')),GetOption('Format du Titre'))); MonSetField(fieldActors, FullTrim(formatTitre(UTF8Decode(findInfo('Avec : ', 'plus...', Line,'0')),GetOption('Format du Titre')))); end else if ((GetOption('Acteurs') = 2) or (GetOption('Acteurs') = 3)) and (GetOption('Mode Films ou Séries') = 1) then begin Value := ladresseduCasting(Line); castingComplet(Value); end; end; // Picture aucunAmazon := 'aucune image'; if CanSetPicture then begin if (GetOption('Choix Image') = 3) then begin imageAmazon(GetField(fieldTranslatedTitle)); returnPetiteImage(Line); end else if (GetOption('Choix Image') = 4) then begin imageAmazon(GetField(fieldTranslatedTitle)); returnPetiteImage(Line); end else if (GetOption('Choix Image') = 1) then begin returnPetiteImage(Line); end else if (GetOption('Choix Image') = 2) then begin //returnSerieImage(Line); returnPetiteImage(Line); end; end; // Initialisation de la liste des infos supplémentaires listeInfos := TStringList.Create; // Note // if (pos('noteserie&', Line) <> 0) then begin Note2 := ''; Note22 := ''; if pos('(', Line) <> 0 then // Merci Maurice Lorieu :) Avertissement := Avertissement else begin Note2 := TextBetween(Line, '>Spectateurs', '>Recommandation<'); Delete (Note2, 1 , pos(')', Note2)); Note2 := findInfo('(', ')', Note2,'0'); if (GetOption('Type de note') = 0) then Note22 := floatToStr(arrondir((convert_STF(Note2)),0)); if (GetOption('Type de note') = 1) then Note22 := floatToStr(arrondir((convert_STF(Note2)),nbDecimal)); if (GetOption('Type de note') = 2) then Note22 := FloatToStr(arrondir((calculMoyenne_2((convert_STF(Note2)),4)),0)); if (GetOption('Type de note') = 3) then Note22 := FloatToStr(arrondir((calculMoyenne_2((convert_STF(Note2)),4)),nbDecimal)); if (GetOption('Type de note') = 0) or (GetOption('Type de note') = 1) then Value2 := 'Note moyenne des téléspectateurs : ' + Note22 + '/4 ' + Value2 else Value2 := 'Note moyenne des téléspectateurs : ' + Note22 + '/10 ' + Value2; end; if CanSetField(fieldComments) and (GetOption('Detail Note') = 1) then // Détail des notes dans les commentaires begin Line2 := TextBetween(Line, 'Critiques, notes, avis des spectateurs', '
'); if pos('yenne:', Line) > 0 then // Détail et nombre de votes des spectateurs begin Value := findInfo('pour ', ' notes', Line2,'0'); Value2 := Value2+' (Pour '+Value+' notes : '; if pos('
0 then begin Delete(Line2, 1 ,Pos('
0 then begin Delete(Line2, 1 ,Pos('
0 then begin Delete(Line2, 1 ,Pos('
0 then begin Delete(Line2, 1 ,Pos('
0 then begin Delete(Line2, 1 ,Pos('
'') then SetField(fieldRating,FloatToStr(arrondir((calculMoyenne_2((convert_STF(Note22)),coefficient)),1))); if (GetOption('Detail Note') = 1) then listeInfos.Add(Value2+#13#10); end; if listeInfos.Count <> 0 then listeInfos.Add(#13#10); // Status, Episodes, Saisons if findInfo('

', '
', Line,'0') <> '' then begin Value := UTF8Decode(findInfo('

', '
', Line,'4')); Value := RemoveSpaces(findInfo('
', '
', Value, '0'), True); Value := StringReplace(Value, ',', '-'); listeInfos.Add(Value+#13#10); end; // 1ere diffusion if findInfo(UTF8Encode('Première diffusion en France'), '
', Line,'0') <> '' then begin Value := UTF8Decode(findInfo(UTF8Encode('Première diffusion'), UTF8Encode('Créée par '), Line, '4')); Value := StringReplace(Value, 'le', ':'); DiffFR := '1ère diffusion en France '+ RemoveSpaces(findInfo('en France', '
', Value, '0'), True); If pos('Première diffusion', Value) > 0 then DiffORI := '1ère diffusion '+ RemoveSpaces(findInfo('Première diffusion', '
', Value, '0'), True); listeInfos.Add(DiffFR+#13#10+DiffORI+#13#10); end; if CanSetField(fieldComments) then begin Value := ''; for i:=0 to listeInfos.Count-1 do begin Value := Value+listeInfos.GetString(i); end; SetField(fieldComments,Value); end; listeInfos.Free; // Saisons et épisodes //if pos('/seriespage_seasonepisodes_last?cseries='+ID, Line) <> 0 then if pos('/series/ficheserie-'+ID+'/saisons/', Line) <> 0 then saisonsETepisodes(urlAllocine+'/series/ficheserie-'+ID+'/saisons/'); // Secrets de Tournage if CanSetField(fieldComments) then begin if (pos('Secrets de tournage

', Line) > 0) and (GetOption('Secrets de tournage') = 1) then begin Value := Line; Value := TextBetween(Value, 'Secrets de tournage', ''); Secret := Avertissement+'Secrets de tournage :'+#13#10#13#10; BeginPos := pos('

', Value); repeat delete(Value, 1, BeginPos-1); // titre Value2 := UTF8Decode(findInfo('', '', Value,'0')); Secret := Secret+formatTitre(Value2,GetOption('Casse Choisie'))+#13#10; // secret Value2 := FullTrim(UTF8Decode(findInfo('
', '

', Value,'0'))); Secret := Secret+Value2+#13#10#13#10; delete(Value, 1, pos('', Value)); BeginPos := pos('

', Value); until (BeginPos = 0); SetField(fieldComments, GetField(fieldComments)+#13#10#13#10+Trim(Secret)); end else if (GetOption('Secrets de tournage') = 2) then begin //AdresseSecret := ladressedesSecrets(Line); // Peut être plus tard !! if Pos('Tous les secrets de tournage', Line) > 0 then AdresseSecret := urlAllocine+'/series/ficheserie-'+ID+'/secrets-tournage/'; if (AdresseSecret <> '') and (GetOption('Secrets de tournage') = 2) then begin La_liste := GetField(fieldComments)+#13#10+'Secrets de tournage :'+#13#10#13#10; numPage := 1; secretComplet(AdresseSecret); end; end; end; // Critiques Spectateurs if ((GetOption('Critiques Spectateurs') = 2) and (pos('Critiques Spectateurs', Line) > 0)) then begin Value := 'Critiques Spectateurs :'+#13#10#13#10; Ligne := Line; delete(Ligne,1, pos('Critiques Spectateurs', Ligne)+length('Critiques Spectateurs')+1); repeat // Début boucle BeginPos := pos('valign="top">

', Ligne); delete(Ligne, 1, BeginPos-1); // nom du spectateur et date Value := Value+formatTitre(findInfo('

', '

', '
', Ligne,'2'); Value2 := StringReplace(Value2, ' ', ''); Value2 := StringReplace(Value2, 'Lire la suite...', ''); Value := Value+Value2+#13#10#13#10; // Fin Boucle delete(Ligne, 1, length('valign="top">

')); BeginPos := pos('valign="top">

', Ligne); until (BeginPos = 0); SetField(fieldComments, GetField(fieldComments)+#13#10#13#10+Value); end else if (GetOption('Critiques Spectateurs') = 1) then begin panelCritiquesSpectateurs(Line); end; // Pour purger la fin des commentaires de retours à la ligne en trop Avertissement := GetField(fieldComments); repeat Avertissement := deleteEnd(Avertissement, #13#10); Until (copy(Avertissement,length(Avertissement)-length(#13#10)+1,length(Avertissement)) <> #13#10); SetField(fieldComments, Avertissement); // Pour le mode Batch if (GetOption('Fichier de log') = 0) then begin AddToLog('Nouvelle Image : '+aucunAmazon); afterUpdate(); end; // Affichage des titres si original et traduit identique titreDouble(GetOption('Titre en double')); end; //------------------------------------------------------------------------------ // NETTOIE 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; //------------------------------------------------------------------------------ // CHOIX DE LA SAISON //------------------------------------------------------------------------------ function choixSaison(listeSaison : TStringList; HS : Boolean) : string; var Value : String; begin begin PickTreeClear; //showmessage(IntToStr(listeSaison.Count)); if HS = True then PickTreeAdd('Hors Saison & Saison 1 à '+IntToStr(listeSaison.Count-1), 'all') else PickTreeAdd('Saisons 1 à '+IntToStr(listeSaison.Count), 'all'); for i:=0 to listeSaison.Count-1 do begin if (HS = True) and (i = 0) then PickTreeAdd('Hors Saison', listeSaison.GetString(i)) else if HS = True then PickTreeAdd('Saison '+IntToStr(i), listeSaison.GetString(i)) else PickTreeAdd('Saison '+IntToStr(i+1), listeSaison.GetString(i)); end; if PickTreeExec(Value) = True then result := Value else result := 'all'; end; end; //------------------------------------------------------------------------------ // SAISONS ET EPISODES //------------------------------------------------------------------------------ procedure saisonsETepisodes(adresse : String); var Value, Line, SaisonCourante, SaisonVoulue : String; listeSaison : TStringList; HS : Boolean; begin // Initialisation de la liste des saisons listeSaison := TStringList.Create; HS := False; Value := ''; sleep(timetosleep); Line := GetPage(adresse); // Création de la liste des pages de saisons SaisonCourante := adresse; // Page courante Value := findInfo('>Saisons :', '', Line,'1'); if pos('Hors saison', Value) <> 0 then HS := True; repeat //showmessage(IntToStr(listeSaison.Count)); adresse := '/series/ficheserie-'+ID+'/saison-'+findInfo('/series/ficheserie-'+ID+'/saison-', '/">', Value,'0')+'/'; if findInfo('/series/ficheserie-'+ID+'/saison-', '/', Value,'0') <> '' then listeSaison.Add(urlAllocine+adresse); Value := StringReplace(Value, adresse, ''); until findInfo('/series/ficheserie-'+ID+'/saison-', '/', Value,'0') = ''; listeSaison.Add(SaisonCourante); SaisonVoulue := ''; // Si choix possible d'une saison pop-up de demande if (GetOption('Mode Films ou Séries') = 2) and (listeSaison.Count <> 1) then SaisonVoulue := choixSaison(listeSaison, HS); if listeSaison.Count = 1 then SaisonVoulue := 'all'; // Récupération des épisodes if (GetOption('Mode Films ou Séries') = 2) and (SaisonVoulue <> 'all') then begin sleep(timetosleep); Line := GetPage(SaisonVoulue); Value := FormatSaison(Line); if (Value <> '') then SetField(fieldComments, GetField(fieldComments)+Value); // si on choisit de récupérer une saison en particulier, rajoute le numéro de saison au champ "Titre traduit" if Fulltrim(findInfo('> Saison ', '

', Line, '0')) <> '' then SetField(fieldTranslatedTitle, GetField(fieldTranslatedTitle)+' - [Saison '+Fulltrim(findInfo('> Saison ', '

', Line, '0'))+']'); if Fulltrim(findInfo('> Hors', '

', Line, '0')) <> '' then SetField(fieldTranslatedTitle, GetField(fieldTranslatedTitle)+' - [Hors saison]'); end else begin for i:=0 to listeSaison.Count-1 do begin sleep(timetosleep); Line := GetPage(listeSaison.GetString(i)); Value := FormatSaison(Line); if (Value <> '') then SetField(fieldComments, GetField(fieldComments)+Value); end; end; listeSaison.Free; // si on choisit de récupérer une saison en particulier, prend la liste des acteurs principaux de cette saison pour le champ "Acteurs" if ((GetOption('Acteurs') = 2) or (GetOption('Acteurs') = 3)) and (GetOption('Mode Films ou Séries') = 2) then begin adresse := '/series/casting_gen_cserie='+ID+'.html?'+'cseriesseason='+findInfo('plus', Line,'0'); if findInfo('plus', Line,'0') <> '' then castingComplet(urlAllocine+adresse); end; if (GetOption('Acteurs') = 1) and (GetOption('Mode Films ou Séries') = 2) then begin Value := RemoveSpaces(UTF8Decode(findInfo('Avec : ', 'plus...', Line,'0')), True); Value := StringReplace(Value, ' ,', ','); Value := copy(Value,1,length(Value)-2)+'.'; MonSetField(fieldActors, formatTitre(Value, GetOption('Format du Titre'))); end; end; //------------------------------------------------------------------------------ // RETOURNE LES INFORMATIONS DE LA SAISON //------------------------------------------------------------------------------ function FormatSaison(Line : String) : String; var Value, Titre, Acteurs, Details, Role, Acteur, liste, couple, Resume, Linebis : String; Startpos, BeginPos : Integer; begin Value := Line; // Titre saison Titre := (UTF8Decode(findInfo(UTF8Encode('Les épisodes'), '', Line,'0'))); Titre := StringReplace(Titre, '(', ' ('); Titre := StringReplace(Titre, 'de la ', ''); Titre := StringReplace(Titre, 'saison', 'Saison'); if Titre ='hors Saison' then // balises info titre différent pour les "saisons" et "hors saison" Titre :='Hors saison'; // donc si le titre ne contient rien alors c'est un "hors saison" Titre := ' --*/////////*-- '+Titre+' --*/////////*--'; // Acteurs principaux/récurrents de la saison Line := findInfo(UTF8Encode('

Acteurs récurrents de la saison

'), '', Line,'1'); BeginPos := Pos('alt=', Line); repeat delete(Line,1,BeginPos-1); Role := ''; Acteur := ''; Linebis := copy(Line,1,Pos('

', Line)+3); // pour récupérer le bon rôle avec le bon acteur. Role := FullTrim(formatTitre(UTF8Decode(findInfo(UTF8Encode('Rôle : '), '

', Linebis,'0')),GetOption('Format du Titre'))); //Acteur := formatTitre(UTF8Decode(findInfo('alt="', retourneElement(2), Line,'0')),GetOption('Format du Titre')); Acteur := formatTitre(UTF8Decode(findInfo('alt=''', '''', Linebis,'0')),GetOption('Format du Titre')); if (Role <> '') and (GetOption('Acteurs') =2) then couple := Acteur +' ('+Role+'), ' else couple := Acteur +', '; Acteurs := Acteurs + couple; delete(Line, 1, Pos('

', Line)); BeginPos := Pos('alt=', Line); until (BeginPos = 0); if Acteurs <> '' then Acteurs := 'Acteurs récurrents de cette saison : '+deleteEnd(Acteurs,', ')+'.' else Acteurs := 'Acteurs récurrents de cette saison : Aucunes infos'; // Liste des épisodes if Pos('Hors saison', Titre) > 0 then Line := Textbetween(Value, UTF8Encode('Les épisodes hors saison'), '') else Line := Textbetween(Value, UTF8Encode('Les épisodes de la saison'), ''); repeat // Si l'option avec résumé a été choisi alors on récupère les résumés if GetOption('Résumé épisodes [Partie Série]') = 0 then //Début begin Resume := findInfo('
', '
', Line, '0'); if Resume <> '' then Resume := #13#10+FullTrim(UTF8Decode(Resume))+#13#10 else Resume := #13#10+'Pas de résumé'+#13#10; end; //Fin if details <> '' then Details := Details+RemoveSpaces(UTF8Decode(findInfo('
', '
', Line, '0')), True)+Resume+#13#10 else Details := RemoveSpaces(UTF8Decode(findInfo('
', '
', Line, '0')), True)+Resume+#13#10; delete(Line, 1 , Pos('
', Line)); BeginPos := Pos('
', Line); until (BeginPos = 0); // Création de la page if (GetOption('Casting Saison [Partie Série]') = 1) then Value := #13#10+Titre+#13#10#13#10+Acteurs+#13#10#13#10+Details else Value := #13#10+Titre+#13#10#13#10+Details; result := Value; end; //------------------------------------------------------------------------------ // RETOURNE LA CRITIQUE SPECTATEURS //------------------------------------------------------------------------------ procedure panelCritiquesSpectateurs(laLigne : String); var Value, Line, ValueTemp, critique, Lurl : String; ZeroaQuatre : Integer; begin if pos(urlAllocineCriSpec, laLigne) <> 0 then Lurl := urlAllocineCriSpec else Lurl := urlAllocineCriSpecS; Value := ''; for ZeroaQuatre := 0 to 4 do begin sleep(timetosleep); if pos(Lurl+ID+'¬e='+IntToStr(ZeroaQuatre)+'.html', laLigne) <> 0 then begin Line := GetPage(urlAllocine+Lurl+ID+'¬e='+IntToStr(ZeroaQuatre)+'.html'); delete(Line, 1, pos('Critiques '+IntToStr(ZeroaQuatre)+' étoiles :', Line)-1); // nom et date ValueTemp := findInfo('

', '

', '

', Line,'2'); ValueTemp := StringReplace(ValueTemp, ' ', ''); if pos('Voir aussi : Toutes les critiques de ',ValueTemp) <> 0 then ValueTemp := copy(ValueTemp, 1, pos('Voir aussi : Toutes les critiques de ',ValueTemp)-1); critique := critique+ValueTemp; Value := critique+#13#10#13#10+Value; end; end; if Value <> '' then begin if pos(urlAllocineCriSpec, laLigne) <> 0 then SetField(fieldComments, GetField(fieldComments)+'Critiques Spectateurs :'+#13#10#13#10+Value) else SetField(fieldComments, GetField(fieldComments)+#13#10#13#10+'Critiques Spectateurs :'+#13#10#13#10+Value); end; end; //------------------------------------------------------------------------------ // ANALYSE DE LA PAGE CRITIQUES PRESSE //------------------------------------------------------------------------------ procedure critiquesPresseComplet(pageCritiques: string); var Line, LineSuivant, Value, pageSuivante, aucun :string; BeginPos, EndPos : Integer; begin // pour eviter les time-out sleep(timetosleep); // charge la page Line := GetPage(pageCritiques); LineSuivant := Line; numPage := numPage + 1; if Pos('> Critiques Presse', Line) > 0 then begin // Les critiques presses BeginPos := Pos('> Critiques Presse', Line); Line := TextBetween(Line, '> Critiques Presse', ''); BeginPos := pos('
', Line); //Delete(Line, 1, BeginPos-1); repeat // Début boucle //BeginPos := pos('

', Line); delete(Line, 1, BeginPos-1); // Journal aucun := UTF8Decode(findInfo('

', '

', Line,'0')); Value := formatTitre(aucun,GetOption('Casse Choisie')); // Note aucun := findInfo('stareval n', '0 on4', Line,'0'); Value := Value+' - Note : '+aucun+ '/4 '+#13#10; // Nom du critique aucun := UTF8Decode(findInfo('

', '

', Line,'0')); Value := Value+formatTitre(aucun,GetOption('Casse Choisie'))+#13#10; delete(Line, 1, Pos('

', Line)+3); // la critique aucun := findInfo('

', '

', Line,'2'); HTMLDecode(aucun); //aucun := UTF8Decode(findInfo('

', '

', Line,'0')); delete(aucun, 1, pos('>', aucun)); //aucun := StringReplace(aucun, ' ', ''); //if pos('Voir aussi : La revue de presse de',aucun) <> 0 then //aucun := copy(aucun, 1, pos('Voir aussi : La revue de presse de',aucun)-1); Value := Value+aucun+#13#10#13#10; // Fin Boucle delete(Line, 1, pos('

', Line)); BeginPos := pos('
', Line); // La critique dans la liste La_liste := La_liste + Value; until (BeginPos = 0); SetField(fieldComments, La_liste); // si on a plusieurs pages pageSuivante := pageCritiques; delete(pageSuivante,1,pos('.fr', pageSuivante)+2); pageSuivante := copy(pageSuivante, 1, pos('.html', pageSuivante)-1); if pos('page',pageSuivante) = 0 then begin pageSuivante := pageSuivante+'&page='+IntToStr(numPage)+'.html'; end else begin pageSuivante := copy(pageSuivante, 1, pos('&page=', pageSuivante)-1)+'&page='+IntToStr(numPage)+'.html'; end; BeginPos := pos(pageSuivante,LineSuivant); if BeginPos <> 0 then begin pageSuivante := urlAllocine+pageSuivante; critiquesPresseComplet(pageSuivante); end; end; end; //------------------------------------------------------------------------------ // RETOURNE LE LIEN VERS LA PREMIERE B.A. //------------------------------------------------------------------------------ function ladressedelaBA(Line : String) : String; var Value : String; begin if (pos('

Bandes annonces',Line) <> 0) then begin sleep(timetosleep); Line := GetPage(urlAllocine+'/video/player_gen_cmedia='+findInfo(''); Liste := ListeActeur(Line,pageCasting); end; // liste des acteurs de doublage principaux et secondaires if Pos('

Acteurs de doublage (Voix originales)

', Value) > 0 then begin Line := TextBetween(Value, '

Acteurs de doublage (Voix originales)

', '
', '>'); Line := StringReplace(Line, ' <', '<'); Line2 := Line; if Pos('Producteur', Line) > 0 then // 1er boucle pour le(s) producteur(s) begin BeginPos := Pos('Producteur', Line); repeat delete(Line, 1, BeginPos+18); if FullTrim(findInfo('', '', Line,'0')) <> '' then Producteur := Producteur+FullTrim(formatTitre(UTF8Decode(findInfo('', '', Line,'0')),GetOption('Format du Titre')))+', '; delete(Line, 1, Pos('', Line)+4); BeginPos := Pos('Producteur', Line); until (BeginPos = 0); end; if Pos('Productrice', Line2) > 0 then // 2ème boucle pour le(s) productrice(s) begin BeginPos := Pos('Productrice', Line2); repeat delete(Line2, 1, BeginPos+19); if FullTrim(findInfo('', '', Line2,'0')) <> '' then Producteur := Producteur+FullTrim(formatTitre(UTF8Decode(findInfo('', '', Line2,'0')),GetOption('Format du Titre')))+', '; delete(Line2, 1, Pos('', Line2)+4); BeginPos := Pos('Productrice', Line2); until (BeginPos = 0); end; EndPos := length(Producteur); Producteur := copy(Producteur,1,EndPos-2)+''; MonSetField(fieldProducer, formatTitre(Producteur,GetOption('Format du Titre'))); end; end; end; //------------------------------------------------------------------------------ // LISTE LES ACTEURS //------------------------------------------------------------------------------ function ListeActeur(Line: string; pageCasting: string) : string; var Role, Acteur, couple, liste, Linebis :string; BeginPos : Integer; begin sleep(timetosleep); if (GetOption('Mode Films ou Séries') = 0) then // Procedure Commune au mode Films et Séries mais différences sur les pages du site BeginPos := Pos('alt=', Line) else BeginPos := Pos('alt=', Line); liste := ''; repeat delete(Line,1,BeginPos-1); Role := ''; Acteur := ''; Linebis := copy(Line,1,Pos('

', Line)+3); // pour récupérer le bon rôle avec le bon acteur. // le role if (GetOption('Mode Films ou Séries') = 0) then // Procedure Commune au mode Films et Séries mais différences sur les pages du site Role := formatTitre(FullTrim(UTF8Decode(findInfo(UTF8Encode('Rôle : '), '

', Linebis,'0'))),GetOption('Format du Titre')) else Role := formatTitre(FullTrim(UTF8Decode(findInfo(UTF8Encode('Rôle : '), '

', Linebis,'0'))),GetOption('Format du Titre')); // le nom de l'acteur if (GetOption('Mode Films ou Séries') = 0) then // Procedure Commune au mode Films et Séries mais différences sur les pages du site Acteur := formatTitre(FullTrim(UTF8Decode(findInfo('alt=''', retourneElement(2), Linebis,'0'))),GetOption('Format du Titre')) else Acteur := formatTitre(FullTrim(UTF8Decode(findInfo('alt=''', retourneElement(2), Linebis,'0'))),GetOption('Format du Titre')); Acteur := StringReplace(Acteur, ')',''); // couple acteur (rôle) if (Role <> '') and (GetOption('Acteurs') =2) then couple := Acteur +' ('+Role+'), ' else couple := Acteur +', '; // ajout du couple dans la liste liste := liste + couple; delete(Line, 1, Pos('

', Line)); BeginPos := Pos('alt=', Line); until (BeginPos = 0); // Deuxième boucle pour les rôles secondaires if (Pos('', Line) > 0) and (pos('casting_gen_cserie',pageCasting) = 0) then begin BeginPos := Pos('', Line); repeat delete(Line, 1, BeginPos-1); Role := ''; Acteur := ''; Linebis := copy(Line,1,Pos('', Line)+4); // pour récupérer le bon rôle avec le bon acteur. // le role secondaire Role := formatTitre(FullTrim(UTF8Decode(findInfo('', '', Linebis,'0'))),GetOption('Format du Titre')); delete(Line, 1, Pos('', Line)+4); delete(Linebis, 1, Pos('', Linebis)+4); // Acteur secondaire Acteur := formatTitre(FullTrim(UTF8Decode(findInfo('', '', Linebis,'0'))),GetOption('Format du Titre')); // couple acteur (rôle) if (Role <> '') and (GetOption('Acteurs') =2) then couple := Acteur +' ('+Role+'), ' else couple := Acteur +', '; // ajout du couple dans la liste liste := liste + couple; delete(Line, 1, Pos('', Line)+4); BeginPos := Pos('', Line); until (BeginPos = 0); end; result := liste; end; //------------------------------------------------------------------------------ // ANALYSE DE LA PAGE SECRETS DE TOURNAGE //------------------------------------------------------------------------------ procedure secretComplet(pageSecret: string); var Line, LineSuivant, Titre, Texte, couple, pageSuivante :string; BeginPos, EndPos : Integer; begin //pour eviter les time-out sleep(timetosleep); //charge la page Line := GetPage(pageSecret); LineSuivant := Line; numPage := numPage + 1; if Pos('> Secrets de tournage', Line) > 0 then begin //liste des secrets Line := TextBetween(Line, '> Secrets de tournage', ''); BeginPos := Pos('
', Line); repeat delete(Line, 1, BeginPos-1); // titre Titre := UTF8Decode(findInfo('

', '

', Line,'0')); Titre := formatTitre(Titre,GetOption('Casse Choisie'))+#13#10; // secret Texte := FullTrim(UTF8Decode(findInfo('

', '

', Line,'0')))+#13#10#13#10; // couple couple := Titre+Texte; La_liste := La_liste+couple; delete(Line, 1, length('

')); BeginPos := pos('

', Line); until (BeginPos = 0); SetField(fieldComments, La_liste); // si on a plusieurs pages pageSuivante := pageSecret; delete(pageSuivante,1,pos('.fr', pageSuivante)+2); pageSuivante := copy(pageSuivante, 1, pos('.html', pageSuivante)-1); if pos('page',pageSuivante) = 0 then begin pageSuivante := pageSuivante+'&page='+IntToStr(numPage)+'.html'; end else begin pageSuivante := copy(pageSuivante, 1, pos('&page=', pageSuivante)-1)+'&page='+IntToStr(numPage)+'.html'; end; BeginPos := pos(pageSuivante,LineSuivant); if BeginPos <> 0 then begin pageSuivante := urlAllocine+pageSuivante; secretComplet(pageSuivante); end; end; end; //------------------------------------------------------------------------------ // AJOUTE UN COUPLE FILM / ADRESSE A LA LISTE DE RESULTAT //------------------------------------------------------------------------------ procedure AddMoviesTitles(Line : string); var MovieTitle, MovieTitle2, MovieAddress, aucun, annee, MessageInput, Resultat : string; StartPos, EndPos : Integer; begin //compte les résultats compteur := 0; listeResultat := TStringList.Create; if (GetOption('Mode Films ou Séries') = 0) then MessageInput := ' Films trouvés pour ' else MessageInput := ' Séries trouvés pour '; Resultat := FullTrim(findInfo('recherche :', UTF8Encode('résultat'), Line, '0')); PickTreeAdd(Resultat + MessageInput + MovieName + ' :', ''); delete(Line, 1, pos('
', Line)-1); Line := StringReplace(Line, '
', ''); repeat StartPos := pos('alt=', Line); // Pour la boucle delete(Line, 1, StartPos-1); // Pour la boucle MovieAddress := urlAllocine+findInfo('
', '', Line,'0'))); MovieTitle := findInfo('
', '', Line,'0'); MovieTitle := UTF8Decode(MovieTitle); MovieTitle := RemoveSpaces(MovieTitle, True); Delete(MovieTitle, Pos('(', MovieTitle), (Pos(')', MovieTitle))-(Pos('(', MovieTitle))+2); // si on a des informations complémentaires annee := copy(MovieTitle,length(MovieTitle2)+2,4); if IsAnneValide(annee) then begin MovieTitle := StringReplace(MovieTitle, annee+' ', ''); MovieTitle := '['+annee+'] '+MovieTitle; end; // Pour le mode batch le titre doit être "propre" listeResultat.Add(MovieTitle2+'|'+MovieAddress+'['+annee+']'); PickTreeAdd(MovieTitle, MovieAddress); delete(Line, 1, pos('', Line)); StartPos := pos('', Line); // Pour la boucle compteur := compteur+1; // Pour la boucle until (StartPos = 0); // si on a plus de résultats StartPos := pos('navcenterdata',Line); if StartPos <> 0 then begin //AdressePlus := urlAllocineSearch+'1/?p='+IntToStr(numPageR)+'&q='+UrlEncode(MovieName); //PickTreeAdd('Plus de résultats',AdressePlus); //end; numTemp := numPageR-1; strTemp := IntToStr(numTemp); if pos('/recherche/1/?p='+strTemp+'&q=',Line) <> 0 then begin AdressePrecedent := urlAllocineSearch+'1/?p='+strTemp+'&q='+UrlEncode(MovieName); PickTreeAdd('Films précédents',AdressePrecedent); end; numTemp := numPageR+1; strTemp := IntToStr(numTemp); if pos('/recherche/1/?p='+strTemp+'&q=',Line) <> 0 then begin AdresseSuivant := urlAllocineSearch+'1/?p='+strTemp+'&q='+UrlEncode(MovieName); PickTreeAdd('Films suivants',AdresseSuivant); end; end; end; // function IsAnneValide(src : String) : Boolean; var Num : String; j : Integer; begin Num := '0123456789'; for j := 1 to 4 do if (pos(copy(src,j,1), Num) = 0) then begin result := False; exit; end else result := True; end; //------------------------------------------------------------------------------ // IMPORTE GRANDE AFFICHE ALLOCINE //------------------------------------------------------------------------------ procedure returnGrandeImage(Line : String); var BeginPos, EndPos : Integer; AdresseImage : String; begin if aucunAmazon = 'aucune image' then begin if (pos('
', Line) <> 0) and (pos('AffichetteAllocine.gef', Line) =0) then begin delete(Line,1, pos('
', Line)); AdresseImage := findInfo('', Line) <> 0) and (pos('AffichetteAllocine.gef', Line) =0) then begin delete(Line,1, pos('
', Line)); AdresseImage := findInfo(' 0) and (pos('AffichetteSerieAllocine.gef', Line) =0) then begin adresse := findInfo(' > 0 then begin aucunAmazon := 'aucune image'; exit; end else if (pos('Résultats', Line) > 0) or (pos('résultats', Line) > 0) then begin StartPos := pos('', Line); delete(Line, 1, StartPos); TrouveTitle(Line, title); end; end; end; //------------------------------------------------------------------------------ // RECUPERE GRANDE IMAGE CINEFIL.COM //------------------------------------------------------------------------------ procedure imageCinefil(title : String); var CinefilBase, CinefilUrl, CinefilUrlLook, adresseRecherche, Line : String; StartPos: Integer; begin if aucunAmazon = 'aucune image' then begin CinefilBase := 'http://www.cinefil.com'; CinefilUrl := CinefilBase; {CinefilUrlLook := CinefilUrl + '/findall?CAT=FILMS&KEYWORDS='; // L'adresse de recherche à changé [modif du 28/03/07] adresseRecherche := CinefilUrlLook+UrlEncode(title); Sleep(timetosleep); Line := GetPage(adresseRecherche);} adresseRecherche := CinefilUrl+'/findall'; Line := PostPage(adresseRecherche, 'KEYWORDS='+UrlEncode(MovieName)+'&CAT=FILMS'); adresseRecherche :=TextBetween(Line, '
Films', Line) = 0 then begin aucunAmazon := 'aucune image'; exit; end else begin recupCinefil(Line, title); end; end; end; //------------------------------------------------------------------------------ // SUPPRIME LES ACCENTS //------------------------------------------------------------------------------ function supprimeAccents(NomFilm : String) : String; begin NomFilm := supprimeLesAccents(NomFilm); delete(NomFilm, pos(' - ',NomFilm), length(NomFilm)); if (pos(', ',NomFilm) > 0) then delete(NomFilm, pos(', ',NomFilm), length(NomFilm)); // Erreur ?? delete(NomFilm, pos(', ',NomFilm)+1, length(NomFilm)); delete(NomFilm, 1, pos(', ',NomFilm)+1); if (pos('(',NomFilm) > 0) then delete(NomFilm, pos('(',NomFilm), length(NomFilm)); if (pos(':',NomFilm) > 0) then delete(NomFilm, pos(':',NomFilm), length(NomFilm)); result := trim(NomFilm); end; //------------------------------------------------------------------------------ // RECUPERE L'IMAGE CINEFIL //------------------------------------------------------------------------------ procedure recupCinefil(Line, title : String); var test, lecouple, letitreCinefil, limageCinefil, temp, CinefilBase, ladresseImageCinefil : String; StartPos, i : Integer; begin CinefilBase := 'http://www.cinefil.com'; i := 0; StartPos := pos('

Films', Line); delete(Line, 1, StartPos-1); StartPos := pos('
', Line); delete(Line, 1, StartPos+43); repeat lecouple := recupTitleAdresseCinefil(Line); letitreCinefil := copy(lecouple,0,pos('|',lecouple)-1); delete(lecouple,1 , pos('|',lecouple)); limageCinefil := copy(lecouple,0,pos('||',lecouple)-1); ladresseImageCinefil := copy(lecouple,pos('||',lecouple)+2,length(lecouple)-1); test := compareTitle(title,letitreCinefil); if test = 'OK' then begin i :=i+1; Sleep(timetosleep); temp := GetPage(CinefilBase+limageCinefil+'/photos'); if pos('', Line); delete(Line, 1, StartPos+43); StartPos := pos('Avec :', Line); until (StartPos = 0) or (test = 'OK'); if (test = 'KO') and (i = 1) then begin if pos('', Line)-1); StartPos := pos('

', Line); delete(Line, 1, StartPos+3); // Titre du film CINEFILM title := copy(Line,1, pos('

', Line)-1); title := StringReplace(title, '', ''); title := StringReplace(title, '', ''); title := StringReplace(title, #13#10, ''); HTMLDecode(title); result := title+'|'+adresseCinefil+'||'+adresseImageCinefil; end; //------------------------------------------------------------------------------ // SUPPRIME LES ACCENTS DU TITRE [rajouté le 03/01/07] //------------------------------------------------------------------------------ function SansAccents(AvecAccent : String): String; var accent, noaccent : String; i : integer; begin accent := 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÌÍÎÏìíîïÙÚÛÜùúûüÿÑñÇç'; noaccent := 'AAAAAAaaaaaaOOOOOOooooooEEEEeeeeIIIIiiiiUUUUuuuuyNnCc'; for i := 1 to Length(accent) do AvecAccent := StringReplace(AvecAccent,copy(accent, i, 1),copy(noaccent, i, 1)); // Supprime tous les accents pour la recherche cinéfil result := AvecAccent; end; //------------------------------------------------------------------------------ // COPIE UNE CHAINE SUR LE DISQUE DUR [rajouté le 01/10/07] (Merci à Scorpion7552 pour cette astuce, les idées les plus simples sont souvent les meilleurs) // DumpPage(Chemin d'accès du fichier, Chaine); // Chemin d'accès du fichier = Chemin complet (ex: 'c:\temp\monfichier.txt') // note: Le répertoire (si il en existe un) doit être crée avant //------------------------------------------------------------------------------ procedure DumpPage(filePath, WholeText: string); var page: TStringList; begin page := TStringList.Create; page.Text := WholeText; page.SaveToFile(filePath); page.Free; end; //------------------------------------------------------------------------------ // ANNEE FILM COURANT POUR AMELIORER PERTINENCE CINEFIL //------------------------------------------------------------------------------ procedure anneeFilmCourant(Line : String); var EndPos : Integer; begin if pos(UTF8Encode('Année de production :'), Line) > 0 then begin lannee := findInfo(UTF8Encode('Année de production :'), '
', Line,'0'); //Delete(Line, 1, pos('Année de production : ', Line)+21); //EndPos := pos('

', Line); //lannee := '['+Trim(copy(Line, 1, EndPos -1))+']'; end; end; //------------------------------------------------------------------------------ // IMPORTE L'IMAGE AMAZON //------------------------------------------------------------------------------ procedure importAmazon(Line : String); var ImageAddress,FicheFilmAddress : String; StartPos: Integer; begin FicheFilmAddress := findInfo('', Line,'0'); Line := GetPage(FicheFilmAddress); if pos('Agrandissez cette image',Line) <> 0 then StartPos := pos('Agrandissez cette image', Line); if pos('Voir une plus grande image et d''autres vues',Line) <> 0 then StartPos := pos('Voir une plus grande image et d''autres vues', Line); delete(Line, 1, StartPos-1); ImageAddress := findInfo('src="', '"', Line,'0'); ImageAddress := StringReplace(ImageAddress, 'AA240_', ''); ImageAddress := StringReplace(ImageAddress, 'SCTHUMBZZZ', 'SCLZZZZZZZ'); ImageAddress := StringReplace(ImageAddress, 'AA240_SCLZZZZZZZ', 'SCLZZZZZZZ'); //SetField(fieldMedia, ImageAddress); // pour Auden69 ;) (il suffit de retirer les // devant SetField) Sleep(1000); GetPicture(ImageAddress); aucunAmazon := 'ok'; end; //------------------------------------------------------------------------------ // RECUPERE LE TITRE AMAZON //------------------------------------------------------------------------------ function recupTitle(Line : String) : String; var title : String; StartPos: Integer; begin StartPos := pos('', Line); delete(Line, 1, StartPos-1); title := copy(Line, 1, pos('', Line)-1); HTMLRemoveTags(title); title := StringReplace(title, #13#10, ''); result := title; 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; //------------------------------------------------------------------------------ // TROUVE LE BON TITRE SI LE PREMIER N'EST PAS LE BON //------------------------------------------------------------------------------ procedure trouveTitle(Line, title : String); var StartPos: Integer; oK : String; begin StartPos := pos('', Line); repeat {*********************** Boucle DEBUT ***********************} StartPos := pos('', Line); delete(Line, 1, StartPos+length('')-1); {*********************** Boucle DEBUT ***********************} oK := compareTitle(title,recupTitle(Line)); if oK = 'OK' then importAmazon(Line); {*********************** Boucle FIN ***********************} StartPos := pos('', Line); delete(Line, 1, StartPos+length('')-1); StartPos := pos('', Line); {*********************** Boucle FIN ***********************} until (StartPos = 0) or (oK = 'OK'); if oK = 'KO' then aucunAmazon := 'aucune image'; end; //------------------------------------------------------------------------------ // RETOURNE L'ADRESSE DES CRITIQUES PRESSE //------------------------------------------------------------------------------ function nbCritiques(Line, Note : String) : String; begin Delete(Line, 1, pos('note='+Note+'.htm', Line)+length('note='+Note+'.htm')); Line := copy(Line,1,pos('', Line)-1); if (findInfo('Les', 'critiques', Line,'0') <> '') then result := findInfo('Les', 'critiques', Line,'0') else if (pos('La critique', Line) <> 0) then result := '1' else result := '0'; end; function NotesCritiques(Line, Note : String) : String; begin //Line := copy(Line,1,pos('', Line)-1); if (findInfo('note=', '&ccritique', Line,'0') <> '') then result := findInfo('note=', '&ccritique', Line,'0') else if (pos('La critique', Line) <> 0) then result := '1' else result := '0'; end; function TitrePlus(Line : String) : String; begin if Line <> '' then begin Line := StringReplace(Line, ' ', '+'); result := Line; end; end; //------------------------------------------------------------------------------ // REMPLACE LES MOIS EN LETTRES PAR DES CHIFFRES //------------------------------------------------------------------------------ function ReplaceMonth(Month : String) : string; begin Month := AnsiLowerCase(Month); Month := StringReplace(Month, 'janvier', '01'); Month := StringReplace(Month, 'février', '02'); Month := StringReplace(Month, 'mars', '03'); Month := StringReplace(Month, 'avril', '04'); Month := StringReplace(Month, 'mai', '05'); Month := StringReplace(Month, 'juin', '06'); Month := StringReplace(Month, 'juillet', '07'); Month := StringReplace(Month, 'août', '08'); Month := StringReplace(Month, 'septembre', '09'); Month := StringReplace(Month, 'octobre', '10'); Month := StringReplace(Month, 'novembre', '11'); Month := StringReplace(Month, 'décembre', '12'); result := Month; end; //------------------------------------------------------------------------------ // PROGRAMME PRINCIPAL //------------------------------------------------------------------------------ begin if CheckVersion(3,5,0) then begin // Détecte and update si la version de StringUtils1 est bonne if StringUtils1_Version < 7 then begin if ShowWarning('Ancienne version de "Stringutils1.pas" détectée: '+IntToStr(StringUtils1_Version)+#13#10+'Ce script requiert au moins la version 7.'+#13#10+'Celle-ci va être téléchargée maintenant, continuer ?') = True then begin listeResultat := TStringList.Create; listeResultat.Text := GetPage('http://update.antp.be/amc/scripts/StringUtils1.pas'); listeResultat.SaveToFile(dirScripts + 'StringUtils1.pas'); listeResultat.Free; ShowInformation('Mise à jour effectuée. Veuillez relancer le script Allociné.'); Exit; end else begin ShowInformation('Vous pouvez télécharger la mise à jour de StringUtils1.pas en lançant "update scripts" ou via http://update.antp.be/amc/scripts'); Exit; end; end; numPageR := 1; MovieName := recupTitreRecherche(GetOption('Recherche sur le titre')); SetArrayLength(listeMessagesF,1); SetArrayLength(listeMessagesS,1); listeMessagesF[0] := urlAllocineSearchEndFilm; listeMessagesS[0] := urlAllocineSearchEndSeries; // 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 // 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 films ayant été mis à jour sont maintenant cochés'); end; // Fin if (GetOption('Type de Lancement') = 1) then begin if (GetOption('Mode Films ou Séries') = 0) then MessageInput := 'Entrez le titre du film :' else MessageInput := 'Entrez le titre de la série :'; if Input(NomScript+' by ScorEpioN',+MessageInput, MovieName) then begin if Pos(urlDomain, MovieName) > 0 then AnalyzeMoviePage(convertURL(MovieName)) else AnalyzePage(urlAllocineSearch+retourneElement(0)+UrlEncode(TitrePlus(UTF8Encode(MovieName)))); end; end else if (GetOption('Type de Lancement') = 3) then begin Sleep(timetosleep); MovieName := GetField(fieldURL); if Pos(urlDomain, MovieName) > 0 then AnalyzeMoviePage(convertURL(MovieName)); end else begin Sleep(timetosleep); AnalyzePage(urlAllocineSearch+retourneElement(0)+UrlEncode(TitrePlus(UTF8Encode(MovieName)))); end; end else ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)'); end.