Page 2 of 7

Posted: 2009-07-26 18:07:51
by antp
Non pas moyen, mais il y a une fonction ListDirectory (ou qqchose dans le genre, voir dans la doc d'AMC à la rubrique Technical info -> scripting) qui offre une version simplifiée pour les recherches de fichiers.

Fonctions de creation d'enregistrement et de recherche...

Posted: 2009-07-26 18:31:31
by boyerf
bonjour,

Encore deux questions avec le langage de script :
- Existe t'il une fonction pour créer un enregistrement dans la base ?
- et une autre pour faire une recherche sur un élément (le titre d'un film par exemple) ?

Je suis en train de créer un script pour importer automatiquement des fichiers n'existant pas dans la base... La partie parcours d'une arborescence est OK, mais bêtement, je n'ai pas regardé si ces 2 fonctions étaient disponible... et j'ai l'impression que non :-(

Quelqu'un peu me confirmer ce point ?

Sinon, je vais me débrouiller pour faire un programme externe... Dans ce cas, est ce que le format de base d'AMC est standard ? (paradox, jet etc...)

A+ F

PS : je viens de voir ta réponse pour tsearchrec, je me suis débrouillé autrement, merci !

Posted: 2009-07-26 20:45:28
by antp
Le script ne peut pas parcourir/modifier la liste de films, malheureusement.
Ça fait partie des trucs que je dois rajouter, mais ça implique quelques "grosses" modifs, donc ça risque de prendre du temps à arriver.

Le format de la base n'est pas "standard", mais il est simple et documenté, donc il ne doit pas être trop difficile à manipuler dans d'autres langages.
Et pour le manipuler dans un programme écrit en Delphi c'est facile : il suffit d'utiliser fields.pas et movieclass.pas fournis avec le code d'AMC.
Sinon on peut toujours basculer en XML pour la liste, ça aussi ça peut se traiter facilement...

Posted: 2009-08-01 07:27:50
by fulvio53s03
Dear Friends,
I need a programmation Help:
In some script I found a function named 'PicktreeSort' and its meaning is almost clear but I cannot find any documentation about it.
Inserted in a script it doesn't look to function as well as I need and so I would like to know how it functions.
Would you help me?
Thanks in advance. :)

Posted: 2009-08-01 08:27:36
by fulvio53s03
Sorry, I forgot to write: is it possible to sort in descending order (withput using an escamotage of the kind 'a = 1000 - a' if we are speaking about numeric fields)?
Re-thanks.

Posted: 2009-08-01 17:37:44
by antp
It just sorts the tree. It does not take parameters so you can't have other than its default a-z sort.

Parcours d'une arborescence - function ListDirectory

Posted: 2009-08-25 14:20:02
by boyerf
Bonjour,

J'utilise la fonction ListDirectory pour parcourir une arborescence de fichier. Je sais repérer les fichier, des répertoires. Par contre, le retour de cette fonction ne me donne pas le chemin complet du fichier.

Qui a une astuce pour savoir à tout moment (ou pour reconstituer), le chemin de chacun des fichiers renvoyés par cette fonction ?

Ou alors, existe t'il un autre moyen pour parcourir une arborescence, en récupérant la liste de tous les fichiers .avi par exemple, avec leur chemin ?

Merci d'avance.
FB

PS :
J'ai pensé à utiliser :
procedure Launch(command: string; parameters: string);

Pour lancer un CD et récupérer le résultat... mais la commande ne permet pas la récupération de résultat !!! :-(

Pour lancer

Posted: 2009-08-25 19:14:46
by antp
:??: elle ne fait que faire la liste du dossier que tu lui donnes, donc normalement tu sais quand même dans quel dossier tu es

Posted: 2009-08-26 08:04:46
by boyerf
antp wrote::??: elle ne fait que faire la liste du dossier que tu lui donnes, donc normalement tu sais quand même dans quel dossier tu es
Oups, j'ai oublié de te préciser... en fait, j'ai utilisé la fonction en récursif... :

Code: Select all

//------------------------------------------------------------------------------
// Procedure de recherche dans l'arborescence - Recursive
//------------------------------------------------------------------------------
procedure scan_fb(nom_dossier : string);
var
  cpt: integer;
  ListeDir: TStringList;
  ListeLigne: TStringList;
  Ligne_originale: string;
  Ligne_parse: string;
  nom_complet_fic: string;
begin
  ListeDir := TStringList.Create;
  ListeDir.Text := ListDirectory(nom_dossier,'*.*');
  if (GetOption('Debug') = 1) then showmessage(FloattoStr(ListeDir.Count)+' lignes');
  for cpt := 0 to ListeDir.count -1 do
  begin
    // Un répertoire est trouvé
    ListeLigne := TStringList.Create;
    Ligne_originale :=  ListeDir.GetString(cpt);
    ListeLigne.text := StringReplace(Ligne_originale,tab,crlf);
    if (Listeligne.GetString(3) = 'D') and ((Listeligne.GetString(0) <> '.') and (Listeligne.GetString(0) <> '..')) then
      begin
        rep_nouveau := Listeligne.GetString(0);
        path_actuel := RechPath(rep_nouveau, path_actuel);
        if (GetOption('Debug') = 1) then showmessage(Listeligne.GetString(0)+' est un répertoire');
        if (GetOption('Debug') = 1) then showmessage(nom_dossier+Listeligne.GetString(0)+'\');
        scan_fb(nom_dossier+Listeligne.GetString(0)+'\');
      end;
    if (Listeligne.GetString(3) = '') then
    begin
      if not(subStringExist('cd2',AnsiLowerCase(Listeligne.GetString(0)))) and not(subStringExist('cd3',AnsiLowerCase(Listeligne.GetString(0)))) and not(subStringExist('cd4',AnsiLowerCase(Listeligne.GetString(0)))) then
        begin
          if (GetOption('Debug') = 1) then showmessage(Listeligne.GetString(0)+' est un fichier');
        if (subStringExist('.avi',AnsiLowerCase(Listeligne.GetString(0)))) then
          begin
          // Un film est trouvé
          cpt_films := cpt_films + 1;
          nom_complet_fic := ExtractFilePath(Listeligne.GetString(0));
          FichTransit.Append(Listeligne.GetString(0));
          scan_FichReference(Listeligne.GetString(0),Ligne_originale);
          end;
        end;
    end;
    Listeligne.free;
  End;
  ListeDir.Free;
End;
Et j'ai trouvé la solution pour récupérer les PATH de chaque répertoire... en les testant... C'est un peu lourdingue, mais ça fonctionne :

Code: Select all

//------------------------------------------------------------------------------
// Fonction de recherche du PATH courant
//------------------------------------------------------------------------------
function RechPath(xrep_nouveau, xpath_actuel: string) : string;
var
  flag_sortie, profondeur, i: integer;
  xpath_test: string;
begin
  flag_sortie := 1;
  profondeur := 1;
  xpath_test := xpath_actuel + xrep_nouveau + '\';
  while flag_sortie = 1 do
  begin
    if DirectoryExists(xpath_test) then
    begin
      xpath_actuel := xpath_test;
      flag_sortie := 0;
    end
    else
    begin
      xpath_test := xpath_actuel;
      for i := 1 to profondeur do
      begin
      xpath_test := ExcludeTrailingPathDelimiter(xpath_test);
      xpath_test := ExtractFilePath(xpath_test);
      end;
    xpath_test := xpath_test + xrep_nouveau + '\';
    profondeur := profondeur + 1;
    end;
  end;
  result := xpath_test;
end;
Bon, des que mon script est terminé, je te l'envoi...
Il a pour objectif, le scan complet d'une arborescence de fichier, pour créer un fichier d'import pour Ant Movie. Il gère un fichier de référence pour ne réimporter que les nouveaux fichiers. Il me reste à gérer les fichiers qui ont disparu.

Merci pour ton soft et pour ton aide !

FB

Posted: 2009-08-26 09:02:01
by antp
Mais "nom_dossier" doit quand même contenir le dossier actuel, non ?

Posted: 2009-08-26 09:58:41
by boyerf
antp wrote:Mais "nom_dossier" doit quand même contenir le dossier actuel, non ?
Oui oui... en fait, tu lui donnes un dossier de départ, et il recherche dans ce répertoire et tous les sous-répertoire la liste de tous les fichiers.

Posted: 2009-08-26 21:11:10
by bad4u
boyerf wrote:Il a pour objectif, le scan complet d'une arborescence de fichier, pour créer un fichier d'import pour Ant Movie.
Just an idea.. in case you use XML format for your catalogs, wouldn't it be a lot more elegant to open - and modify - the catalog file from the script ? You can open it, make a backup file (just in case something goes wrong), use internal XML parser to modify the catalog and add new movies in correct format - all using scripting. No need for importing a list and the catalog file itself is always up-to-date anyway..

Only limitation is that catalog file must be in XML format, I guess ;)

export images using scripts

Posted: 2009-08-27 12:15:11
by Hades666
Hello, i´m working in a script to export all the movie catalog data to xml files that i can use with my mkv player WDTV HD... i have no problem at all to export the text fields but i wanted to export the images too...

¿how can i export using a script the images in a folder and with a filename defined in the script?

For each movie the script make a folder (using translated title) and inside creates a .xml file ("info.xml") with the movie information... this is easy, but i also wanted to copy inside each folder the movie image with this name "folder.jpg" and i don´t know how to do this...

hope you can help me,

thanks

Posted: 2009-08-27 12:41:07
by antp
boyerf wrote: Oui oui... en fait, tu lui donnes un dossier de départ, et il recherche dans ce répertoire et tous les sous-répertoire la liste de tous les fichiers.
Mais donc il contient directement ce dont tu as besoin ? Ou j'ai loupé un truc ?

Re: export images using scripts

Posted: 2009-08-27 12:42:17
by antp
Hades666 wrote: For each movie the script make a folder (using translated title) and inside creates a .xml file ("info.xml") with the movie information... this is easy, but i also wanted to copy inside each folder the movie image with this name "folder.jpg" and i don´t know how to do this...
Impossible in current version :/
Images handling is one of the things that I have to add.

Posted: 2009-08-27 14:17:56
by Hades666
ok, :(

thanks for the information...

Posted: 2009-08-27 16:59:58
by bad4u
Hades666 wrote:¿how can i export using a script the images in a folder and with a filename defined in the script?
Maybe using HTML export function instead of scripting would be a better alternative for you. There you can export with pictures, and it should be no problem to adapt HTML export to the XML format you need. Please do not mistake with XML export (there you cannot change the format of XML file).

Just don't know if there is a way to copy single files to different folders on export, but I don't think so. So all xml files and pictures would be copied to the same folder.

Posted: 2009-08-27 17:07:35
by antp
But that folder "problem" could be solved with Ant Renamer ;)

Posted: 2009-08-28 22:13:50
by Hades666
finally i made a more complicated solution but it works for me...

I get what i wanted in 2 steps:

1) first i export all the pictures with "translatedtitle"

2) launch my script... the script first creates the folders, then move and rename the .jpg inside the right folder (with some help of 'cmd.exe' ;)) and after that generates the xml files inside each folder...

antp thanks for giving us such a good program...

bye

GetPicture with Local image files

Posted: 2009-09-01 06:08:57
by trekkie
Hello

Is There a Way to Import a picture from local hard disk files ?

I've downloaded Covers for many movies and using Shift -F7 for
Each file is cumbersome. So i tried to write a script.

I've tried a file Url 'file:///Drive:\Path\ImageFileName.jpg'

it didn't work .


Thanks in advance