diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-03-19 00:20:58 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-03-19 00:20:58 -0500 |
commit | f87eeba7fd87a83f75e445d9ef2ec55f46b24668 (patch) | |
tree | deeb9a914291045adbd7d0cbcf2d8ffcff6f7e7c /bin | |
parent | eff476d3b7c5b8864f4a7646f001803b838365bb (diff) | |
download | lastfm-export-f87eeba7fd87a83f75e445d9ef2ec55f46b24668.tar.gz lastfm-export-f87eeba7fd87a83f75e445d9ef2ec55f46b24668.zip |
quiet mode
Diffstat (limited to 'bin')
-rw-r--r-- | bin/lastfm_export | 16 |
1 files 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; |