dotfiles/mpd/usr/bin/mpd-random-albums

24 lines
785 B
Scheme
Executable file

#!/usr/bin/env sh
# -*- mode: scheme; -*-
IFS=" "
exec scsh -s "$0" "$@"
!#
(define (randomize-all-albums)
(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))