summaryrefslogtreecommitdiffstats
path: root/videoadd.pl
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem.moulin@ens-lyon.org>2012-02-18 00:09:25 +0100
committerGuilhem Moulin <guilhem.moulin@ens-lyon.org>2012-02-18 00:09:36 +0100
commit92a1750b60381d03f1c1909f236055cfe7fdb0b1 (patch)
tree439cc7e25359b7a1690759aa0eccfa09d74d7417 /videoadd.pl
parent23250c55f8384b084c188c09e2a3eea8d800f50b (diff)
handle custom fields
Diffstat (limited to 'videoadd.pl')
-rwxr-xr-xvideoadd.pl24
1 files changed, 19 insertions, 5 deletions
diff --git a/videoadd.pl b/videoadd.pl
index 8bd726a..5aa0f03 100755
--- a/videoadd.pl
+++ b/videoadd.pl
@@ -178,7 +178,8 @@ pod2usage(2) if $#ARGV != 0;
*LOG = *STDERR unless defined (fileno LOG);
my $file = $ARGV[0];
-my %new = (owner_id => $config{userid});
+my %new = ( owner_id => $config{userid}
+ , customs => {});
################################################################################
@@ -244,9 +245,9 @@ if (defined $imdb{crit}) {
$new{imgurl} = $movie->cover();
$new{director} = join ', ', map {$_->{name}} @{$movie->directors()};
$new{actors} = join "\n", map {$_->{name}. '::' .$_->{role}. '::imdb:' .$_->{id}}
- @{$movie->cast()};
+ @{$movie->full_cast()};
$new{country} = join ', ', @{$movie->country()};
- $new{plot} = $movie->storyline();
+ $new{plot} = $movie->full_plot();
$new{rating} = $movie->rating(); # Ignoring #votes and awards
$new{istv} = 1 if $movie->kind() =~ /tv/;
@@ -312,7 +313,8 @@ if ( defined($file) ) {
};
$new{language} = lc join (', ', @alang)
unless $#alang < 0 and defined $imdb{crit};
- $new{custom1} = lc join (', ', @slang);
+ # The "Subtitles" field is not hard-coded: insert it in the "custom" field instead
+ $new{customs}->{subtitles} = lc join (', ', @slang);
}
@@ -320,6 +322,17 @@ if ( defined($file) ) {
# Insertion into the database
unless ( defined $ignoredb_flag ) {
+ # Handle custom fields
+ my $customs = $dbh->selectall_arrayref ( "SELECT opt,value FROM $config{prefix}config
+ WHERE opt REGEXP '^custom[1-9]+\$'" )
+ or die "Can't select: $!\n";
+ foreach my $c (@$customs) {
+ if (grep {lc $_ eq lc $c->[1]} (keys %{$new{customs}})) {
+ $new{$c->[0]} = $new{customs}->{lc $c->[1]};
+ }
+ }
+ delete $new{customs};
+
my $INSERT = "INSERT INTO $config{prefix}videodata
SET mediatype = 14,
created = NOW()";
@@ -335,7 +348,8 @@ unless ( defined $ignoredb_flag ) {
my $ids = $dbh->selectall_arrayref ( "SELECT id FROM $config{prefix}videodata
WHERE filename = ? ",
- undef, $new{filename} );
+ undef, $new{filename} )
+ or die "Can't select: $!\n";
if ($#$ids == 0) {
my $id = $ids->[0]->[0];
$dbh->do( "INSERT INTO $config{prefix}userseen