photo-stats

statistics processor for the terminal
git clone https://git.clttr.info/photo-stats.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 22673811164a583dbeaf38ecdccb65db7b23515f
parent e00e074d247f301ab26b6bafca3690696b29b65c
Author: René Wagner <rwa@clttr.info>
Date:   Wed, 12 Apr 2023 10:18:13 +0200

apply alias to lensmaker as well

Diffstat:
Mphosta | 22++++++++++++----------
Mphosta.1.scd | 2+-
2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/phosta b/phosta @@ -72,7 +72,7 @@ sub validate my @group_params = ('year', 'month', 'week', 'hour'); !defined($opt_g) || grep /$opt_g/, @group_params or return 0; - my @select_params = qw(file maker model lensmake lens aperture exposuretime iso focallength focallength35mm); + my @select_params = qw(file maker model lensmaker lens aperture exposuretime iso focallength focallength35mm); if (defined($opt_s)) { foreach (split (/,/, $opt_s)) { my $val = $_; @@ -152,7 +152,7 @@ sub create_db 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, lensmake 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, lensmaker TEXT, lens TEXT, focallength INTEGER, focallength35mm INTEGER, aperture DECIMAL, exposuretime TEXT, iso INTEGER, flash TEXT, datetimeoriginal DATETIME);'; !$opt_v or say "### DB Statement: $stmt"; my $rv = $dbh->do($stmt); $dbh->disconnect(); @@ -176,11 +176,12 @@ sub populate my @line = split(/#/, $_); map { s/^\s+|\s+$//g; } @line; - my ($file, $maker, $model, $lensmake, $lens, $lensmodel, $fl, $fl35, $apert, $exposuretime, $ss, $iso, $flash, $datetimeoriginal) = @line; + my ($file, $maker, $model, $lensmaker, $lens, $lensmodel, $fl, $fl35, $apert, $exposuretime, $ss, $iso, $flash, $datetimeoriginal) = @line; my @forbidden_content = ('Unknown', 'N/A', '', '-'); - if (!defined($maker) || $maker ~~ @forbidden_content) { $maker = '-'}; + if (!defined($maker) || $maker ~~ @forbidden_content) { $maker = '-'}; if (!defined($model) || $model ~~ @forbidden_content) { $model = '-'}; - if (!defined($lens) || $lens ~~ @forbidden_content) { $lens = $lensmodel }; + if (!defined($lensmaker) || $lensmaker ~~ @forbidden_content) { $lensmaker = '-' }; + if (!defined($lens) || $lens ~~ @forbidden_content) { $lens = $lensmodel }; if (!defined($lens) || $lens ~~ @forbidden_content) { $lens = '-' }; $apert = ($apert ne '-') ? sprintf("%.1f", $apert) : $apert; $fl = ($fl ne '-') ? sprintf("%.1f", $fl) : $fl; @@ -190,13 +191,14 @@ sub populate foreach (@aliases) { - $lens =~ s/@$_[0]/@$_[1]/; $maker =~ s/@$_[0]/@$_[1]/; $model =~ s/@$_[0]/@$_[1]/; + $lensmaker =~ s/@$_[0]/@$_[1]/; + $lens =~ s/@$_[0]/@$_[1]/; } - 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 $stmt = "INSERT OR REPLACE INTO photos (file, maker, model, lensmaker, lens, focallength, focallength35mm, aperture, exposuretime, iso, flash, datetimeoriginal) + VALUES ('$file', '$maker', '$model', '$lensmaker', '$lens', '$fl', '$fl35', '$apert', '$exposuretime', '$iso', '$flash', '$datetimeoriginal')"; my $rv = $dbh->do($stmt) or $errorcount++; } $dbh->commit(); @@ -456,14 +458,14 @@ sub main::HELP_MESSAGE say ' -g <period> : group by a time period, defaults to total (which means no grouping by period)'; say ' allowed values: year, month, week, hour'; say ' -s <fields> : specify the information you want to select, defaults to none (just show number of images)'; - say ' allowed values: file, maker, model, lensmake, lens, aperture, exposuretime, iso, focallength, focallength35mm'; + say ' allowed values: file, maker, model, lensmaker, lens, aperture, exposuretime, iso, focallength, focallength35mm'; say ' multiple fields should be listed comma-separated without whitespaces'; 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 the first or the later value'; say ' -f <expr> : filter images based on the given expression, multiple expression can be given comma-separated'; say ' this works as a case-insensitive search, multiple expressions need to match all (AND logic)'; say ' use "field=value" for CONTAINS and "field!=value" for NOT CONTAINS'; - say ' allowed fields: file, maker, model, lensmake, lens, aperture, exposuretime, iso, focallength, focallength35mm'; + say ' allowed fields: file, maker, model, lensmaker, lens, aperture, exposuretime, iso, focallength, focallength35mm'; say ' -n <number> : limit the resultset to <number> of lines'; say ' -o <fields> : sort your output by the given fields (sequence matters!) in descending order'; say ' allowed values: any comma separated combination of the values of -g and -s param and \'count\''; diff --git a/phosta.1.scd b/phosta.1.scd @@ -25,7 +25,7 @@ What data you are going to see is specified by the *-s* param. urrently the foll - file - maker - model -- lens maker +- lensmaker - lens - aperture - exposuretime