diff options
author | Rasmus Steinke <rasi@xssn.at> | 2017-09-20 21:28:08 +0200 |
---|---|---|
committer | Rasmus Steinke <rasi@xssn.at> | 2017-09-20 21:28:08 +0200 |
commit | d917065d93769c63bf87f870ec0d0f6ae4f42edc (patch) | |
tree | 025cb515df7c73d1b6ec829bd389ffae3a7f54c0 /clerk | |
parent | b4a46692680c06c42293db2b686e718142ab0d35 (diff) | |
download | perl-app-clerk-d917065d93769c63bf87f870ec0d0f6ae4f42edc.tar.gz perl-app-clerk-d917065d93769c63bf87f870ec0d0f6ae4f42edc.tar.xz |
shuffle array before adding songs
Diffstat (limited to 'clerk')
-rwxr-xr-x | clerk | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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 { |