diff options
author | Guilhem Moulin <guilhem.moulin@ens-lyon.org> | 2012-02-17 21:11:35 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem.moulin@ens-lyon.org> | 2012-02-17 21:13:11 +0100 |
commit | 2764618fb5825840466e6f003ec6df5e8ccdfe5e (patch) | |
tree | f39085d00deafbbea192aeb37801e8fe4f3bbaf5 | |
parent | 653e1ff8bbd9307920cb933d4cb766179d3c3812 (diff) |
support of extra connections options (eg, ssl)
-rwxr-xr-x | videoadd.pl | 30 | ||||
-rwxr-xr-x | videodb-check.pl | 5 | ||||
-rw-r--r-- | videodb.rc | 4 | ||||
-rwxr-xr-x | videomv.pl | 5 | ||||
-rwxr-xr-x | videorm.pl | 5 |
5 files changed, 45 insertions, 4 deletions
diff --git a/videoadd.pl b/videoadd.pl index add8f2a..b1ebb0f 100755 --- a/videoadd.pl +++ b/videoadd.pl @@ -48,8 +48,8 @@ $config{url} =~ s/\/*$//; my $ignoredb_flag; my $sort_flag = 1; my %options; -GetOptions( "seen" => sub { $options{seen} = 1 } - , "s|search=s"=> sub { $imdb{crit} = $_[1] } +GetOptions( #"seen" => sub { $options{seen} = 1 } + "s|search=s"=> sub { $imdb{crit} = $_[1] } # , "u|update=s"=> update id/filename , "o=s" => sub { my ($k,$v) = split /=/, $_[1], 2; $options{lc $k} = $v; } @@ -74,6 +74,11 @@ my $dbh; unless ( defined $ignoredb_flag ) { # Connect to database my $dsn = "DBI:$config{driver}:database=$config{database};host=$config{hostname};port=$config{port}"; + if (exists $config{dbi_misc}) { + while (my ($k,$v) = each $config{dbi_misc}) { + $dsn .= ";$k=$v"; + } + } $dbh = DBI->connect($dsn, $config{user}, $config{password}) or die "Error: Can't connect do database.\n"; $dbh->do( "SET NAMES UTF8" ) or die "Error: Can't set names to UTF-8.\n"; @@ -207,7 +212,8 @@ if ( defined($file) ) { unless ( defined $ignoredb_flag ) { my $INSERT = "INSERT INTO $config{videodata} - SET mediatype = 14"; + SET mediatype = 14, + created = NOW()"; if (defined $new{filedate}) { $INSERT .= ", filedate = FROM_UNIXTIME($new{filedate})"; delete $new{filedate}; @@ -241,7 +247,23 @@ unless ( defined $ignoredb_flag ) { if ( defined ($file) and defined ($sort_flag) ) { if (defined $new{director}) { - move ( $file, catfile ( $directors, $new{director}, $new{filename} ) ) + my $dir = catdir ( $directors, $new{director} ); + unless (-d $dir) { + print STDERR "Directory `$dir' does not exist. "; + until (-d $dir) { + print STDERR "Should I create it? (Y/n) "; + my $a = lc <STDIN>; + chomp $a; + if ($a eq 'y' or $a eq '') { + mkdir $dir + or die "Error: Cannot mkdir `$dir': $!\n"; + } + elsif ($a eq 'n') { + exit 0; + } + } + } + move ( $file, catfile ( $dir, $new{filename} ) ) or warn "Warning: Cannot move file: $!.\n"; symlink catfile( updir(), 'DIRECTORS', $new{director}, $new{filename} ), diff --git a/videodb-check.pl b/videodb-check.pl index 8acff46..11c5de2 100755 --- a/videodb-check.pl +++ b/videodb-check.pl @@ -134,6 +134,11 @@ if (@ARGV) { # Connect to database my $dsn = "DBI:$config{driver}:database=$config{database};host=$config{hostname};port=$config{port}"; +if (exists $config{dbi_misc}) { + while (my ($k,$v) = each $config{dbi_misc}) { + $dsn .= ";$k=$v"; + } +} my $dbh = DBI->connect($dsn, $config{user}, $config{password}) or die "Can't connect do database\n"; $dbh->do( "set names utf8" ) or die; @@ -9,6 +9,10 @@ database => 'videodb', hostname => '127.0.0.1', user => 'username', port => 3306, +# Optional extra connection options +dbi_misc => { mysql_ssl => 1 + , mysql_ssl_ca_file => "/etc/ssl/certs/cacert.org.pem" + }, password => '******', videodata => "videodb_videodata", imdb => 'akas.imdb.com', @@ -379,6 +379,11 @@ my @real_directors = splitdir($real_directors); my ($dsn, $dbh, $RES, $nRES, $id); unless (defined $ignoredb_flag) { $dsn = "DBI:$config{driver}:database=$config{database};host=$config{hostname};port=$config{port}"; + if (exists $config{dbi_misc}) { + while (my ($k,$v) = each $config{dbi_misc}) { + $dsn .= ";$k=$v"; + } + } $dbh = DBI->connect($dsn, $config{user}, $config{password}) or die "Can't connect do database"; $dbh->do( "set names utf8" ) or die; @@ -161,6 +161,11 @@ if (-l $file_s) { # Connect to database my $dsn = "DBI:$config{driver}:database=$config{database};host=$config{hostname};port=$config{port}"; +if (exists $config{dbi_misc}) { + while (my ($k,$v) = each $config{dbi_misc}) { + $dsn .= ";$k=$v"; + } +} my $dbh = DBI->connect($dsn, $config{user}, $config{password}) or die "Can't connect do database.\n"; $dbh->do( "set names utf8" ) or die; |