photo-stats

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

commit 09931aeaf11412ddfa77bb0cb2147ee0ed5c8748
parent f8508fe8cca1784a6922e2473869625bcd42b93f
Author: René Wagner <rwagner@rw-net.de>
Date:   Wed, 29 Jul 2020 19:49:32 +0200

introduce -c flag for clearing db before filling

duplicates are now updated based on file name

Diffstat:
MREADME.md | 4++++
Mphosta.pl | 19++++++++++---------
Mphoto_stats.db | 0
3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/README.md b/README.md @@ -35,3 +35,7 @@ The stats are available as grouped counts by - all time total - by year - by month + +## FAQ +- I have my images on a network share, how can i include them into the stats? +You should mount the share and use is like a local directory? diff --git a/phosta.pl b/phosta.pl @@ -23,17 +23,18 @@ my $password = ""; $Getopt::Std::STANDARD_HELP_VERSION = 'true'; -my $VERSION = '0.1'; +my $VERSION = '0.2'; my $PROGRAM = 'Photo Stats'; my $configfile = catfile(File::HomeDir->my_home, '.photo-stats.conf'); # read commandline switches our $opt_p=''; +our $opt_c=0; getconfig($configfile); -getopts('p:') or die "Invalid parameters provided! See 'phosta.pl --help' for more details."; +getopts('cp:') or die "Invalid parameters provided! See 'phosta.pl --help' for more details."; #if ( $opt_s ) { writeconfig($configfile); } if ( $opt_p ne '' ) { @@ -53,7 +54,7 @@ sub get_stats my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 }) or die $DBI::errstr; - $dbh->do('DELETE FROM photos'); + if ( $opt_c ) { $dbh->do('DELETE FROM photos'); } my $errorcount = 0; my $emptycount = 0; foreach (@lines) @@ -67,8 +68,8 @@ sub get_stats $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 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, lens, focallength, focallength35mm, aperture, exposuretime, iso, flash, datetimeoriginal) + VALUES ('$file', '$maker', '$model', '$lens', '$fl', '$fl35', '$apert', '$exposuretime', '$iso', '$flash', '$datetimeoriginal')"; my $rv = $dbh->do($stmt) or $errorcount++; } $dbh->disconnect(); @@ -95,7 +96,7 @@ sub main::VERSION_MESSAGE() say $PROGRAM . ' - version ' . $VERSION; say 'published under BSD 3 - Clause License'; say 'Copyright(c) 2019-2020 René Wagner'; - say 'https://git.sr.ht/~rwa/photo-helpers'; + say 'https://git.sr.ht/~rwa/photo-stats'; } sub main::HELP_MESSAGE @@ -106,7 +107,7 @@ sub main::HELP_MESSAGE say 'usage: phosta(.pl) [options]'; say ''; say 'options:'; - say ' -p <source folder> : populate database from the files in the specified folder'; - say ' -s : safe current options (-r, -f, -c only) to user profile. If present the saved values are applied automatically.'; - say ' --help : show this help'; + say ' -p <folder> : populate database from the files in the specified folder'; + say ' -c : clear the database before populating with data from the folder'; + say ' --help : show this help'; } diff --git a/photo_stats.db b/photo_stats.db Binary files differ.