(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=ScorEpioN + modifications de baffab
Title=Cinemasie.com
Description=Recherche de films asiatiques, staff, synopsis et images
Site=http://www.cinemasie.com
Language=EN,FR
Version=28 du 15/12/2009
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]
Mise à jour=1|1|0=Oui|1=Non
Langue (Français/English)=0|0|0=Français|1=English
Type de Lancement=0|0|0=Demande le titre avant de lancer le script|1=Ne demande pas le titre avant de lancer le script|2=Cherche le meilleur résultat sans confirmation|3=Lancement automatique sur l'adresse web
Casse Choisie=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
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 titres originaux=2|0|0=Titre Original|1=Titre Anglais|2=Autres titres si titre original identique à titre traduit
Recherche sur le titre=0|0|0=Traduit|1=Original
Détail des critiques=1|0|0=Aucune critique|1=Critiques Cinémasie|2=Critiques Visiteurs|3=Critiques Cinémasie & Visiteurs
Champ commentaire (critique)=1|0|0=Remplace|1=Ajoute en début|2=Ajoute en fin
Fichier de log=1|1|0=Oui|1=Non
Auto-Update=1|1|0=Oui|1=Non
***************************************************)
program CINEMASIE_SEARCH;
uses
ScorEpioNCommonScript;
const
VersionScript = '26 du 20/07/2006';
NomScript = 'CINEMASIE';
urlDomain = 'cinemasie.com';
urlBase = 'http://www.cinemasie.com';
urlBaseFR = 'http://www.cinemasie.com/fr';
urlBaseUS = 'http://www.cinemasie.com/en';
urlSearch = '/listes/recherche/recherche.php?texte=';
urlImage = '/visuels/affichettes/';
urlImage2 = '/visuels/jaqsdvd/';
var
MovieName, NomFilm, TypeExec : string;
i, premiereExecution : Integer;
listeResultat: TStringList;
listeFR, listeUS : array of string;
//------------------------------------------------------------------------------
// URL EN FRANCAIS OU EN ANGLAIS
//------------------------------------------------------------------------------
function urlBaseFRUS() : string;
begin
if (GetOption('Langue (Français/English)') = 0) then
result := urlBaseFR
else if (GetOption('Langue (Français/English)') = 1) then
result := urlBaseUS;
end;
//------------------------------------------------------------------------------
// RETOURNE ELEMENT EN FR OU EN US
//------------------------------------------------------------------------------
function retourneElement(j : Integer) : string;
begin
if (GetOption('Langue (Français/English)') = 0) then
result := listeFR[j]
else if (GetOption('Langue (Français/English)') = 1) then
result := listeUS[j];
end;
//------------------------------------------------------------------------------
// ANALYSE DE LA PAGE DE RECHERCHES
//------------------------------------------------------------------------------
procedure AnalyzePage(Address: string);
var
Line, annee, titre, titre_exact, adresse : String;
StartPos, EndPos : Integer;
begin
// Charge la page
Line := GetPage(Address);
// Traduction des champs
SetArrayLength(listeFR,6);
SetArrayLength(listeUS,6);
listeFR[0] := 'pas de résultats avec le texte entré';
listeUS[0] := 'There is no result for the text you have provided.';
listeFR[1] := 'Aucun film trouvé pour : ';
listeUS[1] := 'No result : ';
listeFR[2] := 'résultat(s) exact(s)';
listeUS[2] := 'accurate Results';
listeFR[3] := 'année';
listeUS[3] := 'year';
listeFR[4] := 'titres les plus demandés';
listeUS[4] := 'all the results';
listeFR[5] := 'tous les titres';
listeUS[5] := 'all the titles';
//teste si il y a des films trouvés
if Pos(retourneElement(0), Line) <> 0 then
begin
if (GetOption('Type de Lancement') = 0) then
begin
if Input(NomScript+' by ScorEpioN', retourneElement(1)+' pour '''+MovieName+''' :', MovieName) then
begin
if Pos(urlDomain, MovieName) > 0 then
begin
AnalysePageFilm(MovieName);
end else
begin
//remplace les caractères accentués
MovieName := supprimeLesAccents(MovieName);
MovieName := StringReplace(MovieName, ' ', '+');
AnalyzePage(urlBaseFRUS()+urlSearch+ UrlEncode(MovieName));
end;
end else
exit;
//showmessage(retourneElement(1) + MovieName)
end else
SetField(fieldChecked, '');
exit;
end else
begin
listeResultat := TStringList.Create;
// Titres exacts
if pos(retourneElement(2),Line) <> 0 then
begin
StartPos := pos(retourneElement(2), Line);
delete(Line, 1, StartPos-1);
StartPos := pos('"indpic">', Line);
delete(Line, 1, StartPos-1);
repeat
StartPos := pos('"indpic">', Line);
delete(Line, 1, StartPos-1);
titre := findInfoC('"indpic">', '', Line,'0');
adresse := urlBaseFRUS()+findInfoC('
', ' | ', Line,'0');
listeResultat.Add(annee+'|'+titre+distingueFAM(adresse)+'|'+adresse);
delete(Line, 1, length('"indpic">'));
EndPos := pos('', Line);
StartPos := pos('"indpic">', Line);
until (StartPos > EndPos);
end;
titre_exact := titre;
// Autres titres
if pos(retourneElement(4),Line) <> 0 then
begin
StartPos := pos(retourneElement(4), Line);
delete(Line, 1, StartPos-1);
StartPos := pos('"indpic">', Line);
delete(Line, 1, StartPos-1);
repeat
StartPos := pos('"indpic">', Line);
delete(Line, 1, StartPos-1);
annee := findInfoC('"indpic">', '', Line,'0');
adresse := urlBaseFRUS()+findInfoC('', '', Line,'0');
if (GetOption('Langue (Français/English)') = 0)then
titre := titre + ' ('+findInfoC('', '', Line,'0')+')';
titre := StringReplace(titre , ' ', '');
titre := StringReplace(titre , ' ', '');
titre := StringReplace(titre , '()', '');
if titre <> titre_exact then
listeResultat.Add(annee+'|'+titre+distingueFAM(adresse)+'|'+adresse);
delete(Line, 1, length('"indpic">'));
EndPos := pos('', Line);
StartPos := pos('"indpic">', Line);
until (StartPos =0);
end;
// Tous les titres
if pos(retourneElement(5),Line) <> 0 then
begin
StartPos := pos('tous les titres', Line);
delete(Line, 1, StartPos-1);
StartPos := pos('"indpic">', Line);
delete(Line, 1, StartPos-1);
repeat
StartPos := pos('"indpic">', Line);
delete(Line, 1, StartPos-1);
annee := findInfoC('"indpic">', '', Line,'0');
adresse := urlBaseFRUS()+findInfoC('', '', Line,'0');
if titre <> titre_exact then
begin
if (GetOption('Langue (Français/English)') = 0)then
titre := titre + ' ('+findInfoC('', '', Line,'0')+')';
titre := StringReplace(titre , ' ', '');
titre := StringReplace(titre , ' ', '');
titre := StringReplace(titre , '()', '');
listeResultat.Add(annee+'|'+titre+distingueFAM(adresse)+'|'+adresse);
end;
delete(Line, 1, length('"indpic">'));
EndPos := pos('', Line);
StartPos := pos('"indpic">', Line);
until (StartPos = 0);
end;
// Création de la liste de résultats
afficheResultat(MovieName);
end;
end;
//------------------------------------------------------------------------------
// CREATION DE LA LISTE DE RESULTAT
//------------------------------------------------------------------------------
procedure afficheResultat(title : String);
var
StartPos : Integer;
Texte, couple, annee, complement, titre, adresse : String;
begin
if (GetOption('Type de Lancement') = 0) or (GetOption('Type de Lancement') = 1) then
begin
PickTreeClear;
if (GetOption('Langue (Français/English)') = 0) then
Texte := 'Films trouvés pour '
else if (GetOption('Langue (Français/English)') = 1) then
Texte := 'Movies founds for ';
PickTreeAdd(Texte + title + ' :', '');
for i:=0 to listeResultat.Count-1 do
begin
couple := listeResultat.GetString(i);
annee := copy(couple,0,pos('|',couple)-1);
delete(couple, 1, length(annee)+1);
titre := copy(couple,0,pos('|',couple)-1);
delete(couple, 1, length(titre)+1);
HTMLDecode(titre);
adresse := copy(couple,0,length(couple));
delete(couple, 1, length(adresse)+1);
PickTreeAdd('['+annee+'] '+titre, adresse);
end;
if listeResultat.Count = 1 then
begin
AnalysePageFilm(adresse);
exit;
end;
begin
if PickTreeExec(adresse)=true then
begin
AnalysePageFilm(adresse);
end;
end;
end else if (GetOption('Type de Lancement') = 2) then
begin
if listeResultat.Count = 1 then
begin
couple := listeResultat.GetString(0);
annee := copy(couple,0,pos('|',couple)-1);
delete(couple, 1, length(annee)+1);
titre := copy(couple,0,pos('|',couple)-1);
delete(couple, 1, length(titre)+1);
HTMLDecode(titre);
adresse := copy(couple,0,length(couple));
delete(couple, 1, length(adresse)+1);
AnalysePageFilm(adresse);
exit;
end else
begin
trouveTitle(title);
end;
end;
end;
//------------------------------------------------------------------------------
// ANALYSE DE LA PAGE DU FILM
//------------------------------------------------------------------------------
procedure AnalysePageFilm(Address: string);
var
Value, Value2, Line, LineAux, titre_film, titre_traduit, titre_fr, titre_original, titre_anglais, autre_titre, les_titres, NoteMoy, Note1, Note2, LesCritiques, CritiqueCinemasie, CritiqueVisiteur : String;
StartPos, IntValue : Integer;
begin
//charge la page
Sleep(500);
Line := GetPage(Address);
// Pour le mode Batch
if (GetOption('Fichier de log') = 0) then
beforeUpdate();
// Traduction des champs
SetArrayLength(listeFR,16);
SetArrayLength(listeUS,16);
listeFR[0] := 'Titre Anglais';
listeUS[0] := 'English Title';
listeFR[1] := 'Titre Original';
listeUS[1] := 'Original Title';
listeFR[2] := 'Titre Français';
listeUS[2] := 'French Title';
listeFR[3] := 'Année';
listeUS[3] := 'Year';
listeFR[4] := 'pays';
listeUS[4] := 'Country';
listeFR[5] := 'réalisateur';
listeUS[5] := 'director';
listeFR[6] := 'interprète';
listeUS[6] := 'actor';
listeFR[7] := 'producteur';
listeUS[7] := 'producer';
listeFR[8] := 'genres';
listeUS[8] := 'Genre';
listeFR[9] := 'Durée';
listeUS[9] := 'Duration';
listeFR[10] := 'Scénario';
listeUS[10] := 'Synopsis';
listeFR[11] := 'notes';
listeUS[11] := 'grades';
listeFR[12] := 'Moyenne';
listeUS[12] := 'average';
listeFR[13] := 'Critiques';
listeUS[13] := 'Reviews';
listeFR[14] := 'textes';
listeUS[14] := 'texts';
listeFR[15] := 'Visiteurs';
listeUS[15] := 'Visitors';
// Les Titres
//titre_original := StringReplace(findInfoC(retourneElement(1), '', Line,'0'), ' ', '');
titre_film := StringReplace(findInfoC('', '', Line,'0'), ' ', '');
titre_anglais := StringReplace(findInfoC(retourneElement(0), '', Line,'0'), ' ', '');
titre_original := StringReplace(findInfoC(retourneElement(1), '', Line,'0'), ' ', '');
titre_fr := StringReplace(findInfoC(retourneElement(2), '', Line,'0'), ' ', '');
autre_titre := StringReplace(findInfoC('autres titres', '', Line,'0'), ' ', '');
// Titre Traduit
if CanSetField(fieldTranslatedTitle) then
begin
if titre_fr <> '' then
les_titres := titre_fr
else if titre_anglais <> '' then
les_titres := titre_anglais
else if titre_film <> '' then
les_titres := titre_film
else if deleteAsianChar(titre_original) <> '' then
les_titres := deleteAsianChar(titre_original);
titre_traduit := formatTitre(Trim(les_titres),GetOption('Casse Choisie'));
MonSetField(fieldTranslatedTitle, titre_traduit);
end;
// Titre Original
if CanSetField(fieldOriginalTitle) then
begin
// tests les titres :
if (GetOption('Choix titres originaux') = 0) then
begin
if deleteAsianChar(titre_original) <> '' then
les_titres := deleteAsianChar(titre_original)
else if titre_anglais <> '' then
les_titres := titre_anglais
else if autre_titre <> '' then
les_titres := autre_titre;
end else
if (GetOption('Choix titres originaux') = 1) then
begin
if titre_anglais <> '' then
les_titres := titre_anglais
else if titre_original <> '' then
les_titres := deleteAsianChar(titre_original)
else if autre_titre <> '' then
les_titres := autre_titre;
end else
if (GetOption('Choix titres originaux') = 2) then
begin
if (trim(AnsiLowerCase(titre_traduit)) <> trim(AnsiLowerCase(titre_original))) and (titre_original <> '') then
les_titres := deleteAsianChar(titre_original)
else if autre_titre <> '' then
les_titres:= autre_titre
else
les_titres:= titre_anglais;
end;
les_titres := formatTitre(Trim(les_titres),GetOption('Casse Choisie'));
MonSetField(fieldOriginalTitle, les_titres);
end;
// Année
if CanSetField(fieldYear) then
MonSetField(fieldYear, StringReplace(findInfoC(retourneElement(3), '', Line,'0'), ' ', ''));
// Pays
if CanSetField(fieldCountry) then
begin
Value := findInfoC(retourneElement(4), '
', Line,'-1');
Value := StringReplace(Value, RC, ', ');
Value := StringReplace(Value, ' ', '');
MonSetField(fieldCountry, deleteEnd(Value, ', , '));
end;
// Réalisateur
if CanSetField(fieldDirector) then
begin
Value := findInfoC(retourneElement(5), 'interprète', Line,'1');
Value := StringReplace(Value, '', ' (');
Value := StringReplace(Value, '', '), ');
Value := StringReplace(Value, ' (), ', ', ');
Value := StringReplace(Value, ' ', '');
Value := coupeInfo('', '
', '', Value);
Value := StringReplace(Value, ' - ', '');
Value := StringReplace(Value, ' ', ' ');
Value := StringReplace(Value, ' ', ' ');
Value := deleteEnd(formatTitre(Value,GetOption('Casse Choisie')), ',');
MonSetField(fieldDirector, Value);
end;
// Acteurs
if CanSetField(fieldActors) then
begin
Value := findInfoC(retourneElement(6), retourneElement(7), Line,'1');
if (Value = '') then Value := findInfoC(retourneElement(6), 'compositeur', Line,'1');
if (Value = '') then Value := findInfoC(retourneElement(6), 'scénariste', Line,'1');
if (Value = '') then Value := findInfoC(retourneElement(6), '', Line,'1');
Value := StringReplace(Value, '', ' (');
Value := StringReplace(Value, '', '), ');
Value := StringReplace(Value, ' (), ', ', ');
Value := StringReplace(Value, ' ', '');
Value := coupeInfo('', '
', '', Value);
Value := StringReplace(Value, ' - ', '');
Value := StringReplace(Value, ' ', ' ');
Value := StringReplace(Value, ' ', ' ');
Value := Trim(deleteEnd(formatTitre(Value,GetOption('Casse Choisie')), ','))+'.';
if Value <> '.' then
MonSetField(fieldActors, Value);
end;
// Producteur
if CanSetField(fieldProducer) then
begin
Value := formatTitre(StringReplace(findInfoC(retourneElement(7), '', Line,'0'), ' ', ''),GetOption('Casse Choisie'));
Value := StringReplace(Value, ' - ', ', ');
Value := deleteEnd(Value, ', ');
Value := deleteEnd(Value, ' -');
MonSetField(fieldProducer, Value);
end;
// Adresse Web
if CanSetField(fieldURL) then
SetField(fieldURL, Address);
// Durée
if CanSetField(fieldLength) then
begin
Value := findInfoC(retourneElement(9)+'', ' | ', Line,'0');
if pos('m', Value)>0 then
begin
IntValue := 0;
delete(Value,pos('m',Value),length(Value));
IntValue := IntValue + StrToInt(trim(Value), 0);
end else
begin
IntValue := StrToInt(copy(Value, 1, 1), 0) * 60;
if pos('H', Value)>0 then
delete(Value,1,pos('H', Value))
else if pos('h',Value)>0 then
delete(Value,1,pos('h', Value));
if pos(' ',Value)>0 then
delete(Value,pos(' ', Value),length(Value));
Value := copy(Value, 1, length(Value));
Value := StringReplace(Value, ' ', '');
IntValue := IntValue + StrToInt(Value, 0);
end;
if IntValue>0 then
MonSetField(fieldLength, IntToStr(IntValue));
end;
// Genre
if CanSetField(fieldCategory) then
begin
Value := findInfoC(retourneElement(8), '', Line,'-1');
Value := StringReplace(Value, RC, ', ');
Value := StringReplace(Value, ' ', '');
MonSetField(fieldCategory, formatTitre(deleteEnd(Value, ', , '),GetOption('Casse Choisie')));
end;
// Image
if CanSetPicture then
begin
Sleep(400);
if findInfoC(urlImage, '"', Line,'0') <> '' then
MonGetPicture(urlBase+urlImage+findInfoC(urlImage, '"', Line,'0'))
else if findInfoC(urlImage2, '"', Line,'0') <> '' then
MonGetPicture(urlBase+urlImage2+findInfoC(urlImage2, '"', Line,'0'));
end;
// L'histoire
if CanSetField(fieldDescription) then
begin
Value := findInfoC(retourneElement(10), '', Line,'0');
Value := StringReplace(Value, ' ', '');
if pos('This text does not yet exist, please click on ', Value) = 0 then
MonSetField(fieldDescription, Value);
end;
// Critiques et notes
Note1 := '0';
Note2 := '0';
LesCritiques := '';
CritiqueCinemasie := '';
CritiqueVisiteur := '';
if pos('critiques.html', Line) <> 0 then
begin
// --- Charge la page ---
Sleep(400);
Line := GetPage(Address+'critiques.html');
Line := StringReplace(Line, '’', '''');
Line := StringReplace(Line, '…', '...');
Line := StringReplace(Line, 'œ', 'oe');
Line := StringReplace(Line, '–', '-');
// --- Récupérer la moyenne globale ---
Value := findInfoC(retourneElement(12), '/5', Line,'0');
NoteMoy := Value;
// --- Nombre de critiques et moyenne ---
if (length(Value)>0) then
Value2 := Value2+retourneElement(12)+' : '+Value+'/5 ' + RCN(2);
LineAux := findInfoC('', ''0') then
begin
Value := findInfoC('critiques:', '/5', LineAux,'0');
Value2 := Value2 + ', moyenne : ' + Value + '/5 ';
end;
Value2 := Value2 + RCN(1);
LineAux := findInfoC('', '', LineAux, '1');
Value := findInfoC('vos avis', 'critiques', LineAux,'0');
Value2 := Value2+ 'Visiteurs : ' + Value + ' notes';
LineAux := findInfoC('', '', LineAux, '1');
if (Value<>'0') then
begin
Value := findInfoC('critiques:', '/5', LineAux,'0');
Value2 := Value2+ ', moyenne : ' + Value + '/5 ';
end;
Value2 := Value2 + RCN(2);
//Note1 := Value;
//Value2 := Value2+retourneElement(12)+' : '+NoteMoy+'/5 ';
if ((GetOption('Détail des critiques') = 1) or (GetOption('Détail des critiques') = 3)) then
// --- Récupérer les critiques cinémasie ---
begin
if pos('