summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem.moulin@ens-lyon.org>2012-02-17 21:11:35 +0100
committerGuilhem Moulin <guilhem.moulin@ens-lyon.org>2012-02-17 21:13:11 +0100
commit2764618fb5825840466e6f003ec6df5e8ccdfe5e (patch)
treef39085d00deafbbea192aeb37801e8fe4f3bbaf5
parent653e1ff8bbd9307920cb933d4cb766179d3c3812 (diff)
support of extra connections options (eg, ssl)
-rwxr-xr-xvideoadd.pl30
-rwxr-xr-xvideodb-check.pl5
-rw-r--r--videodb.rc4
-rwxr-xr-xvideomv.pl5
-rwxr-xr-xvideorm.pl5
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;
diff --git a/videodb.rc b/videodb.rc
index 8a3ce70..150b09d 100644
--- a/videodb.rc
+++ b/videodb.rc
@@ -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',
diff --git a/videomv.pl b/videomv.pl
index f45d463..ddc3357 100755
--- a/videomv.pl
+++ b/videomv.pl
@@ -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;
diff --git a/videorm.pl b/videorm.pl
index d05da9f..04e1e03 100755
--- a/videorm.pl
+++ b/videorm.pl
@@ -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;