From ec40b5aaa8fe19ecfeacb1936de4a035801797ac Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Thu, 1 Mar 2012 18:08:10 +0100 Subject: doc --- videoadd.pl | 74 +++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 31 deletions(-) (limited to 'videoadd.pl') diff --git a/videoadd.pl b/videoadd.pl index 15c9044..fadc7f1 100755 --- a/videoadd.pl +++ b/videoadd.pl @@ -9,14 +9,12 @@ $VERSION = "0.3, 01 March 2012"; -use Getopt::Long qw/:config noauto_abbrev nogetopt_compat no_ignore_case - permute bundling auto_version auto_help/; +use Getopt::Long qw/:config noauto_abbrev no_ignore_case + gnu_compat bundling permute nogetopt_compat + auto_version auto_help/; use Pod::Usage; -use IMDB::Film; use Locale::Language qw /code2language LOCALE_LANG_ALPHA_2 LOCALE_LANG_ALPHA_3/; -use DBI; - use IPC::Open3; use File::Basename qw /basename/; use File::Spec::Functions; @@ -51,13 +49,13 @@ $config{url} =~ s/\/*$//; =head1 NAME -videoadd.pl - add movies to your collection +videoadd.pl - add/update movies to your collection =head1 SYNOPSIS B [B<-s>] [B<-u>] [B<--ignore-db>] [B<--dont-move>] [B<--force>] [B<-i> I] [B<-o> I...] [B<--only=>I...] [B<--exclude=>I...] -[B<-q>] (I|I|I<id>|I<IMDBID>) +[B<-q>] (I<filename>|I<title>|I<id>|I<IMDbID>) =head1 DISCLAIMER @@ -84,19 +82,27 @@ not verify these conventions! =head1 DESCRIPTION -B<videoadd.pl> add the given movie to your collection. Various data such -as the movie length, the A/V codecs, etc. are read from the metadata of -the movie. One can fetch other data (e.g., year, director, cast, etc.) -from IMDB (option B<-i>). If there is a clash (e.g., language) the metadata -take precedence. -The database is then updated with the new movie (unless B<--ignore-db> -is set), which in turn is put in the right place of the above hierarchy -(unless B<--dont-move> is set). - -The argument is matched against the file names, titles, IDs and IMDBIDs -of the database. If matching entries are found, then the user is -prompted to choose an entry to update. In that case, the hierachy -remains unchanged. +C<videoadd.pl arg> starts by trying to match I<arg> against the +IDs or IMDb IDs (if I<arg> contains only digits), +filenames (if I<arg> has a known video extension), or +titles (with wildcards; succeeds if I<args> is contained in a title) +of the database. + +If matching entries are found, then the user is prompted to choose for +an entry to update, or to ignore these entries. In the former case, the +above file hierachy remains unchanged and the database is merely updated +with the new retrieved data. In the later case, B<videoadd.pl> acts as +below. + +If no matching entry is found, I<arg> should be an existing file, and +the correspoding movie is added to the collection. +Various data such as the movie length, the A/V codecs, etc. are read +from the metadata of I<arg> via B<mplayer>. +One can fetch other data (e.g., year, director, cast, etc.) from IMDb +(option B<-i>). If there is a clash (e.g., language) the metadata take +precedence. The database is then updated with the new movie +(unless B<--ignore-db> is set), which in turn is put in the right place +of the above file hierarchy (unless B<--dont-move> is set). =head1 OPTIONS @@ -109,6 +115,8 @@ Mark the movie as seen for the I<userid> of the configuration file. =item B<-u>, B<--unseen> Mark the movie as unseen for the I<userid> of the configuration file. +(This flag is ignored unless the action is to update an existing movie +in the database) =item B<--ignore-db> @@ -123,19 +131,19 @@ Note that it may break the sanity of your collection. =item B<--force> -Do not ask the user before uptading existing entries in the database. If -more that one matching entry is found while [B<--force>] is set, -B<videoadd.pl> exists with a non-zero status. +Do not ask the user before updating existing entries in the database. If +more that one matching entry is found while B<--force> is set, +B<videoadd.pl> exits with a non-zero status. =item B<-i> I<crit>, B<--imdb=>I<crit> -Search for the given criterion (e.g., a movie title or an IMDB ID) on -IMDB. The retrieved data (such as year, director, cast, etc.) will be +Search for the given criterion (e.g., a movie title or an IMDb ID) on +IMDb. The retrieved data (such as year, director, cast, etc.) will be added to the database (unless overriden by B<-o> I<key=value>). =item B<-o> I<key=value>, B<--option=>I<key=value> -Override data from IMDB with the I<value> provided. +Override data from IMDb with the I<value> provided. Valid I<key>s are I<title>, I<language >, I<imdbid>, I<year>, I<imgurl>, I<director>, I<genres>, I<country>, I<plot>, I<rating>, I<istv>. @@ -174,7 +182,7 @@ details. =item B<-q>, B<--quiet> -Do not print the final URL for the freshly added movie. +Do not print the final URL for the freshly added/updated movie. =back @@ -240,6 +248,8 @@ pod2usage(2) if $#ARGV != 0; my $dbh; unless ( defined $ignoredb_flag ) { + use DBI; + # Connect to database my $dsn = "DBI:$config{driver}:database=$config{database};host=$config{hostname}"; $dsn .= ";port=$config{port}" if defined $config{port}; @@ -261,15 +271,17 @@ my %new = ( owner_id => $config{userid} ################################################################################ # Look on-line for information on the movie -if ( defined ($imdb{crit}) and &runIMDB() ) { - # Look up the title/ID on IMDB +if ( defined ($imdb{crit}) and &runIMDb() ) { + # Look up the title/ID on IMDb + + use IMDB::Film; my $single; my $movie; do { $movie = new IMDB::Film(%imdb); - die "IMDB: " .$movie->error. "\n" + die "IMDb error: " .$movie->error. "\n" unless $movie->status; my @matches = @{$movie->matched}; @@ -712,7 +724,7 @@ sub include { return 1; } -sub runIMDB { +sub runIMDb { # Returns 1 if there is need to retrieve some data online, 0 otherwise foreach (qw/title subtitle language imdbid year imgurl -- cgit v1.2.3