summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/lastfm_export16
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;