diff --git a/phosta.pl b/phosta.pl
index c70f420a07d2e654c815e1fa5a1c1a336af1861e..e39c7555459b6bfe7e20dfc88f96a601beebe114 100755
--- a/phosta.pl
+++ b/phosta.pl
@@ -19,7 +19,7 @@ use File::HomeDir;
$Getopt::Std::STANDARD_HELP_VERSION = 'true';
-my $VERSION = '0.5';
+my $VERSION = '0.6';
my $PROGRAM = 'Photo Stats';
my $configfile = catfile(File::HomeDir->my_home, '.phosta.conf');
@@ -57,7 +57,7 @@ {
my @group_params = ('year', 'month', 'week', 'hour', '');
if ( ! ($opt_g ~~ @group_params) ) { return 0; }
- my @select_params = ('maker', 'model', 'lens', 'aperture', 'exposuretime', 'iso', 'focallength', 'focallength35mm', '');
+ my @select_params = ('maker', 'model', 'lensmake', 'lens', 'aperture', 'exposuretime', 'iso', 'focallength', 'focallength35mm', '');
foreach (split (/,/, $opt_s))
{
if ( ! ($_ ~~ @select_params) ) { return 0; }
@@ -87,7 +87,7 @@ {
my ($dbfile) = @_;
my $dbh = DBI->connect($dsn, '', '', { RaiseError => 1 }) or die $DBI::errstr;
- my $stmt = 'CREATE TABLE photos (file TEXT PRIMARY KEY, maker TEXT, model TEXT, lens TEXT, focallength INTEGER, focallength35mm INTEGER, aperture DECIMAL, exposuretime TEXT, iso INTEGER, flash TEXT, datetimeoriginal DATETIME);';
+ my $stmt = 'CREATE TABLE photos (file TEXT PRIMARY KEY, maker TEXT, model TEXT, lensmake TEXT, lens TEXT, focallength INTEGER, focallength35mm INTEGER, aperture DECIMAL, exposuretime TEXT, iso INTEGER, flash TEXT, datetimeoriginal DATETIME);';
my $rv = $dbh->do($stmt);
}
@@ -97,7 +97,7 @@ my ($destination_dir) = @_;
say "Scanning $destination_dir for images...";
- my $cmd = "exiftool -fast2 -r -m -f -p '\$filepath##\$make##\$model##\$lens##\$lensmodel##\$focallength##\$focallengthin35mmformat##\$aperture##\$exposuretime##\$iso##\$flash##\$datetimeoriginal' -d \"%Y-%m-%d %H:%M:%S\" -ext jpg " . $destination_dir;
+ my $cmd = "exiftool -fast2 -r -m -f -p '\$filepath##\$make##\$model##\$lensmake##\$lens##\$lensmodel##\$focallength##\$focallengthin35mmformat##\$aperture##\$exposuretime##\$shutterspeed##\$iso##\$flash##\$datetimeoriginal' -d \"%Y-%m-%d %H:%M:%S\" -ext jpg " . $destination_dir;
my @lines = qx($cmd);
my $dbh = DBI->connect($dsn, '', '', { RaiseError => 1 }) or die $DBI::errstr;
@@ -106,16 +106,21 @@ my $emptycount = 0;
foreach (@lines)
{
chomp $_;
- my ($file, $maker, $model, $lens, $lensmodel, $fl, $fl35, $apert, $exposuretime, $iso, $flash, $datetimeoriginal) = split(/#/, $_);
+ my ($file, $maker, $model, $lensmake, $lens, $lensmodel, $fl, $fl35, $apert, $exposuretime, $ss, $iso, $flash, $datetimeoriginal) = split(/#/, $_);
+
+ my @forbidden_content = ('Unknown', 'N/A', '-', '');
+ #if ($model eq '-') { $emptycount++; next; }
- if ($model eq '-') { $emptycount++; next; }
- $lens = ($lens ne '-') ? $lens : $lensmodel;
+ if ( $maker ~~ @forbidden_content) { $maker = '-'; }
+ if ( $model ~~ @forbidden_content) { $model = '-'; }
+ $lens = ($lens ~~ @forbidden_content) ? $lensmodel : $lens;
+ if ( $lens ~~ @forbidden_content) { $lens = '-'; }
$apert = ($apert ne '-') ? sprintf("%.1f", $apert) : $apert;
$exposuretime = (looks_like_number($exposuretime) && $exposuretime < 1) ? "1/". POSIX::lround(1/$exposuretime) : $exposuretime;
if ($datetimeoriginal eq '0000:00:00 00:00:00') { $datetimeoriginal = '-'; }
- my $stmt = "INSERT OR REPLACE INTO photos (file, maker, model, lens, focallength, focallength35mm, aperture, exposuretime, iso, flash, datetimeoriginal)
- VALUES ('$file', '$maker', '$model', '$lens', '$fl', '$fl35', '$apert', '$exposuretime', '$iso', '$flash', '$datetimeoriginal')";
+ my $stmt = "INSERT OR REPLACE INTO photos (file, maker, model, lensmake, lens, focallength, focallength35mm, aperture, exposuretime, iso, flash, datetimeoriginal)
+ VALUES ('$file', '$maker', '$model', '$lensmake', '$lens', '$fl', '$fl35', '$apert', '$exposuretime', '$iso', '$flash', '$datetimeoriginal')";
my $rv = $dbh->do($stmt) or $errorcount++;
}
$dbh->disconnect();
@@ -253,7 +258,7 @@ say 'stats querying:';
say ' -g : group by time range, defaults to total (which means no grouping by time range)';
say ' allowed values: year, month, week, hour';
say ' -s : specify the information you want to select, defaults to none (just show number of images)';
- say ' allowed values: maker, model, lens, aperture, exposuretime, iso, focallength, focallength35mm';
+ say ' allowed values: maker, model, lensmake, lens, aperture, exposuretime, iso, focallength, focallength35mm';
say ' multiple fields should be listed comma-separated';
say ' -t <range> : only take images into account which have been taken in the given timerange';
say ' <range> must be specified as \'YYYYMMDD-YYYYMMDD\', you can omit one value';