use strict;
use warnings;
use utf8;
+use feature 'say';
use Log::Any qw($log);
use Object::Pad;
return 0;
}
+ if ( $cmd eq 'list-unwanted-artists' ) {
+ die "This command has no arguments\n" if @args;
+ $self->set_db_needs_update(0);
+ my $count = $self->db->walk_unwanted_artists( sub { say @_ } );
+ say "Total unwanted artists: $count";
+
+ return 0;
+ }
+
if ( $cmd eq 'add-unwanted-album' ) {
die "NOT IMPLEMENTED\n";
}
$log->debug("DB generation is $generation");
}
+ method walk_unwanted_artists($callback) {
+ $self->connect;
+
+ my $count = 0;
+
+ my $sth = $db->prepare('SELECT artist FROM unwanted_artists ORDER BY 1');
+ my $artist;
+ $sth->execute;
+ $sth->bind_columns(\$artist);
+ while ( $sth->fetchrow_arrayref ) {
+ $count++;
+ $callback->($artist);
+ }
+
+ return $count;
+ }
+
method disconnect {
return unless $db;