summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2017-10-28 01:11:05 +0200
committerRasmus Steinke <rasi@xssn.at>2017-10-28 01:11:05 +0200
commit27b136166a62b20e526a4d605ad5b16d5040234e (patch)
tree14a134d7278eb8f658f024c5d511a602ca16f480
parent546fcf12dc4ace159c2af0c3a00b7080da8b88b9 (diff)
downloadclerk-index.tar.gz
clerk-index.tar.bz2
use uris for tracks tooindex
-rwxr-xr-xclerk.pl22
1 files changed, 15 insertions, 7 deletions
diff --git a/clerk.pl b/clerk.pl
index 9ac0d45..2023092 100755
--- a/clerk.pl
+++ b/clerk.pl
@@ -4,7 +4,7 @@ binmode(STDOUT, ":utf8");
use v5.10;
use warnings;
use strict;
-#use Data::Dumper;
+use Data::Dumper;
use utf8;
use Config::Simple;
use Data::MessagePack;
@@ -348,11 +348,13 @@ sub formatted_tracks {
my ($rdb) = @_;
my $fmtstr = join "", map {"%-${_}.${_}s\t"} ($rvar{max_width}->@{qw/track title artist album rating/});
$fmtstr .= "%-s\n";
- my @tracks = map {
+ my $i = 0;
+ my @tracks;
+ @tracks = map {
sprintf $fmtstr,
(map { $_ // "-" } $_->@{qw/Track Title Artist Album/}),
"r=" . ($_->{rating} // '0'),
- $_->{uri};
+ $i++;
} @{$rdb};
return \@tracks;
@@ -485,16 +487,22 @@ sub get_tags_from_rdb {
sub action_db_tracks {
my ($out) = @_;
-
+
my @sel = util_parse_selection($out);
+ @sel = map { $rvar{db}{ref}->[$_] } @sel;
+ my (@uris);
+
+ foreach (@sel) {
+ push @uris, $_->{uri};
+ }
my $action = backend_call(["Add\n", "Replace\n", "---\n", "Rate Track(s)\n"]);
mpd_reachable();
{
local $_ = $action;
- if (/^Add/) { mpd_add_items(\@sel) }
- elsif (/^Replace/) { mpd_replace_with_items(\@sel) }
- elsif (/^Rate Track\(s\)/) { mpd_rate_with_tracks(\@sel) }
+ if (/^Add/) { mpd_add_items(\@uris) }
+ elsif (/^Replace/) { mpd_replace_with_items(\@uris) }
+ elsif (/^Rate Track\(s\)/) { mpd_rate_with_tracks(\@uris) }
}
}