changeset 698: | 96958d3eb5b0 |
parent: | ea3b643a27a3 |
author: | Richard Westhaver <ellis@rwest.io> |
date: | Fri, 04 Oct 2024 22:04:59 -0400 |
permissions: | -rw-r--r-- |
description: | fixes |
279
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
1 | ;;; aud/mpd.lisp --- MPD Interface for Lisp |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
2 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
3 | ;; based on https://github.com/stassats/mpd |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
4 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
5 | ;;; Commentary: |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
6 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
7 | ;; The original code hasn't been updated in quite some time. Here |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
8 | ;; we've added in some missing slots, fixed a typo, removed the |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
9 | ;; dependency on usocket library and extended the functionality |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
10 | ;; slightly. |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
11 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
12 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
13 | ;;; Code: |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
14 | (in-package :aud/mpd) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
15 | ;;; Classes |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
16 | (define-condition mpd-error (error) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
17 | ((text :initarg :text :reader text |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
18 | :initform nil)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
19 | (:report (lambda (condition stream) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
20 | (princ (text condition) stream)))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
21 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
22 | (macrolet ((define-conditions (names) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
23 | `(progn ,@(mapcar |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
24 | (lambda (name) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
25 | `(define-condition ,name (mpd-error) ())) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
26 | names)))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
27 | (define-conditions (bad-argument incorrect-password |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
28 | not-permitted unknown-command not-exist |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
29 | playlist-size-exceed already-updating exist))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
30 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
31 | (defparameter *error-ids-alist* |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
32 | '((2 . bad-argument) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
33 | (3 . incorrect-password) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
34 | (4 . not-permitted) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
35 | (5 . unknown-command) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
36 | (50 . not-exist) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
37 | (51 . playlist-size-exceed) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
38 | (54 . already-updating) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
39 | (56 . exist))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
40 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
41 | (eval-always |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
42 | (defparameter *tag-types* |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
43 | '(:artist :album :title :track :name :genre :date |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
44 | :composer :performer :comment :disc :filename :any) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
45 | "Types of tags for using in `search' and `find'")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
46 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
47 | (deftype tag-type () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
48 | `(member ,@*tag-types*)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
49 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
50 | (defclass track () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
51 | ((file |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
52 | :initform nil :initarg :file :accessor file) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
53 | (title |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
54 | :initform nil :initarg :title :accessor title) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
55 | (artist |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
56 | :initform nil :initarg :artist :accessor artist) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
57 | (albumartist |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
58 | :initform nil :initarg :albumartist :accessor albumartist) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
59 | (album |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
60 | :initform nil :initarg :album :accessor album) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
61 | (genre |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
62 | :initform nil :initarg :genre :accessor genre) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
63 | (date |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
64 | :initform nil :initarg :date :accessor date) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
65 | (performer |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
66 | :initform nil :initarg :performer :accessor performer) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
67 | (composer |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
68 | :initform nil :initarg :composer :accessor composer) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
69 | (disc |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
70 | :initform nil :initarg :disc :accessor disc) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
71 | (track |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
72 | :initform nil :initarg :track :accessor track-number) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
73 | (time |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
74 | :initform nil :initarg :time :accessor duration) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
75 | (last-modified |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
76 | :initform nil :initarg :last-modified :accessor last-modified))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
77 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
78 | (defclass playlist (track) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
79 | ((pos |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
80 | :initform 0 :initarg :pos :accessor position-in-playlist |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
81 | :type integer) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
82 | (duration |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
83 | :initform nil :initarg :duration) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
84 | (format :initform nil :initarg :format) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
85 | (id |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
86 | :initform 0 :initarg :id :accessor id |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
87 | :type integer))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
88 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
89 | (defclass status () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
90 | ((volume |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
91 | :reader volume :initarg :volume :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
92 | (repeat |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
93 | :reader repeat :initarg :repeat :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
94 | (random |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
95 | :reader randomized :initarg :random :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
96 | (playlist |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
97 | :reader playlist-version :initarg :playlist :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
98 | (playlist-length |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
99 | :reader playlist-length :initarg :playlistlength :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
100 | (xfade |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
101 | :reader xfade :initarg :xfade :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
102 | (state |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
103 | :reader state :initarg :state :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
104 | (partition |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
105 | :reader partition :initarg :partition :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
106 | (audio |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
107 | :reader audio :initarg :audio :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
108 | (bitrate |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
109 | :reader bitrate :initarg :bitrate :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
110 | (duration |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
111 | :reader duration :initarg :duration :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
112 | (time |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
113 | :reader %time :initarg :time :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
114 | (songid |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
115 | :reader songid :initarg :songid :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
116 | (song :reader song :initarg :song :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
117 | (nextsongid |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
118 | :reader nextsongid :initarg :nextsongid :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
119 | (nextsong |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
120 | :reader nextsong :initarg :nextsong :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
121 | (elapsed |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
122 | :reader elapsed :initarg :elapsed :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
123 | (mixrampdb |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
124 | :reader mixrampdb :initarg :mixrampdb :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
125 | (consume |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
126 | :reader consume :initarg :consume :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
127 | (single |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
128 | :reader single :initarg :single :initform nil))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
129 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
130 | (defclass stats () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
131 | ((artists |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
132 | :reader artists :initarg :artists :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
133 | (albums |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
134 | :reader albums :initarg :albums :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
135 | (songs |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
136 | :reader songs :initarg :songs :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
137 | (uptime |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
138 | :reader uptime :initarg :uptime :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
139 | (playtime |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
140 | :reader playtime :initarg :playtime :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
141 | (db-playtime |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
142 | :reader db-playtime :initarg :db_playtime :initform nil) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
143 | (db-update |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
144 | :reader db-update :initarg :db_update :initform nil))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
145 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
146 | (macrolet ((generate-commands (class names) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
147 | `(progn |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
148 | ,@(mapcar (lambda (name) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
149 | `(defmethod ,name ((stream socket)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
150 | (,name (,class stream)))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
151 | names)))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
152 | (generate-commands status |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
153 | (volume repeat randomized playlist-version playlist-length |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
154 | xfade state audio bitrate duration songid song)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
155 | (generate-commands stats |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
156 | (artists albums songs uptime playtime db-playtime db-update))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
157 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
158 | (defparameter *integer-keys* |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
159 | '(:id :pos :volume :playlist :playlistlength |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
160 | :xfade :song :songid :bitrate :playtime |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
161 | :artists :albums :songs :uptime :db_playtime :db_update |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
162 | :outputid) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
163 | "List of keys which values must be integers.") |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
164 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
165 | (defparameter *value-processing-functions* |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
166 | '(:time parse-time :state to-keyword |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
167 | :random string-not-zerop :repeat string-not-zerop |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
168 | :outputenabled string-not-zerop)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
169 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
170 | (defmethod print-object ((object track) stream) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
171 | (print-unreadable-object (object stream :type t :identity t) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
172 | (with-slots (artist title album) object |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
173 | (format stream "~A - ~A (~A)" artist title album)))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
174 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
175 | ;;; MPD |
474
ea3b643a27a3
init glib and gstreamer FFI
Richard Westhaver <ellis@rwest.io>
parents:
402
diff
changeset
|
176 | (defvar *default-host* (or (sb-posix:getenv "MPD_HOST") "localhost")) |
ea3b643a27a3
init glib and gstreamer FFI
Richard Westhaver <ellis@rwest.io>
parents:
402
diff
changeset
|
177 | (defvar *default-port* (or (when-let ((port (sb-posix:getenv "MPD_PORT"))) (parse-integer port)) 6600)) |
279
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
178 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
179 | (defun connect (&key (host *default-host*) (port *default-port*) password) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
180 | "Connect to MPD." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
181 | (let ((connection (socket-connect (make-instance 'inet-socket :type :stream) (get-address-by-name host) port))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
182 | (prog1 (values connection |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
183 | (read-answer (socket-make-stream connection :input t :output t))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
184 | (when password |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
185 | (password connection password))))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
186 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
187 | (defun read-answer (stream) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
188 | (loop for line = (read-line stream) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
189 | until (string= line "OK" :end1 2) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
190 | collect line |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
191 | when (string= line "ACK" :end1 3) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
192 | do (throw-error line))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
193 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
194 | (defun throw-error (text) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
195 | ;; Error format: `ACK [<error id>@<position>] {<comand name>} <description>' |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
196 | (let* ((error-id (parse-integer text :start 5 :junk-allowed t)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
197 | (delimiter (position #\] text)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
198 | (condition (cdr (assoc error-id *error-ids-alist*)))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
199 | (error condition :text (subseq text (+ delimiter 2))))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
200 | |
365
49c3f3d11432
bug fixes and more tweaks for test macros
Richard Westhaver <ellis@rwest.io>
parents:
280
diff
changeset
|
201 | (eval-always |
49c3f3d11432
bug fixes and more tweaks for test macros
Richard Westhaver <ellis@rwest.io>
parents:
280
diff
changeset
|
202 | (defmacro with-mpc ((var &rest options) &body body) |
49c3f3d11432
bug fixes and more tweaks for test macros
Richard Westhaver <ellis@rwest.io>
parents:
280
diff
changeset
|
203 | `(let ((,var (connect ,@options))) |
49c3f3d11432
bug fixes and more tweaks for test macros
Richard Westhaver <ellis@rwest.io>
parents:
280
diff
changeset
|
204 | (unwind-protect |
49c3f3d11432
bug fixes and more tweaks for test macros
Richard Westhaver <ellis@rwest.io>
parents:
280
diff
changeset
|
205 | (progn ,@body) |
49c3f3d11432
bug fixes and more tweaks for test macros
Richard Westhaver <ellis@rwest.io>
parents:
280
diff
changeset
|
206 | (disconnect ,var))))) |
279
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
207 | |
402 | 208 | (defun ensure-mpd () |
209 | (handler-case |
|
210 | (with-mpc (c) t) |
|
211 | (not-exist () (sb-ext:run-program "mpd" nil :search t :directory (user-homedir-pathname) :wait nil)))) |
|
212 | ||
279
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
213 | (defun send-command (connection command) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
214 | "Send command to MPD." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
215 | (let ((stream (socket-make-stream connection :input t))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
216 | (unless (open-stream-p stream) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
217 | (error 'mpd-error :text (format nil "The stream ~A is not opened." stream))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
218 | (write-line command stream) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
219 | (finish-output stream) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
220 | (read-answer stream))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
221 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
222 | ;;; Parsing |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
223 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
224 | (defun to-keyword (name) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
225 | (intern (string-upcase name) :keyword)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
226 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
227 | (defun split-value (string) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
228 | "Split a string `key: value' into (list :key value)." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
229 | (let ((column (position #\: string))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
230 | (process-value (to-keyword (subseq string 0 column)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
231 | (subseq string (+ 2 column))))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
232 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
233 | (defun split-values (strings) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
234 | "Transform a list of strings 'key: value' into the plist." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
235 | (mapcan #'split-value strings)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
236 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
237 | (defun process-value (key value) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
238 | (list key |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
239 | (funcall (value-processing-function key) value))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
240 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
241 | (defun value-processing-function (key) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
242 | (if (member key *integer-keys*) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
243 | #'parse-integer |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
244 | (getf *value-processing-functions* key #'identity))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
245 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
246 | (defun parse-time (time) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
247 | "\"10:20\" -> (10 20); \"10\" -> 10" |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
248 | (multiple-value-bind (first stop) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
249 | (parse-integer time :junk-allowed t) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
250 | (if (= stop (length time)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
251 | first |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
252 | (list first |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
253 | (parse-integer time :start (1+ stop)))))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
254 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
255 | (defun string-not-zerop (string) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
256 | (not (string= string "0"))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
257 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
258 | (defun filter-keys (strings) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
259 | "Transform a list of strings 'key: value' into a list of values." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
260 | (mapcar (lambda (entry) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
261 | (subseq entry (+ 2 (position #\: entry)))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
262 | strings)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
263 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
264 | (defun make-class (data type) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
265 | "Make a new instance of the class playlist with initargs from |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
266 | the list of strings `key: value'." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
267 | (apply 'make-instance type (split-values data))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
268 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
269 | (defun parse-list (list &optional class) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
270 | "Make a list of new instances of the class `class' with initargs from |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
271 | a list of strings `key: value'. Each track is separeted by the `file' key." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
272 | (let (track) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
273 | (flet ((create-track () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
274 | (when track |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
275 | (list (apply 'make-instance class track))))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
276 | (nconc |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
277 | (mapcan (lambda (x) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
278 | (let ((pair (split-value x))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
279 | (case (car pair) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
280 | (:file (prog1 (create-track) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
281 | (setf track pair))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
282 | ((:directory :playlist) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
283 | (list pair)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
284 | (t (nconc track pair) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
285 | nil)))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
286 | list) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
287 | (create-track))))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
288 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
289 | ;;; |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
290 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
291 | (defun process-string (string) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
292 | "Check for emtpy strings, and escape strings when needed." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
293 | (when string |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
294 | (let ((string |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
295 | (string-trim '(#\Space #\Tab #\Newline) string))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
296 | (when (zerop (length string)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
297 | (error 'mpd-error :text "Zero length argument.")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
298 | (if (position #\Space string) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
299 | (prin1-to-string string) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
300 | string)))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
301 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
302 | ;;; Macros |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
303 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
304 | (defmacro send (&rest commands) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
305 | "Macro for using inside `defcommand'." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
306 | `(send-command connection |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
307 | (format nil "~{~A~^ ~}" |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
308 | (remove nil (list ,@commands))))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
309 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
310 | (defmacro defcommand (name parameters &body body) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
311 | `(defun ,name (connection ,@parameters) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
312 | ,@body)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
313 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
314 | (defmacro defmethod-command (name parameters &body body) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
315 | `(defmethod ,name (connection ,@parameters) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
316 | ,@body)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
317 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
318 | (defmacro check-args (type &rest args) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
319 | "Check string and integer arguments." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
320 | (if (or (eq type 'string) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
321 | (and (listp type) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
322 | (member 'string type))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
323 | `(progn ,@(mapcan |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
324 | (lambda (arg) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
325 | `((check-type ,arg ,type "a string") |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
326 | (setf ,arg (process-string ,arg)))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
327 | args)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
328 | `(progn ,@(mapcar |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
329 | (lambda (arg) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
330 | `(check-type ,arg ,type)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
331 | args)))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
332 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
333 | ;;; Commands |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
334 | (defcommand password (password) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
335 | "Authentication." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
336 | (check-args string password) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
337 | (send "password" password)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
338 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
339 | (defcommand disconnect () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
340 | "Close connection." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
341 | (socket-close connection)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
342 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
343 | (defcommand now-playing () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
344 | "Return instance of playlist with current song." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
345 | (let ((track (send "currentsong"))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
346 | (when track |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
347 | (make-class track 'playlist)))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
348 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
349 | (defcommand disable-output (id) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
350 | (check-args unsigned-byte id) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
351 | (send "disableoutput" id)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
352 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
353 | (defcommand enable-output (id) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
354 | (check-args unsigned-byte id) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
355 | (send "enableoutput" id)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
356 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
357 | (defcommand ping () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
358 | "Send ping to MPD." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
359 | (send "ping")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
360 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
361 | (defcommand kill () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
362 | "Stop MPD in a safe way." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
363 | (send "kill")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
364 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
365 | (defcommand status () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
366 | "Return status of MPD." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
367 | (make-class (send "status") 'status)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
368 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
369 | (defcommand stats () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
370 | "Return statisics." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
371 | (make-class (send "stats") 'stats)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
372 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
373 | (defcommand outputs () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
374 | "Return information about all outputs." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
375 | (split-values (send "outputs"))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
376 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
377 | (defcommand commands () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
378 | "Return list of available commands." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
379 | (filter-keys (send "commands"))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
380 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
381 | (defcommand not-commands () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
382 | "Return list of commands to which the current user does not have access." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
383 | (filter-keys |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
384 | (send "notcommands"))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
385 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
386 | ;;; Control |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
387 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
388 | (defcommand pause () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
389 | "Toggle pause / resume playing." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
390 | (send "pause")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
391 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
392 | (defcommand play (&optional song-number) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
393 | (check-args (or unsigned-byte null) song-number) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
394 | "Begin playing the playlist starting from song-number, default is 0." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
395 | (send "play" song-number)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
396 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
397 | (defcommand stop () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
398 | "Stop playing." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
399 | (send "stop")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
400 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
401 | (defcommand next () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
402 | "Play next track in the playlist." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
403 | (send "next")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
404 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
405 | (defcommand previous () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
406 | "Play previous track in the playlist." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
407 | (send "previous")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
408 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
409 | (defcommand crossfade (seconds) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
410 | (check-args unsigned-byte seconds) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
411 | "Sets crossfading between songs." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
412 | (send "crossfade" seconds)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
413 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
414 | ;; Playlist |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
415 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
416 | (defcommand list-playlist (name) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
417 | "List files in the playlist `name'" |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
418 | (check-args string name) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
419 | (filter-keys (send "listplaylist" name))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
420 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
421 | (defcommand list-playlist-info (name) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
422 | "List metadata of tracks in the playlist `name'" |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
423 | (check-args string name) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
424 | (parse-list (send "listplaylistinfo" name) 'playlist)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
425 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
426 | (defcommand clear () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
427 | "Clear the current playlist." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
428 | (send "clear")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
429 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
430 | (defcommand save-playlist (filename) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
431 | "Save the current playlist to the file in the playlist directory." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
432 | (check-args string filename) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
433 | (send "save" filename)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
434 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
435 | (defcommand load-playlist (filename) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
436 | "Load playlist from file." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
437 | (check-args string filename) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
438 | (send "load" filename)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
439 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
440 | (defcommand rename-playlist (name new-name) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
441 | "Rename playlist." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
442 | (check-args string name new-name) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
443 | (unless (equal name new-name) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
444 | (send "rename" name new-name))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
445 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
446 | (defcommand playlist-info (&optional id) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
447 | "Return content of the current playlist." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
448 | (check-args (or unsigned-byte null) id) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
449 | (if id |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
450 | (make-class (send "playlistinfo" id) 'playlist) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
451 | (parse-list (send "playlistinfo") 'playlist))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
452 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
453 | (defcommand playlist-changes (version) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
454 | "Return changed songs currently in the playlist since `version'." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
455 | (check-args unsigned-byte version) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
456 | (parse-list (send "plchanges" version) 'playlist)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
457 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
458 | (defcommand add-to-playlist (name path) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
459 | "Add `path' to the playlist `name'." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
460 | (check-args string name path) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
461 | (send "playlistadd" name path)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
462 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
463 | (defcommand clear-playlist (name) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
464 | "Clear playlist `name'." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
465 | (check-args string name) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
466 | (send "playlistclear")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
467 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
468 | (defcommand delete-from-playlist (name song-id) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
469 | "Delete `song-id' from playlist `name'." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
470 | (check-args string name) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
471 | (check-args unsigned-byte song-id) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
472 | (send "playlistdelete" name song-id)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
473 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
474 | (defcommand move-in-playlist (name song-id position) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
475 | "Move `song-id' in playlist `name' to `position'." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
476 | (check-args string name) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
477 | (check-args unsigned-byte song-id position) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
478 | (send "playlistmove" name song-id position)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
479 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
480 | (defcommand find-in-current-playlist (scope query) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
481 | "Search for songs in the current playlist with strict matching." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
482 | (check-args string scope query) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
483 | (send "playlistfind" scope query)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
484 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
485 | (defcommand search-in-current-playlist (scope query) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
486 | "Search case-insensitively with partial matches for songs in the current playlist" |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
487 | (check-args string scope query) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
488 | (send "playlistsearch" scope query)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
489 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
490 | (defgeneric add (connection what) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
491 | (:documentation "Add file or directory to the current playlist.")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
492 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
493 | (defmethod-command add ((what track)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
494 | (add connection (file what))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
495 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
496 | (defmethod-command add ((what string)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
497 | (check-args string what) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
498 | (send "add" what)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
499 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
500 | (defgeneric add-id (connection what) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
501 | (:documentation "Like add, but returns a id.")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
502 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
503 | (defmethod-command add-id ((what track)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
504 | (add connection (file what))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
505 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
506 | (defmethod-command add-id ((what string)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
507 | (check-args string what) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
508 | (car (filter-keys (send "addid" what)))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
509 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
510 | (defcommand move (from to) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
511 | "Move track from `from' to `to' in the playlist." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
512 | (check-args unsigned-byte from to) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
513 | (unless (= from to) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
514 | (send "move" from to))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
515 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
516 | (defgeneric move-id (connection id to) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
517 | (:documentation "Move track with `id' to `to' in the playlist.")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
518 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
519 | (defmethod-command move-id ((track playlist) (to integer)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
520 | (move-id connection (id track) to)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
521 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
522 | (defmethod-command move-id ((id integer) (to integer)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
523 | (check-args unsigned-byte id to) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
524 | (send "moveid" id to)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
525 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
526 | (defcommand swap (first second) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
527 | "Swap positions of two tracks." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
528 | (check-args unsigned-byte first second) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
529 | (unless (= first second) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
530 | (send "swap" first second))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
531 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
532 | (defgeneric swap-id (connection first second) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
533 | (:documentation "Swap positions of two tracks by id.")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
534 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
535 | (defmethod-command swap-id ((first playlist) (second playlist)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
536 | (swap-id connection (id first) (id second))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
537 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
538 | (defmethod-command swap-id ((first integer) (second integer)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
539 | (check-args unsigned-byte first second) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
540 | (send "swap" first second)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
541 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
542 | (defcommand delete-track (number) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
543 | "Delete track from playlist." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
544 | (check-args unsigned-byte number) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
545 | (send "delete" number)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
546 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
547 | (defgeneric delete-id (connection id) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
548 | (:documentation "Delete track with `id' from playlist.")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
549 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
550 | (defmethod-command delete-id ((id playlist)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
551 | (delete-id connection (id id))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
552 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
553 | (defmethod-command delete-id ((id integer)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
554 | (check-args unsigned-byte id) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
555 | (send "deleteid" id)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
556 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
557 | (defcommand shuffle () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
558 | "Shuffle the current playlist." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
559 | (send "shuffle")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
560 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
561 | ;;; Database |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
562 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
563 | (defcommand update (&optional path) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
564 | "Scan directory for music files and add them to the database." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
565 | (check-args string path) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
566 | (send "update" path)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
567 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
568 | (defcommand find-tracks (type what) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
569 | "Find tracks in the database with a case sensitive, exact match." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
570 | (check-args tag-type type) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
571 | (check-args string what) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
572 | (parse-list (send "find" type what) 'track)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
573 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
574 | (defcommand list-metadata (metadata-1 &optional metadata-2 search-term) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
575 | "List all metadata of `metadata-1'. |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
576 | If `metadata-2' & `search-term' are supplied, |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
577 | then list all `metadata-1' in which `metadata-2' has value `search-term'." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
578 | (check-args (or string null) search-term) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
579 | (send "list" metadata-1 metadata-2 search-term)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
580 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
581 | (defcommand search-tracks (type what) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
582 | "Find tracks in the database with a case sensitive, inexact match." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
583 | (check-args tag-type type) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
584 | (check-args string what) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
585 | (parse-list (send "search" type what) 'track)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
586 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
587 | (defcommand list-all-info (&optional path) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
588 | "Lists all information about files in `path' recursively. Default path is /." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
589 | (parse-list (send "listallinfo" path) 'track)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
590 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
591 | (defcommand list-all (&optional path) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
592 | "Lists all files in `path' recursively. Default path is /." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
593 | (check-args (or string null) path) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
594 | (filter-keys (send "listall" path))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
595 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
596 | (defcommand list-info (&optional path) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
597 | "Show contents of directory." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
598 | (check-args (or string null) path) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
599 | (parse-list (send "lsinfo" path) 'track)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
600 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
601 | (defcommand count-tracks (scope query) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
602 | "Number of songs and their total playtime matching `query'. |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
603 | Return: (number playtime)." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
604 | (check-args string query) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
605 | (filter-keys (send "count" scope query))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
606 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
607 | (defcommand tag-types () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
608 | "Get a list of available metadata types." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
609 | (filter-keys (send "tagtypes"))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
610 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
611 | (defcommand url-handlers () |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
612 | "Get a list of available URL handlers." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
613 | (filter-keys (send "urlhandlers"))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
614 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
615 | (defun (setf volume) (value connection) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
616 | "Set the volume to the value between 0-100." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
617 | (check-type value (integer 0 100) "an integer in range 0-100") |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
618 | (send "setvol" value)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
619 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
620 | (defun (setf randomized) (value connection) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
621 | "NIL---turn off random mode, non-nil---turn on random mode." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
622 | (send "random" (if value 1 0))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
623 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
624 | (defun (setf repeat) (value connection) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
625 | "NIL---turn off repeat mode, non-nil---turn on repeat mode." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
626 | (send "repeat" (if value 1 0))) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
627 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
628 | (defcommand seek (song time) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
629 | "Skip to a specified point in a song on the playlist." |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
630 | (send "seek" song time)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
631 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
632 | (defgeneric seek-id (connection song time) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
633 | (:documentation "Skip to a specified point in a song on the playlist.")) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
634 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
635 | (defmethod-command seek-id ((song playlist) (time integer)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
636 | (seek-id connection (id song) time)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
637 | |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
638 | (defmethod-command seek-id ((song integer) (time integer)) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
639 | (check-args unsigned-byte song time) |
efc3e9ec02bf
random tune-ups, added mpd and net/util.lisp
Richard Westhaver <ellis@rwest.io>
parents:
diff
changeset
|
640 | (send "seekid" song time)) |