', 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('
| ', 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. | | |