summaryrefslogtreecommitdiffstats
path: root/clerk
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2017-09-20 21:28:08 +0200
committerRasmus Steinke <rasi@xssn.at>2017-09-20 21:28:08 +0200
commitd917065d93769c63bf87f870ec0d0f6ae4f42edc (patch)
tree025cb515df7c73d1b6ec829bd389ffae3a7f54c0 /clerk
parentb4a46692680c06c42293db2b686e718142ab0d35 (diff)
downloadperl-app-clerk-d917065d93769c63bf87f870ec0d0f6ae4f42edc.tar.gz
perl-app-clerk-d917065d93769c63bf87f870ec0d0f6ae4f42edc.tar.xz
shuffle array before adding songs
Diffstat (limited to 'clerk')
-rwxr-xr-xclerk6
1 files changed, 3 insertions, 3 deletions
diff --git a/clerk b/clerk
index ad00d5f..8b4c958 100755
--- a/clerk
+++ b/clerk
@@ -17,11 +17,10 @@ use File::stat;
use Try::Tiny;
use FindBin '$Bin';
use FindBin '$Script';
-use List::Util qw(min);
+use List::Util qw(min any shuffle);
use Getopt::Std;
use HTTP::Date;
use IPC::Run qw( timeout start );
-use List::Util qw(any);
use Net::MPD;
use POSIX qw(tzset);
use autodie;
@@ -274,7 +273,8 @@ sub random_rated_tracks {
$minimal = "$minimal_rating";
my $rdb = unpack_msgpack();
my @rating_rdb = grep { ($_->{rating} // 0) >= $minimal } @$rdb;
- $mpd->add($_->{uri}) for (splice(@rating_rdb, -min($#rating_rdb, $songs)));
+ my @random_rated_tracks = shuffle @rating_rdb;
+ $mpd->add($_->{uri}) for (splice(@random_rated_tracks, -min($#random_rated_tracks, $songs)));
}
sub random {