Command line support

Comments on existing version & Suggestions for future versions. If you want a new feature suggest it here. Discussions about beta versions also come in this section.
Post Reply
Willspo
Posts: 61
Joined: 2002-08-14 15:50:23

Command line support

Post by Willspo »

Hi,
I was thinking it might be good if you could run movie catalog from the command line to export to a template for example. That way the template could call the program to update the movielist and you would always have a fresh list. :ha: Or maybe if you could access the .amc file right away like a db?
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

I planned to add that, but I reported it to later.
If somebody wants to make a program that exports the amc file, I can give the file needed for that : it is simple two .PAS file (Delphi 6) that gives you TMovie and TMovieList classes allowing to browse the amc file.
Willspo
Posts: 61
Joined: 2002-08-14 15:50:23

Post by Willspo »

Can you mail the two files to me?
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Sure.
I'll do that this evening ;)
LA
Posts: 14
Joined: 2006-08-09 07:08:46
Location: Russia, Moscow

Post by LA »

hi [b]antp[/b]!
do you still have command-line support in your plans?
I think it is one-two hours exersice :)
Please add the following features there (with regards to input):
- option to add new item (new movie)
- full path to file with possibility to extract video info from it (like when drag&drop the file now)
- possibility to assign value to each field
- save and exit

For ex., I have file D:\Movies\New Good Movie.[LA].avi
Usage of amc.exe can be like
amc.exe -n -file:"D:\Movies\New Good Movie.[LA].avi" -fieldMovieName:"New Good Movie" -fieldMedia:"D:\Movies\" -x
where -n - add new record
-file - extract video info from file
-fieldFieldName - add into into FieldName
-x - save and exot
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

There are so many things in my to-do list that I could do in 1 or 2 hours :D That one does not have an especially high priority. Couldn't it be made with some automation tool?
LA
Posts: 14
Joined: 2006-08-09 07:08:46
Location: Russia, Moscow

Post by LA »

command line support is very useful item!
I've done first step, which will probably encourage you to add this feature in next version of AMC :)

Here is the code, which supports command line:
(I've used getopt component)

Code: Select all

uses
  ...
  getoptlib, // LA edition
  ...

procedure TMainWindow.FormShow(Sender: TObject);
var
  s, FileToOpen: string;
  CmdLineValue, CmdLineOptionIndex: integer; // LA edition
const
    CmdLineParametersList : array [0..10] of option =         // LA edition
      (
      	( name:'moviefile';         has_arg:required_argument;       flag:nil; val:0 ),
       	( name:'fTranslatedTitle';  has_arg:required_argument;       flag:nil; val:1 ),
       	( name:'fDirector';         has_arg:required_argument;       flag:nil; val:2 ),
       	( name:'fYear';             has_arg:required_argument;       flag:nil; val:3 ),
       	( name:'fCountry';          has_arg:required_argument;       flag:nil; val:4 ),
       	( name:'fActors';           has_arg:required_argument;       flag:nil; val:5 ),
       	( name:'fDescription';      has_arg:required_argument;       flag:nil; val:6 ),
       	( name:'fProducer';         has_arg:required_argument;       flag:nil; val:7 ),
       	( name:'fOriginalTitle';    has_arg:required_argument;       flag:nil; val:8 ),
      	( name:'fMedia';            has_arg:required_argument;       flag:nil; val:9 ),
       	( name:'fURL';              has_arg:required_argument;       flag:nil; val:10 )
      );

begin
  SplashWin.ProgressBar1.Position := 60;
  LoadOptions;
  SplashWin.ProgressBar1.Position := 60;
  ApplyLanguage;
  SplashWin.ProgressBar1.Position := 70;
  Application.ProcessMessages;
  SplashWin.Release;
  SplashWin := nil;
  FCatalogFile.Modified := False;
  with Settings.rOptions.rFiles do
    if (AutoLoad) and (AutoLoadFile <> '') then
      FileToOpen := AutoLoadFile
    else
      FileToOpen := '';
//  if ParamCount > 0 then                  // LA edition - removed
//  begin                                   // LA edition - removed
//    s := ParamStr(1);                     // LA edition - removed
//    if (s <> '') and (s[1] <> '/') then   // LA edition - removed
//      FileToOpen := s;                    // LA edition - removed
//  end;                                    // LA edition - removed
  if FileToOpen <> '' then
    FCatalogFile.Open(ExpandFileName(FileToOpen))
  else
    FCatalogFile.New;

  if ParamCount > 0 then                  // LA edition
  begin

    if FindCmdLineSwitch('a',['-'], true) then
         ActionMovieAddExecute(nil); // this action may ask user for new movie number

    while CmdLineValue <> EOF_getopt do
    begin
      CmdLineOptionIndex := 0;
      try
        CmdLineValue := getopt_long( argc, argvptr^, 'a', CmdLineParametersList, CmdLineOptionIndex);
        case CmdLineValue of
          0: if GetInfoFromMediaFile(optarg, FrmMovie) then
             begin
               FrmMovie.Modified := True;
               OnMovieFieldChange(Self);
             end;
          1: FrmMovie.ETranslatedTitle.Text := optarg;
          2: FrmMovie.EDirector.Text := optarg;
          3: FrmMovie.EYear.Text := optarg;
          4: FrmMovie.ECountry.Text := optarg;
          5: FrmMovie.EActors.Text := optarg;
          6: FrmMovie.EDescription.Text := optarg;
          7: FrmMovie.EProducer.Text := optarg;
          8: FrmMovie.EOriginalTitle.Text := optarg;
          9: FrmMovie.EMedia.Text := optarg;
          10: FrmMovie.EURL.Text := optarg;
        end;
      except
      end;
    end;

    if FindCmdLineSwitch('s',['-'], true) then
         FCatalogFile.Save;

    if FindCmdLineSwitch('e',['-'], true) then
         ActionExitExecute(nil);

  end;
end;

(I am not specialist in a coding, so, I've just chosen the easiest code... there is no good handling of errors etc. But it works.)


The following parameters in command line are supported:
-a add new item in the list (there is no sense to use command line w/o this parameter really - data will be written in frame, which doesn't belong to any movie)
-s save catalog
-x exit AMC
--moviefile file from which media info should be imported (long values and values with spaces should be passed in brackets, for ex. --moviefile="C:\Program Files\my movie.avi")
--fTranslatedTitle
--fDirector
--fYear
--fCountry
--fActors
--fDescription
--fProducer
--fOriginalTitle
--fMedia
--fURL
assing value to according field (for ex. --fOriginalTitle="The Movie")
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks, I'll check that. I am not sure that adding again one more component is a very good idea (users already complain that there are too many :D)
LA
Posts: 14
Joined: 2006-08-09 07:08:46
Location: Russia, Moscow

Post by LA »

otherwise you'll have to write your own function to parse command line.. there is no sense to do it since it is already exists. moreover, getopt one of the best (at least, I was told so :))
and, does it really matter for USERS how many components you used?
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

For those that want to recompile the code, I mean.
And I do not like much having lots of dependencies.
Though that if it is just a .pas file to include and not a VCL to register it is not a problem.
LA
Posts: 14
Joined: 2006-08-09 07:08:46
Location: Russia, Moscow

Post by LA »

hehe :)
looks like you are talking about me - I was asking a few days ago about compiling of your project :)
do you have a lot of users trying to compile your project? :)

