aboutsummaryrefslogtreecommitdiffstats
path: root/mpd/usr/bin
diff options
context:
space:
mode:
authorGravatar Tom Willemse2022-03-03 01:08:16 -0800
committerGravatar Tom Willemse2022-03-03 01:08:16 -0800
commitc454bde37c777bf422a7df729fb9ff43c2ef3f3c (patch)
tree4b62a3b9ff685b6238ff4cd424bb1970f5ce434d /mpd/usr/bin
parent79df03a72ad0dc7c13f5e313f5038786dc38bc90 (diff)
downloadnew-dotfiles-c454bde37c777bf422a7df729fb9ff43c2ef3f3c.tar.gz
new-dotfiles-c454bde37c777bf422a7df729fb9ff43c2ef3f3c.zip
[mpd] Lispify the MPD query
Write a small DSL for converting a simple lisp expression to an MPD query format. This turns, for example: (and (= artist "Katatonia") (= album "Last Fair Deal Gone Down")) Into: ((artist == "Katatonia") AND (album == "Last Fair Deal Gone Down")) The expressions inside ‘query’ are quasi-quoted, so that variable substitution is possible.
Diffstat (limited to 'mpd/usr/bin')
-rwxr-xr-xmpd/usr/bin/mpd-random-albums7
1 files changed, 4 insertions, 3 deletions
diff --git a/mpd/usr/bin/mpd-random-albums b/mpd/usr/bin/mpd-random-albums
index 4bcd680..50e6f79 100755
--- a/mpd/usr/bin/mpd-random-albums
+++ b/mpd/usr/bin/mpd-random-albums
@@ -1,7 +1,7 @@
#!/usr/bin/env sh
# -*- mode: scheme; -*-
IFS=" "
-exec scsh -s "$0" "$@"
+exec scsh -ll mpd.scm -o mpd -s "$0" "$@"
!#
(define (randomize-all-albums)
@@ -12,8 +12,9 @@ exec scsh -s "$0" "$@"
(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 "\"))"))
+ (run (mpc findadd ,(query (and (= artist ,artist)
+ (= album ,album))))))
+ (run/strings (pipe (mpc list album ,(query (= artist ,artist)))
(shuf)))))
(run (mpc clear)