1(import [protocol [commands]]
2 [protocol.util :as util])
3(require [hy.contrib.walk [let]]
4 [hy.extra.anaphoric [*]])
5
6(with-decorator (commands.add "currentsong")
7 (defn current-song [ctx args]
8 (with (playlist ctx.playback)
9 (.current playlist))))
10
11(with-decorator (commands.add "status")
12 (defn status [ctx args]
13 (with (playlist ctx.playback)
14 (let [mode (. playlist mode)
15 song (.current playlist)
16 time (.time ctx.playback)]
17 {#**
18 {
19 "volume" 100
20 "repeat" (get mode :repeat)
21 "random" (get mode :random)
22 "single" (get mode :single)
23 "consume" (get mode :consume)
24 "playlistlength" (playlist.psize)
25 "state" (ctx.playback.state)
26 "elapsed" (ap-if time (first it))
27 "duration" (ap-if time (last it))
28 "time" (ap-if time (.join ":" (map (fn [v] (str (round v))) time)))
29 }
30 #**
31 (if song
32 {
33 "song" (. song position)
34 "songid" (get (. song metadata) "Id")
35 } {})
36 }))))