photo-stats

Unnamed repository; edit this file 'description' to name the repository.
git clone git://code.clttr.info/photo-stats.git
Log | Files | Refs | README | LICENSE

commit 938f14feee2dffe341c5466f38ce211c4dd67cdc
parent 36fe991fa1c7944b538b95577dfbde6d27fc79ed
Author: René Wagner <rwagner@rw-net.de>
Date:   Sun, 30 Aug 2020 14:06:11 +0200

sanitize invalid datetimeoriginal

Diffstat:
Mphosta.pl | 11++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/phosta.pl b/phosta.pl @@ -125,31 +125,28 @@ sub populate my $dbh = DBI->connect($dsn, '', '', { RaiseError => 1 }) or die $DBI::errstr; my $errorcount = 0; - my $emptycount = 0; foreach (@lines) { chomp $_; 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 ( $maker ~~ @forbidden_content) { $maker = '-'; } - if ( $model ~~ @forbidden_content) { $model = '-'; } + $maker !~ @forbidden_content or $maker = '-'; + $model !~ @forbidden_content or $model = '-'; $lens = ($lens ~~ @forbidden_content) ? $lensmodel : $lens; - if ( $lens ~~ @forbidden_content) { $lens = '-'; } + $lens !~ @forbidden_content or $lens = '-'; $apert = ($apert ne '-') ? sprintf("%.1f", $apert) : $apert; $fl = ($fl ne '-') ? sprintf("%.1f", $fl) : $fl; $fl35 = ($fl35 ne '-') ? POSIX::lround($fl35) : $fl35; $exposuretime = (looks_like_number($exposuretime) && $exposuretime < 1 && $exposuretime != 0) ? "1/". POSIX::lround(1/$exposuretime) : $exposuretime; - if ($datetimeoriginal eq '0000:00:00 00:00:00') { $datetimeoriginal = '-'; } + $datetimeoriginal =~ /\d{4}\-\d{2}\-\d{2}\s\d{2}:\d{2}:\d{2}$/ or $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(); - say sprintf('%5d', $emptycount). ' image files skipped due to missing EXIF data'; say sprintf('%5d', $errorcount). ' image files skipped due to errors'; say "Updated database $opt_D."; }