mpvd

Control mpv using the MPD protocol

git clone https://git.8pit.net/mpvd.git

 1(require [hy.contrib.loop [loop]])
 2(require [hy.contrib.walk [let]])
 3
 4(defclass Reader [object]
 5  (defn --init-- [self file]
 6    (setv self.file file))
 7
 8  (defn list-start? [self line]
 9    (or (= line "command_list_begin\n")
10        (= line "command_list_ok_begin\n")))
11
12  (defn list-end? [self line]
13    (= line "command_list_end\n"))
14
15  (defn --call-- [self]
16    (loop [[str ""] [list False]]
17      (let [line (self.file.readline)]
18        (cond
19          [(self.list-start? line)
20           (recur (+ str line) True)]
21          [list
22           (if (self.list-end? line)
23             (+ str line)
24             (recur (+ str line) list))]
25          [True line])))))