ruby-mpd-client 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +6 -0
- data/lib/mpd/commands.rb +31 -13
- data/lib/mpd/commands/playlist_add.rb +20 -0
- data/lib/mpd/commands/playlist_info.rb +19 -0
- data/lib/mpd/commands/playlist_list.rb +17 -0
- data/lib/mpd/server_response.rb +12 -0
- data/lib/mpd/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8418f0f9f6feb888fefb0c1bba3dc1d8992ac221b6e9381278d27091b945a1e6
|
4
|
+
data.tar.gz: 65b8aa6e6f008f339de0766f4f06def5b0f6255db86c60997b0ace019557d240
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a954040ae3a4828b5b456d4d006ba02d2017b798a03249426db0661ff5e3c16fd439f581f59f03a543ef3db0eed0871183012352d155189b0b337f931163dc8a
|
7
|
+
data.tar.gz: ada812509e41842636a482d76821e2d75f2d72424410ff8572c29d399f9efc8b8cfdc4bdf9d7d1a36240f73472d1aa4fb86c9d0f3dc25d9b7d0aa813294ef490
|
data/.travis.yml
CHANGED
@@ -8,3 +8,4 @@ deploy:
|
|
8
8
|
secure: CCtmgUnWoiG4tKRalp9kfEcaeDUfipES0mcWPV4K0D/K651nxZ0kHe+VV+3rpvV1KDs4i5W+TosVvpH5lDL7+oALLFTsYgo3iam+kzMLfoskkZUuizUDxYjXrWI0T+SM0gL3Ax1J9oJ0cd7j1sUGi5TZ/IHXrKknm1yqFIx83mgKCFxYKJUAwQuwpo924ukqyQ0IsJtYX7AJ31hQwFBZSscJbriaxsz3dN+ptmvYVt9/+oIowHrvZCFnlgejel/eZ9iKCMR8buxx1RF3Q3y7LZkpMb20UBfjMwUkz/XBXGFCFVUaCLEcdFnAuoRePJ8a+q3Qkd0wZp+5g2offguVycTWsPTGgSjSAXcPUK0fOnE6bsBZ9XnkAiwkPtxO3MeG7iBcGBX2XY/Tzl+8EW2FgGeIICBh5sg+UqmrGAuqzmtgrJJwOaBeyLEbAKemAdPRfN7M0Hq1DgbOHchttmiCAY1Ja/RBiYwbEkZsPn9VI2tH3CUvdqc0B4jPV05OKU1sv06hHKJTWoCjsmvd52Tr0Kbr5ofBvLMj+uHnyCx78SwfReVCPEb2PzK5GUBG6+Ufu8UOTFdlS8gDmSO09R/qd/kSILvxCLntNVQAn/aUlnZ0aBJURxhoTQkKRSBGcGrOUXhMKnj3jnwZw1othJ5xxiSXy6fM/8JrsxyPH7TalT8=
|
9
9
|
on:
|
10
10
|
branch: master
|
11
|
+
tags: true
|
data/README.md
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
# Ruby MPD client
|
2
2
|
|
3
|
+
master: [![Build Status](https://travis-ci.org/Nondv/ruby-mpd-client.svg?branch=master)](https://travis-ci.org/Nondv/ruby-mpd-client)
|
4
|
+
develop: [![Build Status](https://travis-ci.org/Nondv/ruby-mpd-client.svg?branch=develop)](https://travis-ci.org/Nondv/ruby-mpd-client)
|
5
|
+
|
3
6
|
Yet another ruby mpd client.
|
4
7
|
|
5
8
|
This gem is for my own usage (practicing my programming skills). But
|
6
9
|
I would be glad to know if you found it useful.
|
7
10
|
|
11
|
+
See on [rubydoc](http://www.rubydoc.info/gems/ruby-mpd-client)
|
12
|
+
|
8
13
|
## Installation
|
9
14
|
|
10
15
|
```ruby
|
@@ -27,6 +32,7 @@ MPD::Commands::Next.new.execute
|
|
27
32
|
#
|
28
33
|
conn = MPD::Connection.new(host: 'localhost', port: 6600)
|
29
34
|
conn.connect
|
35
|
+
conn.gets # first MPD response is always "OK <version>\n"
|
30
36
|
MPD::Commands::Next.new(connection: conn).execute
|
31
37
|
MPD::Commands::Pause.new(connection: conn).execute
|
32
38
|
```
|
data/lib/mpd/commands.rb
CHANGED
@@ -44,18 +44,36 @@ module MPD
|
|
44
44
|
const_set(class_name, klass)
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
define_trivial_command(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
47
|
+
# @!macro [attach] define_trivial_command
|
48
|
+
# @!parse
|
49
|
+
# # Sends "$2" to MPD.
|
50
|
+
# class Commands::$1; end
|
51
|
+
define_trivial_command('Pause', 'pause 1')
|
52
|
+
define_trivial_command('Stop', 'stop')
|
53
|
+
define_trivial_command('Previous', 'previous')
|
54
|
+
define_trivial_command('Next', 'next')
|
55
|
+
define_trivial_command('CurrentPlaylistClear', 'clear')
|
56
|
+
|
57
|
+
# @!macro [attach] define_text_argument_command
|
58
|
+
# @!parse
|
59
|
+
# # Sends '$2 "<ARGUMENT>"' to MPD
|
60
|
+
# class Commands::$1; end
|
61
|
+
define_text_argument_command 'PlaylistDelete', :rm
|
62
|
+
define_text_argument_command 'PlaylistSave', :save
|
63
|
+
define_text_argument_command 'PlaylistLoad', :load
|
64
|
+
define_text_argument_command 'PlaylistClear', :playlistclear
|
65
|
+
|
66
|
+
# @!macro [attach] define_option_command
|
67
|
+
# @!parse
|
68
|
+
# # Sends '$2 <1/0>' to MPD
|
69
|
+
# class Commands::$1
|
70
|
+
# # @param state [Boolean]
|
71
|
+
# def execute(state); end
|
72
|
+
# end
|
73
|
+
define_option_command 'Consume', 'consume'
|
74
|
+
define_option_command 'Crossfade', 'crossfade'
|
75
|
+
define_option_command 'Random', 'random'
|
76
|
+
define_option_command 'Repeat', 'repeat'
|
77
|
+
define_option_command 'Single', 'single'
|
60
78
|
end
|
61
79
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'mpd/commands/abstract'
|
2
|
+
|
3
|
+
module MPD
|
4
|
+
module Commands
|
5
|
+
#
|
6
|
+
# Adds song(s) to specific playlist
|
7
|
+
# `songs` is an array of URIs.
|
8
|
+
#
|
9
|
+
class PlaylistAdd < Abstract
|
10
|
+
#
|
11
|
+
# `name` is playlist name.
|
12
|
+
# `songs` is position (as int) or range.
|
13
|
+
#
|
14
|
+
def execute(name, songs)
|
15
|
+
return exec_command("playlistadd \"#{name}\" \"#{songs}\"") unless songs.is_a?(Array)
|
16
|
+
exec_command_list(songs.map { |s| "playlistadd \"#{name}\" \"#{s}\"" })
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'mpd/commands/abstract'
|
2
|
+
|
3
|
+
module MPD
|
4
|
+
module Commands
|
5
|
+
#
|
6
|
+
# Info about songs in specific playlist.
|
7
|
+
# MPD command: "listplaylistinfo <NAME>"
|
8
|
+
#
|
9
|
+
class PlaylistInfo < Abstract
|
10
|
+
# `songs` can be range
|
11
|
+
# or integer (to show info about one song)
|
12
|
+
# or completely ommited (to show info about all songs)
|
13
|
+
def execute(name)
|
14
|
+
response = super("listplaylistinfo \"#{name}\"")
|
15
|
+
Playlist.from_response(response)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'mpd/commands/abstract'
|
2
|
+
|
3
|
+
module MPD
|
4
|
+
module Commands
|
5
|
+
#
|
6
|
+
# List of saved playlists.
|
7
|
+
#
|
8
|
+
class PlaylistList < Abstract
|
9
|
+
def execute
|
10
|
+
exec_command('listplaylists')
|
11
|
+
.key_value_pairs
|
12
|
+
.select { |k, v| k == 'playlist' }
|
13
|
+
.map(&:last)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/mpd/server_response.rb
CHANGED
@@ -3,6 +3,7 @@ module MPD
|
|
3
3
|
# Just a frozen string with some useful methods
|
4
4
|
#
|
5
5
|
class ServerResponse < String
|
6
|
+
# Reads data from `MPD::Connection` instance to next OK/ACK
|
6
7
|
def self.from_connection(conn)
|
7
8
|
line = ''
|
8
9
|
buffer = ''
|
@@ -24,6 +25,16 @@ module MPD
|
|
24
25
|
key_value_pairs.to_h
|
25
26
|
end
|
26
27
|
|
28
|
+
#
|
29
|
+
# MPD often sends data as:
|
30
|
+
#
|
31
|
+
# id: 1
|
32
|
+
# title: some title
|
33
|
+
# id: 2
|
34
|
+
# title: another title
|
35
|
+
#
|
36
|
+
# So this method comes useful.
|
37
|
+
#
|
27
38
|
def key_value_pairs
|
28
39
|
content.split("\n").map do |line|
|
29
40
|
index = line.index(':')
|
@@ -39,6 +50,7 @@ module MPD
|
|
39
50
|
lines[0..-2].join
|
40
51
|
end
|
41
52
|
|
53
|
+
# last line of response
|
42
54
|
def status
|
43
55
|
lines.last.chomp
|
44
56
|
end
|
data/lib/mpd/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-mpd-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitriy Non
|
@@ -77,6 +77,9 @@ files:
|
|
77
77
|
- lib/mpd/commands/current_song.rb
|
78
78
|
- lib/mpd/commands/ping.rb
|
79
79
|
- lib/mpd/commands/play.rb
|
80
|
+
- lib/mpd/commands/playlist_add.rb
|
81
|
+
- lib/mpd/commands/playlist_info.rb
|
82
|
+
- lib/mpd/commands/playlist_list.rb
|
80
83
|
- lib/mpd/commands/set_volume.rb
|
81
84
|
- lib/mpd/commands/status.rb
|
82
85
|
- lib/mpd/connection.rb
|