From f87eeba7fd87a83f75e445d9ef2ec55f46b24668 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 19 Mar 2012 00:20:58 -0500 Subject: quiet mode --- bin/lastfm_export | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/lastfm_export b/bin/lastfm_export index bd0fab8..1f33c2d 100644 --- a/bin/lastfm_export +++ b/bin/lastfm_export @@ -9,9 +9,10 @@ use Getopt::Long qw(:config pass_through); use LastFM::Export; use Term::ProgressBar; -my $dsn; +my ($dsn, $quiet); GetOptions( 'dsn=s' => \$dsn, + 'quiet' => \$quiet, ); die "--dsn is required" unless $dsn; @@ -25,10 +26,13 @@ CREATE TABLE `tracks` ( ); my $exporter = LastFM::Export->new_with_options; -my $progress = Term::ProgressBar->new({ - count => $exporter->track_count, - ETA => 'linear', -}); +my $progress; +if (!$quiet) { + $progress = Term::ProgressBar->new({ + count => $exporter->track_count, + ETA => 'linear', + }); +} my $sth = $dbh->prepare( 'INSERT INTO tracks (artist, album, name, timestamp) VALUES (?, ?, ?, ?)' @@ -44,7 +48,7 @@ while (my $block = $s->next) { $item->{name}, $item->{date}{uts}, ); - $progress->update($count++); + $progress->update($count++) unless $quiet; } $dbh->commit; sleep 1; -- cgit v1.2.3