diff options
author | Tom Willemse | 2022-03-02 22:04:01 -0800 |
---|---|---|
committer | Tom Willemse | 2022-03-02 22:04:01 -0800 |
commit | 5c371433b9ba76da6fde27849775e5bf9c4c7db4 (patch) | |
tree | 20bd9887bdcc7db49e3ea466ab9016df29b380e5 /mpd-random-albums | |
parent | d1771d66c17a6cd2bf676028b1059eafa93093cd (diff) | |
download | mpd-random-albums-5c371433b9ba76da6fde27849775e5bf9c4c7db4.tar.gz mpd-random-albums-5c371433b9ba76da6fde27849775e5bf9c4c7db4.zip |
Add option to randomize albums by specific artist
Diffstat (limited to 'mpd-random-albums')
-rwxr-xr-x | mpd-random-albums | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/mpd-random-albums b/mpd-random-albums index 0b2469b..4bcd680 100755 --- a/mpd-random-albums +++ b/mpd-random-albums @@ -1,9 +1,24 @@ -#!/usr/bin/scsh -s +#!/usr/bin/env sh +# -*- mode: scheme; -*- +IFS=" " +exec scsh -s "$0" "$@" !# -(run (mpc clear)) +(define (randomize-all-albums) + (for-each (lambda (album) + (run (mpc findadd album ,album))) + (run/strings (pipe (mpc list album) + (shuf))))) -(for-each (lambda (album) - (run (mpc findadd album ,album))) - (run/strings (pipe (mpc list album) - (shuf)))) +(define (randomize-albums-by-artist artist) + (for-each (lambda (album) + (display (run/string (mpc findadd ,(string-append "((artist == \"" artist "\") AND (album == \"" album "\"))"))))) + (run/strings (pipe (mpc list album ,(string-append "((artist == \"" artist "\"))")) + (shuf))))) + +(run (mpc clear) + (> /dev/null)) + +(if (> (length command-line-arguments) 0) + (randomize-albums-by-artist (car command-line-arguments)) + (randomize-all-albums)) |