diff --git a/phosta.pl b/phosta.pl
index 3e7c304fa723d92415b7d2f38501a79408cd50eb..0615b34c248863cd1bb894255e8a3fd711908a85 100755
--- a/phosta.pl
+++ b/phosta.pl
@@ -20,7 +20,7 @@ use File::HomeDir;
$Getopt::Std::STANDARD_HELP_VERSION = 'true';
-my $VERSION = '0.6';
+my $VERSION = '0.8';
my $PROGRAM = 'Photo Stats';
my $configfile = catfile(File::HomeDir->my_home, '.phosta.conf');
@@ -29,16 +29,18 @@ # read commandline switches
our $opt_E='jpg,jpeg';
our $opt_D=getcwd . "/photo_stats.db";
our $opt_p='';
-our $opt_t='';
+our $opt_t=undef;
our $opt_c=0;
-our $opt_s='';
-our $opt_g='';
+our $opt_s=undef;
+our $opt_g=undef;
our $opt_v=0;
our $opt_n=undef;
+our $opt_o='count';
+our $opt_r=0;
getconfig($configfile);
-getopts('vcp:n:g:s:t:D:E:') or die "Invalid parameters provided! See 'phosta --help' for more details.";
+getopts('vcrp:n:g:s:t:D:E:o:') or die "Invalid parameters provided! See 'phosta --help' for more details.";
validate() or die "Invalid parameters provided! See 'phosta --help' for more details.";
my $dsn = "DBI:SQLite:dbname=$opt_D";
@@ -58,18 +60,23 @@ exit 0;
sub validate
{
my @select_params = ('maker', 'model', 'lensmake', 'lens', 'aperture', 'exposuretime', 'iso', 'focallength', 'focallength35mm', '');
{
if ( ! ($_ ~~ @select_params) ) { return 0; }
foreach (split (/,/, $opt_s))
{
if ( ! ($_ ~~ @select_params) ) { return 0; }
}
}
if (defined($opt_n) && (!looks_like_number($opt_n) || $opt_n < 1)) { return 0; }
if ($opt_E !~ /^([a-z]{2,4}){1,}(\,[a-z]{2,4}){0,}$/) { return 0; }
@@ -144,7 +151,7 @@ }
sub get_sql
{
my $fieldlist = '';
my $grouplist = '';
@@ -159,7 +166,7 @@ $grouplist = "strftime('%Y/%m', datetimeoriginal)";
}
when ('week')
{
$fieldlist = "IFNULL(strftime('%Y/%W', datetimeoriginal), '-') as week_of_year,";
$fieldlist = "IFNULL(strftime('%Y/%W', datetimeoriginal), '-') as week,";
$grouplist = "strftime('%Y/%W', datetimeoriginal)";
}
when ('year')
@@ -174,32 +181,22 @@ $grouplist = "strftime('%H', datetimeoriginal)";
}
}
{
$fieldlist = $fieldlist . $selected . ', ';
$grouplist .= ($grouplist ne '' ? ',' : '') . $selected;
}
{
my $lastcolumn = $selected =~ tr/,//;
$lastcolumn += 2;
$orderlist = 'ORDER BY ';
if ($grouping ne '')
{
$orderlist = $orderlist . ' 1 DESC,';
$lastcolumn++;
}
$orderlist .= " $lastcolumn DESC";
$orderlist = 'ORDER BY 1 DESC';
my $sorter = $opt_r ? ' ASC' : ' DESC';
my @order = split(/\,/, $order);
$orderlist = ' ORDER BY '. join("$sorter, ", @order) .$sorter;
}
{
my ($from, $to) = split (/\-/, $opt_t);
my ($from, $to) = split(/\-/, $timerange);
if ($from ne '')
{
$wherelist = 'datetimeoriginal >= \''. substr($from, 0, 4) .'-'. substr($from, 4, 2) .'-'. substr($from, 6, 2) .'\'';
@@ -224,8 +221,8 @@ my $total_count = $dbh->selectrow_array("SELECT count(file) from photos");
say "Querying database $opt_D with $total_count entries...";
say '';
$stmt->execute();
my $rows = $stmt->fetchall_arrayref;
@@ -311,10 +308,12 @@ say '';
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 ' 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';
say ' -n <number> : limit the resultset to <number> of lines';
}
text/gemini
This content has been proxied by September (ba2dc).