photo-stats

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

commit bb40cab16d89689e027b714a77ed242af4b6a2c8
parent 6769eb04d4024fa4955fdb58d860d38c4713f714
Author: René Wagner <rwa@clttr.info>
Date:   Tue, 22 Aug 2023 19:56:01 +0200

fix perl deprecation warnings

Diffstat:
MCHANGELOG.md | 4++--
Mphosta | 68+++++++++++++++++++++++++++++++++++---------------------------------
2 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md @@ -11,12 +11,12 @@ - apply aliases to 'lensmaker' as well - fix parameter validation -## 1.1 (02.04.2023) +## 1.1 (2023-04-02) - introduce aliases to allow data to be sanitized - new param -T for table output - new param -W for output width limiting -## 1.0 (31.08.2020) +## 1.0 (2020-08-31) initial release with the following features: - extract EXIF data from media files and store it in the database - allow querying of statistic data diff --git a/phosta b/phosta @@ -107,7 +107,7 @@ sub validate !defined($opt_f) || $opt_f =~ /^(,{0,1}[\w\-]{2,}(!){0,1}=[\w\-\s]{1,}){1,}$/ or return 0; my @table_params = qw(on off auto); - $opt_T ~~ @table_params or return 0; + grep /$opt_T/, @table_params or return 0; return 1; } @@ -182,12 +182,12 @@ sub populate map { s/^\s+|\s+$//g; } @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($model) || $model ~~ @forbidden_content) { $model = '-'}; - 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; + if (!defined($maker) || grep /$maker/, @forbidden_content) { $maker = '-'}; + if (!defined($model) || grep /$model/, @forbidden_content) { $model = '-'}; + if (!defined($lensmaker) || grep /$lensmaker/, @forbidden_content) { $lensmaker = '-' }; + if (!defined($lens) || grep /$lens/, @forbidden_content) { $lens = $lensmodel }; + if (!defined($lens) || grep /$lens/, @forbidden_content) { $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; @@ -240,32 +240,34 @@ sub get_sql my $fieldlist = ''; my @grouparray; my $orderlist = ''; - my @wherearray; - foreach (split (/,/, $opt_g)) { - given ($_) { - when ('month') { - $fieldlist = $fieldlist . "IFNULL(strftime('%m', datetimeoriginal), '-') as month,"; - push @grouparray, "strftime('%m', datetimeoriginal)"; - } - when ('week') { - $fieldlist = $fieldlist . "IFNULL(strftime('%W', datetimeoriginal), '-') as week,"; - push @grouparray, "strftime('%W', datetimeoriginal)"; - } - when ('year') { - $fieldlist = $fieldlist . "IFNULL(strftime('%Y', datetimeoriginal), '-') as year,"; - push @grouparray, "strftime('%Y', datetimeoriginal)"; - } - when ('hour') { - $fieldlist = $fieldlist . "IFNULL(strftime('%H', datetimeoriginal), '-') as hour,"; - push @grouparray, "strftime('%H', datetimeoriginal)"; - } - when ('dayofmonth') { - $fieldlist = $fieldlist . "IFNULL(strftime('%d', datetimeoriginal), '-') as dayofmonth,"; - push @grouparray, "strftime('%d', datetimeoriginal)"; - } - when ('dayofweek') { - $fieldlist = $fieldlist . "substr('SunMonTueWedThuFriSat-', 1+ 3 * IFNULL(strftime('%w', datetimeoriginal), 7), 3) as dayofweek,"; - push @grouparray, "strftime('%w', datetimeoriginal)"; + my @wherearray; + if (defined($opt_g)) { + foreach (split (/,/, $opt_g)) { + for ($_) { + if ('month') { + $fieldlist = $fieldlist . "IFNULL(strftime('%m', datetimeoriginal), '-') as month,"; + push @grouparray, "strftime('%m', datetimeoriginal)"; + } + elsif ('week') { + $fieldlist = $fieldlist . "IFNULL(strftime('%W', datetimeoriginal), '-') as week,"; + push @grouparray, "strftime('%W', datetimeoriginal)"; + } + elsif ('year') { + $fieldlist = $fieldlist . "IFNULL(strftime('%Y', datetimeoriginal), '-') as year,"; + push @grouparray, "strftime('%Y', datetimeoriginal)"; + } + elsif ('hour') { + $fieldlist = $fieldlist . "IFNULL(strftime('%H', datetimeoriginal), '-') as hour,"; + push @grouparray, "strftime('%H', datetimeoriginal)"; + } + elsif ('dayofmonth') { + $fieldlist = $fieldlist . "IFNULL(strftime('%d', datetimeoriginal), '-') as dayofmonth,"; + push @grouparray, "strftime('%d', datetimeoriginal)"; + } + elsif ('dayofweek') { + $fieldlist = $fieldlist . "substr('SunMonTueWedThuFriSat-', 1+ 3 * IFNULL(strftime('%w', datetimeoriginal), 7), 3) as dayofweek,"; + push @grouparray, "strftime('%w', datetimeoriginal)"; + } } } }