summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2014-10-28 20:01:42 +0100
committerRasmus Steinke <rasi@xssn.at>2014-10-28 20:01:42 +0100
commit480ae4a52005bbcdbead30d62f8a1adf154c5cf1 (patch)
tree4f522f9b7001facbc4b27097ae6a6994dce474ce
parent4196cb2cdf297a78091e5a608c01b82c8bd00e84 (diff)
downloadperl-app-clerk-480ae4a52005bbcdbead30d62f8a1adf154c5cf1.tar.gz
perl-app-clerk-480ae4a52005bbcdbead30d62f8a1adf154c5cf1.tar.xz
simplify add random function
-rwxr-xr-xclerk28
-rw-r--r--create_rating.sql8
2 files changed, 8 insertions, 28 deletions
diff --git a/clerk b/clerk
index 257ec03..dc32d72 100755
--- a/clerk
+++ b/clerk
@@ -726,31 +726,19 @@ playRandomAlbum () {
}
playRandomTracks () {
- addRandomT () {
+ mpc clear
+ artist="$(mpc list "$mpd_artist" | shuf -n 1)"
+ album="$(mpc list album "$mpd_artist" "$artist" | shuf -n 1)"
+ title="$(mpc list title album "$album" "$mpd_artist" "$artist" | shuf -n 1)"
+ mpc find album "$album" "$mpd_artist" "$artist" title "$title" | mpc add
+ mpc play
+ n=0; while (( n++ < $value -1 ));
+ do
artist="$(mpc list "$mpd_artist" | shuf -n 1)"
album="$(mpc list album "$mpd_artist" "$artist" | shuf -n 1)"
title="$(mpc list title album "$album" "$mpd_artist" "$artist" | shuf -n 1)"
mpc find album "$album" "$mpd_artist" "$artist" title "$title" | mpc add
- }
- mpc clear
- addRandomT
- mpc play
-
- nThreads=4
-
- for (( i=0, j=1; i<value - 1; i++, j++ )); do
- {
- addRandomT
- } &
-
- if [ $j -eq $nThreads ]; then
- j=0
- wait
- #sleep 1
- fi
done
-
- wait
mpc play
}
diff --git a/create_rating.sql b/create_rating.sql
deleted file mode 100644
index f2d112e..0000000
--- a/create_rating.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-create table if not exists albums(
- date varchar(12) not null,
- artist varchar(255) not null,
- album varchar(255) not null,
- rating smallint not null
-);
-create index if not exists album_ratings_idx ON albums (rating);
-CREATE UNIQUE INDEX albums_dir_idx ON albums (album);