mpd_client 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +23 -0
- data/MPD_COMMANDS.md +49 -19
- data/README.md +3 -1
- data/lib/mpd_client.rb +35 -18
- data/lib/mpd_client/version.rb +1 -1
- metadata +9 -10
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f4e6e63e19367101a4fe97e8cc2cec2c9670a2db
|
4
|
+
data.tar.gz: 885cada023e75ab8891ef8c092fdf86ffddefa8f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2063ffee152d4698f8e8c593b113c50c7d41d4a57fc98ad145fc72a2485e19781a8f93f2c1ae5f4ac75a8d53e221ae472df200289e698ac44d1cf8c0dba153ae
|
7
|
+
data.tar.gz: 5b9cb922941282c395da464aebcb4149b3acdfbc920872680e83256c66c621897496dee28318e7a66111574af01ed31803bb722cf98eb49a4fdb3d389e645904
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# MPDClient CHANGELOG
|
2
|
+
|
3
|
+
### 0.0.4
|
4
|
+
|
5
|
+
* Added support for readcomments, toggleoutput, volume
|
6
|
+
* Added a mutex protecting execution of MPD commands
|
7
|
+
* Automatic reconnect after the server dropped the connection
|
8
|
+
|
9
|
+
### 0.0.3
|
10
|
+
|
11
|
+
* Support for logging
|
12
|
+
* Better support for fetching stickers from MPD
|
13
|
+
* Fixed sticker commands
|
14
|
+
* Add support for ranges
|
15
|
+
|
16
|
+
### 0.0.2
|
17
|
+
|
18
|
+
* Support for connecting to unix domain sockets
|
19
|
+
* Fixed some bugs
|
20
|
+
|
21
|
+
### 0.0.1
|
22
|
+
|
23
|
+
* Porting code from mpd-python2
|
data/MPD_COMMANDS.md
CHANGED
@@ -1,4 +1,15 @@
|
|
1
|
-
|
1
|
+
* [Status Commands](#status-commands)
|
2
|
+
* [Playback Option Commands](#playback-option-commands)
|
3
|
+
* [Playback Control Commands](#playback-control-commands)
|
4
|
+
* [Playlist Commands](#playlist-commands)
|
5
|
+
* [Stored Playlist Commands](#stored-playlist-commands)
|
6
|
+
* [Database Commands](#database-commands)
|
7
|
+
* [Sticker Commands](#sticker-commands)
|
8
|
+
* [Connection Commands](#connection-commands)
|
9
|
+
* [Reflection Commands](#reflection-commands)
|
10
|
+
* [Client to client](#client-to-client)
|
11
|
+
|
12
|
+
### Status Commands ###
|
2
13
|
|
3
14
|
---
|
4
15
|
`clearerror => fetch_nothing`
|
@@ -27,7 +38,7 @@
|
|
27
38
|
* `subscription`: a client has subscribed or unsubscribed to a channel
|
28
39
|
* `message`: a message was received on a channel this client is subscribed to; this event is only emitted when the queue is empty
|
29
40
|
|
30
|
-
> While a client is waiting for `idle` results, the server disables timeouts, allowing a client to wait for events as long as mpd runs. The `idle` command can be canceled by sending the command `noidle` (no other commands are allowed). MPD will then leave `idle` mode and print results immediately; might be empty at this time.
|
41
|
+
> While a client is waiting for `idle` results, the server disables timeouts, allowing a client to wait for events as long as mpd runs. The `idle` command can be canceled by sending the command `noidle` (no other commands are allowed). MPD will then leave `idle` mode and print results immediately; might be empty at this time.
|
31
42
|
|
32
43
|
> If the optional `SUBSYSTEMS` argument is used, MPD will only send notifications when something changed in one of the specified subsytems.
|
33
44
|
|
@@ -75,7 +86,7 @@
|
|
75
86
|
* `db_update`: last db update in UNIX time
|
76
87
|
* `playtime`: time length of music played
|
77
88
|
|
78
|
-
### Playback Option Commands
|
89
|
+
### Playback Option Commands ###
|
79
90
|
|
80
91
|
---
|
81
92
|
`consume {STATE} => fetch_nothing`
|
@@ -90,7 +101,7 @@
|
|
90
101
|
---
|
91
102
|
`mixrampdb {deciBels} => fetch_nothing`
|
92
103
|
|
93
|
-
> Sets the threshold at which songs will be overlapped. Like crossfading but doesn't fade the track volume, just overlaps. The songs need to have MixRamp tags added by an external tool. 0dB is the normalized maximum volume so use negative values, I prefer -17dB. In the absence of mixramp tags crossfading will be used. See http://sourceforge.net/projects/mixramp
|
104
|
+
> Sets the threshold at which songs will be overlapped. Like crossfading but doesn't fade the track volume, just overlaps. The songs need to have MixRamp tags added by an external tool. 0dB is the normalized maximum volume so use negative values, I prefer -17dB. In the absence of mixramp tags crossfading will be used. See http://sourceforge.net/projects/mixramp
|
94
105
|
|
95
106
|
---
|
96
107
|
`mixrampdelay {SECONDS} => fetch_nothing`
|
@@ -115,7 +126,7 @@
|
|
115
126
|
---
|
116
127
|
`single {STATE} => fetch_nothing`
|
117
128
|
|
118
|
-
> Sets single state to `STATE`, `STATE` should be 0 or 1. When single is activated, playback is stopped after current song, or song is repeated if the 'repeat' mode is enabled.
|
129
|
+
> Sets single state to `STATE`, `STATE` should be 0 or 1. When single is activated, playback is stopped after current song, or song is repeated if the 'repeat' mode is enabled.
|
119
130
|
|
120
131
|
---
|
121
132
|
`replay_gain_mode {MODE} => fetch_nothing`
|
@@ -131,8 +142,12 @@
|
|
131
142
|
|
132
143
|
> Prints replay gain options. Currently, only the variable `replay_gain_mode` is returned.
|
133
144
|
|
145
|
+
---
|
146
|
+
`volume {CHANGE} => fetch_nothing`
|
147
|
+
|
148
|
+
> Changes volume by amount `CHANGE`.
|
134
149
|
|
135
|
-
### Playback Control Commands
|
150
|
+
### Playback Control Commands ###
|
136
151
|
|
137
152
|
---
|
138
153
|
`next => fetch_nothing`
|
@@ -181,7 +196,7 @@
|
|
181
196
|
> Stops playing.
|
182
197
|
|
183
198
|
|
184
|
-
### Playlist Commands
|
199
|
+
### Playlist Commands ###
|
185
200
|
|
186
201
|
---
|
187
202
|
`add {URI} => fetch_nothing`
|
@@ -257,7 +272,7 @@
|
|
257
272
|
---
|
258
273
|
`plchangesposid {VERSION} => fetch_changes`
|
259
274
|
|
260
|
-
> Displays changed songs currently in the playlist since `VERSION`. This function only returns the position and the id of the changed song, not the complete metadata. This is more bandwidth efficient.
|
275
|
+
> Displays changed songs currently in the playlist since `VERSION`. This function only returns the position and the id of the changed song, not the complete metadata. This is more bandwidth efficient.
|
261
276
|
|
262
277
|
> To detect songs that were deleted at the end of the playlist, use `playlistlength` returned by status command.
|
263
278
|
|
@@ -288,7 +303,7 @@
|
|
288
303
|
|
289
304
|
Swaps the positions of `SONG1` and `SONG2` (both song ids).
|
290
305
|
|
291
|
-
### Stored Playlist Commands
|
306
|
+
### Stored Playlist Commands ###
|
292
307
|
|
293
308
|
Playlists are stored inside the configured playlist directory. They are addressed with their file name (without the directory and without the .m3u suffix).
|
294
309
|
|
@@ -309,7 +324,7 @@ Some of the commands described in this section can be used to run playlist plugi
|
|
309
324
|
|
310
325
|
> Prints a list of the playlist directory.
|
311
326
|
|
312
|
-
> After each playlist name the server sends its last modification time as attribute "Last-Modified" in ISO 8601 format. To avoid problems due to clock differences between clients and the server, clients should not compare this value with their local clock.
|
327
|
+
> After each playlist name the server sends its last modification time as attribute "Last-Modified" in ISO 8601 format. To avoid problems due to clock differences between clients and the server, clients should not compare this value with their local clock.
|
313
328
|
|
314
329
|
---
|
315
330
|
`load {NAME} [START:END] => fetch_nothing`
|
@@ -353,7 +368,7 @@ Some of the commands described in this section can be used to run playlist plugi
|
|
353
368
|
|
354
369
|
> Saves the current playlist to `NAME.m3u` in the playlist directory.
|
355
370
|
|
356
|
-
### Database Commands
|
371
|
+
### Database Commands ###
|
357
372
|
|
358
373
|
---
|
359
374
|
`count {TAG} {NEEDLE} => fetch_object`
|
@@ -363,7 +378,7 @@ Some of the commands described in this section can be used to run playlist plugi
|
|
363
378
|
---
|
364
379
|
`find {TYPE} {WHAT} [...] => fetch_songs`
|
365
380
|
|
366
|
-
> Finds songs in the db that are exactly `WHAT`. `TYPE` can be any tag supported by MPD, or one of the two special parameters — file to search by full path (relative to database root), and any to match against all available tags. `WHAT` is what to find.
|
381
|
+
> Finds songs in the db that are exactly `WHAT`. `TYPE` can be any tag supported by MPD, or one of the two special parameters — file to search by full path (relative to database root), and any to match against all available tags. `WHAT` is what to find.
|
367
382
|
|
368
383
|
---
|
369
384
|
`findadd {TYPE} {WHAT} [...] => fetch_nothing`
|
@@ -431,9 +446,18 @@ Some of the commands described in this section can be used to run playlist plugi
|
|
431
446
|
|
432
447
|
> Same as `update`, but also rescans unmodified files.
|
433
448
|
|
434
|
-
|
449
|
+
---
|
450
|
+
`readcomments [URI] => fetch_object`
|
451
|
+
|
452
|
+
> Read "comments" (i.e. key-value pairs) from the file specified by `URI`. This `URI` can be a path relative to the music directory or a URL in the form `file:///foo/bar.ogg`.
|
453
|
+
|
454
|
+
> The response consists of lines in the form "KEY: VALUE". Comments with suspicious characters (e.g. newlines) are ignored silently.
|
435
455
|
|
436
|
-
|
456
|
+
> The meaning of these depends on the codec, and not all decoder plugins support it. For example, on Ogg files, this lists the Vorbis comments.
|
457
|
+
|
458
|
+
### Sticker Commands ###
|
459
|
+
|
460
|
+
"Stickers" are pieces of information attached to existing MPD objects (e.g. song files, directories, albums). Clients can create arbitrary name/value pairs. MPD itself does not assume any special meaning in them.
|
437
461
|
|
438
462
|
The goal is to allow clients to share additional (possibly dynamic) information about songs, which is neither stored on the client (not available to other clients), nor stored in the song files (MPD has no write access).
|
439
463
|
|
@@ -466,7 +490,7 @@ Objects which may have stickers are addressed by their object type ("song" for s
|
|
466
490
|
|
467
491
|
> Searches the sticker database for stickers with the specified name, below the specified directory (`URI`). For each matching song, it prints the URI and that one sticker's value.
|
468
492
|
|
469
|
-
### Connection Commands
|
493
|
+
### Connection Commands ###
|
470
494
|
|
471
495
|
---
|
472
496
|
`close`
|
@@ -505,7 +529,13 @@ Objects which may have stickers are addressed by their object type ("song" for s
|
|
505
529
|
|
506
530
|
> Shows information about all outputs.
|
507
531
|
|
508
|
-
|
532
|
+
---
|
533
|
+
`toggleoutput {ID} => fetch_nothing`
|
534
|
+
|
535
|
+
> Turns an output on or off, depending on the current state.
|
536
|
+
|
537
|
+
|
538
|
+
### Reflection Commands ###
|
509
539
|
|
510
540
|
---
|
511
541
|
`config => fetch_item`
|
@@ -544,11 +574,11 @@ Objects which may have stickers are addressed by their object type ("song" for s
|
|
544
574
|
|
545
575
|
> Print a list of decoder plugins, followed by their supported suffixes and MIME types.
|
546
576
|
|
547
|
-
### Client to client
|
577
|
+
### Client to client ###
|
548
578
|
|
549
|
-
Clients can communicate with each others over "channels". A channel is created by a client subscribing to it. More than one client can be subscribed to a channel at a time; all of them will receive the messages which get sent to it.
|
579
|
+
Clients can communicate with each others over "channels". A channel is created by a client subscribing to it. More than one client can be subscribed to a channel at a time; all of them will receive the messages which get sent to it.
|
550
580
|
|
551
|
-
Each time a client subscribes or unsubscribes, the global idle event subscription is generated. In conjunction with the channels command, this may be used to auto-detect clients providing additional services.
|
581
|
+
Each time a client subscribes or unsubscribes, the global idle event subscription is generated. In conjunction with the channels command, this may be used to auto-detect clients providing additional services.
|
552
582
|
|
553
583
|
New messages are indicated by the message idle event.
|
554
584
|
|
data/README.md
CHANGED
@@ -110,6 +110,8 @@ For more information about logging configuration, see http://www.ruby-doc.org/st
|
|
110
110
|
4. Push to the branch (`git push origin my-new-feature`)
|
111
111
|
5. Create new Pull Request
|
112
112
|
|
113
|
-
## License
|
113
|
+
## License and Author
|
114
|
+
|
115
|
+
Copyright (c) 2013 by Anton Maminov
|
114
116
|
|
115
117
|
This library is distributed under the MIT license. Please see the LICENSE file.
|
data/lib/mpd_client.rb
CHANGED
@@ -31,6 +31,7 @@ COMMANDS = {
|
|
31
31
|
"single" => "fetch_nothing",
|
32
32
|
"replay_gain_mode" => "fetch_nothing",
|
33
33
|
"replay_gain_status" => "fetch_item",
|
34
|
+
"volume" => "fetch_nothing",
|
34
35
|
# Playback Control Commands
|
35
36
|
"next" => "fetch_nothing",
|
36
37
|
"pause" => "fetch_nothing",
|
@@ -86,6 +87,7 @@ COMMANDS = {
|
|
86
87
|
"searchaddp1" => "fetch_nothing",
|
87
88
|
"update" => "fetch_item",
|
88
89
|
"rescan" => "fetch_item",
|
90
|
+
"readcomments" => "fetch_item",
|
89
91
|
# Sticker Commands
|
90
92
|
"sticker get" => "fetch_sticker",
|
91
93
|
"sticker set" => "fetch_nothing",
|
@@ -101,6 +103,7 @@ COMMANDS = {
|
|
101
103
|
"disableoutput" => "fetch_nothing",
|
102
104
|
"enableoutput" => "fetch_nothing",
|
103
105
|
"outputs" => "fetch_outputs",
|
106
|
+
"toggleoutput" => "fetch_nothing",
|
104
107
|
# Reflection Commands
|
105
108
|
"config" => "fetch_item",
|
106
109
|
"commands" => "fetch_list",
|
@@ -151,22 +154,29 @@ class MPDClient
|
|
151
154
|
end
|
152
155
|
|
153
156
|
def initialize
|
157
|
+
@mutex = Mutex.new
|
154
158
|
reset
|
155
159
|
end
|
156
160
|
|
157
161
|
def connect(host = 'localhost', port = 6600)
|
158
|
-
|
159
|
-
|
160
|
-
|
162
|
+
@host = host
|
163
|
+
@port = port
|
164
|
+
reconnect
|
165
|
+
end
|
166
|
+
|
167
|
+
def reconnect
|
168
|
+
log.info("MPD (re)connect #{host}, #{port}") if log
|
169
|
+
if @host.start_with?('/')
|
170
|
+
@socket = UNIXSocket.new(@host)
|
161
171
|
hello
|
162
172
|
else
|
163
|
-
@socket = TCPSocket.new(host, port)
|
173
|
+
@socket = TCPSocket.new(@host, @port)
|
164
174
|
hello
|
165
175
|
end
|
166
176
|
end
|
167
177
|
|
168
178
|
def disconnect
|
169
|
-
log.info("MPD disconnect")
|
179
|
+
log.info("MPD disconnect") if log
|
170
180
|
@socket.close
|
171
181
|
reset
|
172
182
|
end
|
@@ -181,7 +191,7 @@ class MPDClient
|
|
181
191
|
def command_list_end
|
182
192
|
raise "Not in command list" if @command_list.nil?
|
183
193
|
write_command('command_list_end')
|
184
|
-
|
194
|
+
|
185
195
|
return fetch_command_list
|
186
196
|
end
|
187
197
|
|
@@ -200,17 +210,24 @@ class MPDClient
|
|
200
210
|
private
|
201
211
|
|
202
212
|
def execute(command, *args, retval)
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
213
|
+
@mutex.synchronize do
|
214
|
+
if !@command_list.nil?
|
215
|
+
write_command(command, *args)
|
216
|
+
@command_list << retval
|
217
|
+
else
|
218
|
+
write_command(command, *args)
|
219
|
+
eval retval
|
220
|
+
end
|
209
221
|
end
|
210
222
|
end
|
211
223
|
|
212
224
|
def write_line(line)
|
213
|
-
|
225
|
+
begin
|
226
|
+
@socket.puts line
|
227
|
+
rescue Errno::EPIPE
|
228
|
+
reconnect
|
229
|
+
@socket.puts line
|
230
|
+
end
|
214
231
|
@socket.flush
|
215
232
|
end
|
216
233
|
|
@@ -319,19 +336,19 @@ class MPDClient
|
|
319
336
|
end
|
320
337
|
|
321
338
|
def fetch_changes; fetch_objects(['cpos']); end
|
322
|
-
|
339
|
+
|
323
340
|
def fetch_songs; fetch_objects(['file']); end
|
324
341
|
|
325
342
|
def fetch_messages; fetch_objects('channel'); end
|
326
343
|
|
327
344
|
def fetch_outputs; fetch_objects(['outputid']); end
|
328
|
-
|
345
|
+
|
329
346
|
def fetch_plugins; fetch_objects(['plugin']); end
|
330
347
|
|
331
348
|
def fetch_database; fetch_objects(['file', 'directory', 'playlist']); end
|
332
|
-
|
349
|
+
|
333
350
|
def fetch_playlists; fetch_objects(['playlist']); end
|
334
|
-
|
351
|
+
|
335
352
|
def fetch_playlist
|
336
353
|
result = []
|
337
354
|
read_pairs(':').each do |key, value|
|
@@ -363,7 +380,7 @@ class MPDClient
|
|
363
380
|
ensure
|
364
381
|
@command_list = nil
|
365
382
|
end
|
366
|
-
|
383
|
+
|
367
384
|
return result
|
368
385
|
end
|
369
386
|
|
data/lib/mpd_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mpd_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Anton Maminov
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-12-06 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: Yet another Ruby MPD client library
|
15
14
|
email:
|
@@ -18,7 +17,8 @@ executables: []
|
|
18
17
|
extensions: []
|
19
18
|
extra_rdoc_files: []
|
20
19
|
files:
|
21
|
-
- .gitignore
|
20
|
+
- ".gitignore"
|
21
|
+
- CHANGELOG.md
|
22
22
|
- Gemfile
|
23
23
|
- LICENSE
|
24
24
|
- MPD_COMMANDS.md
|
@@ -33,26 +33,25 @@ files:
|
|
33
33
|
- mpd_client.gemspec
|
34
34
|
homepage: https://github.com/mamantoha/mpd_client
|
35
35
|
licenses: []
|
36
|
+
metadata: {}
|
36
37
|
post_install_message:
|
37
38
|
rdoc_options: []
|
38
39
|
require_paths:
|
39
40
|
- lib
|
40
41
|
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
-
none: false
|
48
47
|
requirements:
|
49
|
-
- -
|
48
|
+
- - ">="
|
50
49
|
- !ruby/object:Gem::Version
|
51
50
|
version: '0'
|
52
51
|
requirements: []
|
53
52
|
rubyforge_project:
|
54
|
-
rubygems_version:
|
53
|
+
rubygems_version: 2.4.2
|
55
54
|
signing_key:
|
56
|
-
specification_version:
|
55
|
+
specification_version: 4
|
57
56
|
summary: Simple Music Player Daemon library written entirely in Ruby
|
58
57
|
test_files: []
|