dacpclient 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/bin/dacpclient +16 -12
- data/lib/dacpclient/browser.rb +10 -10
- data/lib/dacpclient/pairingserver.rb +4 -4
- data/lib/dacpclient/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75fdfc2a63bf7ff3c54194931d3a8475ad297f44
|
4
|
+
data.tar.gz: b3a5fe9f909c13a9ef96d7e8b6dd97d40db0d682
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca6dee63a426109a45be94fa670ef322d2f7623576157727fba03fb056829f94f0bc731c9b216dc4480552743d76ef2dc13dec8259582f6196ef1fef328440d2
|
7
|
+
data.tar.gz: e1a8d069672cd29e0546cdfb8c3b766244ac0880fc8e627f857a89667936c6cdb18821ceb6b38560d89d26fdc43987bbd092f3740a7901d80bcadd00e147efd6
|
data/README.md
CHANGED
@@ -29,7 +29,7 @@ Or install it yourself using:
|
|
29
29
|
|
30
30
|
See [bin/dacpclient](https://github.com/jurriaan/ruby-dacpclient/blob/master/bin/dacpclient)
|
31
31
|
|
32
|
-
DACPClient v0.3.
|
32
|
+
DACPClient v0.3.1
|
33
33
|
(c) 2014 Jurriaan Pruis <email@jurriaanpruis.nl>
|
34
34
|
|
35
35
|
DACPClient commands:
|
@@ -37,11 +37,11 @@ See [bin/dacpclient](https://github.com/jurriaan/ruby-dacpclient/blob/master/bin
|
|
37
37
|
dacpclient help [COMMAND] # Describe available commands or one specific command
|
38
38
|
dacpclient hostname # Set the hostname
|
39
39
|
dacpclient next # Go to next item
|
40
|
-
dacpclient pause # Pause
|
40
|
+
dacpclient pause # Pause playing
|
41
41
|
dacpclient play # Start playing
|
42
42
|
dacpclient play_playlist # Plays a playlist
|
43
43
|
dacpclient playlists # Show the playlists
|
44
|
-
dacpclient playpause # Toggle
|
44
|
+
dacpclient playpause # Toggle playing
|
45
45
|
dacpclient prev # Go to previous item
|
46
46
|
dacpclient status # Shows the status of the DACP server
|
47
47
|
dacpclient stop # Stop playing
|
@@ -59,6 +59,7 @@ See [bin/dacpclient](https://github.com/jurriaan/ruby-dacpclient/blob/master/bin
|
|
59
59
|
|
60
60
|
## Contributors
|
61
61
|
|
62
|
+
- [Daisuke Shimamoto](https://github.com/diskshima)
|
62
63
|
- [Jurriaan Pruis](https://github.com/jurriaan)
|
63
64
|
|
64
65
|
## Thanks
|
data/bin/dacpclient
CHANGED
@@ -18,8 +18,7 @@ class CLIClient < Thor
|
|
18
18
|
@config = {}
|
19
19
|
@config['client_name'] ||= "DACPClient (#{Socket.gethostname})"
|
20
20
|
@config['host'] ||= 'localhost'
|
21
|
-
@config['
|
22
|
-
|
21
|
+
@config['known_services'] ||= []
|
23
22
|
load_config
|
24
23
|
|
25
24
|
if @config['guid'].nil? || @config['guid'] !~ /^[A-F0-9]{16}$/
|
@@ -34,24 +33,27 @@ class CLIClient < Thor
|
|
34
33
|
|
35
34
|
3.times do
|
36
35
|
browser.browse
|
37
|
-
database = browser.
|
38
|
-
@config['
|
36
|
+
database = browser.services.find do |service|
|
37
|
+
@config['known_services'].include? service.name
|
39
38
|
end
|
40
39
|
break if database
|
41
40
|
sleep 0.5
|
42
41
|
end
|
43
42
|
|
43
|
+
pin = @config['pin'].to_s.chars.map { |num| num.to_i }
|
44
|
+
|
44
45
|
unless database
|
45
|
-
pin = 4.times.map { Random.rand(10) } if pin.
|
46
|
+
pin = 4.times.map { Random.rand(10) } if pin.empty?
|
46
47
|
puts 'Cannot find paired Libraries, waiting for a pair request..'
|
47
48
|
puts "Pincode: #{pin}"
|
48
49
|
pairserver = DACPClient::PairingServer.new(@config['client_name'],
|
49
50
|
@config['guid'])
|
50
51
|
pairserver.pin = pin
|
51
52
|
database = pairserver.start
|
52
|
-
@config['
|
53
|
+
@config['known_services'] << database.name
|
53
54
|
save_config
|
54
55
|
end
|
56
|
+
|
55
57
|
@client = DACPClient::Client.new(@config['client_name'], database.host,
|
56
58
|
database.port)
|
57
59
|
@client.guid = @config['guid']
|
@@ -237,6 +239,7 @@ class CLIClient < Thor
|
|
237
239
|
end
|
238
240
|
end
|
239
241
|
end
|
242
|
+
|
240
243
|
loop do
|
241
244
|
status = @client.status true
|
242
245
|
start_time = Time.now.to_f * 1000.0
|
@@ -252,10 +255,11 @@ class CLIClient < Thor
|
|
252
255
|
@client.login
|
253
256
|
end
|
254
257
|
@login = true
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
258
|
+
|
259
|
+
return if @client.host == @config['host']
|
260
|
+
|
261
|
+
@config['host'] = @client.host
|
262
|
+
save_config
|
259
263
|
end
|
260
264
|
|
261
265
|
def format_time(millis)
|
@@ -299,8 +303,8 @@ class CLIClient < Thor
|
|
299
303
|
end
|
300
304
|
|
301
305
|
def clean_config
|
302
|
-
@config['
|
303
|
-
@config['
|
306
|
+
@config['known_services'].delete('')
|
307
|
+
@config['known_services'].uniq!
|
304
308
|
end
|
305
309
|
|
306
310
|
def save_config
|
data/lib/dacpclient/browser.rb
CHANGED
@@ -4,34 +4,34 @@ require 'ostruct'
|
|
4
4
|
module DACPClient
|
5
5
|
# The Client class handles communication with the server
|
6
6
|
class Browser
|
7
|
-
class
|
8
|
-
def
|
9
|
-
text_records['
|
7
|
+
class Service < Struct.new(:name, :host, :port, :text_records)
|
8
|
+
def library_name
|
9
|
+
text_records['CtlN'] || text_records['Machine Name']
|
10
10
|
end
|
11
11
|
|
12
12
|
def database_id
|
13
|
-
text_records['
|
13
|
+
text_records['DbId'] || text_records['Database ID']
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
DAAP_SERVICE = '_daap._tcp'.freeze
|
18
18
|
TOUCHABLE_SERVICE = '_touch-able._tcp'.freeze
|
19
19
|
|
20
|
-
attr_reader :
|
20
|
+
attr_reader :services
|
21
21
|
|
22
22
|
def initialize
|
23
|
-
@
|
23
|
+
@services = []
|
24
24
|
end
|
25
25
|
|
26
26
|
def browse
|
27
|
-
@
|
27
|
+
@services = []
|
28
28
|
timeout(5) do
|
29
29
|
DNSSD.browse!(TOUCHABLE_SERVICE) do |node|
|
30
30
|
resolve(node)
|
31
31
|
break unless node.flags.more_coming?
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
34
|
+
services
|
35
35
|
rescue Timeout::Error # => e
|
36
36
|
[]
|
37
37
|
end
|
@@ -39,8 +39,8 @@ module DACPClient
|
|
39
39
|
private
|
40
40
|
|
41
41
|
def node_resolver(_node, resolved)
|
42
|
-
|
43
|
-
|
42
|
+
services << Service.new(resolved.name, get_device_host(resolved),
|
43
|
+
resolved.port, resolved.text_record)
|
44
44
|
|
45
45
|
resolved.flags.more_coming?
|
46
46
|
end
|
@@ -29,7 +29,6 @@ module DACPClient
|
|
29
29
|
@browser = DACPClient::Browser.new
|
30
30
|
@browser.browse
|
31
31
|
|
32
|
-
PairInfo.new(DMAPParser::Parser.parse(@pairing_string))
|
33
32
|
super
|
34
33
|
join
|
35
34
|
|
@@ -46,10 +45,11 @@ module DACPClient
|
|
46
45
|
|
47
46
|
def serve(client)
|
48
47
|
data = client.gets
|
49
|
-
|
50
|
-
@peer = @browser.
|
51
|
-
|
48
|
+
|
49
|
+
@peer = @browser.services.find do |service|
|
50
|
+
data =~ /servicename=#{service.name}/i
|
52
51
|
end
|
52
|
+
|
53
53
|
if data =~ /pairingcode=#{@expected}/i && @peer
|
54
54
|
client.print "HTTP/1.1 200 OK\n" \
|
55
55
|
"Content-Length: #{@pairing_string.length}\n\n"
|
data/lib/dacpclient/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dacpclient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jurriaan Pruis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|