but really this is just one .pas file...



off top: why there is google ad:
[quote]Got a movie collection? - AMC is good but we have a better
alternative named All My Movies. www.bolidesoft.com[/quote]
looks strange...
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

You were not the first one to ask help for compiling it ;)

About the ad, indeed it may look strange, but in a way the fact that their ad show here means that they give me money for that (as when users click, Google gives me a part of what the software company has to pay to Google)
LA
Posts: 14
Joined: 2006-08-09 07:08:46
Location: Russia, Moscow

Post by LA »

hi, [b]antp[/b]!
were you able to test my code? :)
I've noticed one strange thing - when I compile the project (either with my code or without it) [u]some[/u] my scripts stop to work - I am getting err msgs like 'connection refused' or 'bad request', but when I use your compiled version, the same scripts work fine. Any idea what can be the reason? Have I installed Delphi or some components incorrectly?
If you have time, could you please compile the project on your machine with my code and place result exe on some rapidshare.com site for my verification? Thank you
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Sorry I did not had time yet.

This error that you have is interesting: it may be caused by a different version of the Indy library (I do not really see what else :??:). Which version do you have?
Tyrell66
Posts: 3
Joined: 2008-04-30 09:00:49
Location: Belgium

Another usefull command-line option

Post by Tyrell66 »

Hello antp,

Another great command-line option would be to run an export command.

Something like amc.exe -e \\webserver\webroot\dvd-php\autoimp\dvd.sql -t sql
where -e filename would be export to filename & -t sql the type of export.

That would allow AMC users to run a scheduled task to daily/weekly export their database.

Thanks for considering it...
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

command-line export is still on my to-do list (I know, I already said few years ago that it was planned... :/)
LA
Posts: 14
Joined: 2006-08-09 07:08:46
Location: Russia, Moscow

Post by LA »

Hi!

hope, you've implemented command line support ;)
checking my backups now and wanted to delete the source code of my version of AMC with command line support ;)
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Hi
... still on the to do list.
I haven't really worked on AMC since then.
I doubt that in the next months/year I'll have time to work on that. I already do not know when I'll make the most urgent feature: good compatibility with Vista/7...
Post Reply