dacpclient 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +0 -2
- data/bin/dacpclient +33 -1
- data/dacpclient.gemspec +3 -1
- data/lib/dacpclient/client.rb +25 -6
- data/lib/dacpclient/models/album.rb +10 -0
- data/lib/dacpclient/models/albums.rb +10 -0
- data/lib/dacpclient/models/artist.rb +11 -0
- data/lib/dacpclient/models/artists.rb +10 -0
- data/lib/dacpclient/version.rb +1 -1
- metadata +37 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3655dc2c114e8a4aa0e4526ec54497b5369feb1
|
4
|
+
data.tar.gz: d0cba7a839a858361f9f6e253c03c129667bca1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99a79a86d06f1ff9594c4e97fd9ba77d9fba3432378a2a27315fc1e3d647af2eeba56751c3bd78740ef8e90482c33d1a438be7b667ec6c008389b6ce756f7a7d
|
7
|
+
data.tar.gz: e8b30bce34c24e55b82c78c4abad57b05aa0103b4f82202f7789f483f7962b04b7de82702b8675ed18c72c16ec47626f396093ca86c8bb6f298ce2d747cb7c22
|
data/Gemfile
CHANGED
data/bin/dacpclient
CHANGED
@@ -40,7 +40,7 @@ class CLIClient < Thor
|
|
40
40
|
sleep 0.5
|
41
41
|
end
|
42
42
|
|
43
|
-
pin = @config['pin'].to_s.chars.map
|
43
|
+
pin = @config['pin'].to_s.chars.map(&:to_i)
|
44
44
|
|
45
45
|
unless database
|
46
46
|
pin = 4.times.map { Random.rand(10) } if pin.empty?
|
@@ -131,6 +131,38 @@ class CLIClient < Thor
|
|
131
131
|
puts
|
132
132
|
end
|
133
133
|
|
134
|
+
desc :artists, 'Show the artists'
|
135
|
+
def artists
|
136
|
+
login
|
137
|
+
artists = @client.artists
|
138
|
+
puts 'Artists:'
|
139
|
+
puts '----------'
|
140
|
+
count = 0
|
141
|
+
num = Math.log10(artists.length).floor + 1
|
142
|
+
artists.each do |artist|
|
143
|
+
printf("%#{num}d. ", count += 1)
|
144
|
+
|
145
|
+
puts "#{artist.name} (#{artist.count} songs, #{artist.album_count} albums)"
|
146
|
+
end
|
147
|
+
puts
|
148
|
+
end
|
149
|
+
|
150
|
+
desc :albums, 'Show the albums'
|
151
|
+
def albums
|
152
|
+
login
|
153
|
+
albums = @client.albums
|
154
|
+
puts 'Albums:'
|
155
|
+
puts '----------'
|
156
|
+
count = 0
|
157
|
+
num = Math.log10(albums.length).floor + 1
|
158
|
+
albums.each do |album|
|
159
|
+
printf("%#{num}d. ", count += 1)
|
160
|
+
|
161
|
+
puts "#{album.name} [#{album.album_artist}] (#{album.count} songs)"
|
162
|
+
end
|
163
|
+
puts
|
164
|
+
end
|
165
|
+
|
134
166
|
desc :play_playlist, 'Plays a playlist'
|
135
167
|
def play_playlist(playlist)
|
136
168
|
login
|
data/dacpclient.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_runtime_dependency 'faraday', '~> 0.9.0'
|
23
23
|
spec.add_runtime_dependency 'dnssd', '~> 2.0'
|
24
24
|
spec.add_runtime_dependency 'plist', '~> 3.1.0'
|
25
|
-
spec.add_runtime_dependency 'dmapparser', '~> 0.
|
25
|
+
spec.add_runtime_dependency 'dmapparser', '~> 0.2.0'
|
26
26
|
spec.add_runtime_dependency 'thor', '~> 0.19.1'
|
27
27
|
spec.add_runtime_dependency 'fuzzy_match', '~> 2.1.0'
|
28
28
|
|
@@ -30,6 +30,8 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency 'redcarpet'
|
31
31
|
spec.add_development_dependency 'github-markup'
|
32
32
|
spec.add_development_dependency 'rake'
|
33
|
+
spec.add_development_dependency 'rubocop', '~> 0.27.1'
|
34
|
+
spec.add_development_dependency 'minitest', '~> 5.4.0'
|
33
35
|
|
34
36
|
spec.required_ruby_version = '>= 2.0.0'
|
35
37
|
end
|
data/lib/dacpclient/client.rb
CHANGED
@@ -15,6 +15,10 @@ require 'dacpclient/models/database'
|
|
15
15
|
require 'dacpclient/models/databases'
|
16
16
|
require 'dacpclient/models/playlist'
|
17
17
|
require 'dacpclient/models/playlists'
|
18
|
+
require 'dacpclient/models/artist'
|
19
|
+
require 'dacpclient/models/artists'
|
20
|
+
require 'dacpclient/models/album'
|
21
|
+
require 'dacpclient/models/albums'
|
18
22
|
require 'dacpclient/models/play_queue_item'
|
19
23
|
require 'dacpclient/models/play_queue'
|
20
24
|
|
@@ -219,7 +223,7 @@ module DACPClient
|
|
219
223
|
end
|
220
224
|
|
221
225
|
def default_playlist(db = default_db)
|
222
|
-
playlists(db).find
|
226
|
+
playlists(db).find(&:base_playlist?)
|
223
227
|
end
|
224
228
|
|
225
229
|
def artwork(database, id, width = 320, height = 320)
|
@@ -259,9 +263,23 @@ module DACPClient
|
|
259
263
|
com.apple.itunes.content-rating daap.songdatereleased
|
260
264
|
com.apple.itunes.movie-info-xml daap.songalbumartist
|
261
265
|
com.apple.itunes.extended-media-kind).join(',')
|
262
|
-
url = "databases/#{db.
|
263
|
-
do_action(url,
|
264
|
-
|
266
|
+
url = "databases/#{db.item_id}/containers/#{container.item_id}/items"
|
267
|
+
do_action(url, query: q, type: 'music', sort: 'album', meta: meta,
|
268
|
+
:'include-sort-headers' => 1, clean_url: true)
|
269
|
+
end
|
270
|
+
|
271
|
+
def artists(db = default_db)
|
272
|
+
url = "databases/#{db.item_id}/groups"
|
273
|
+
meta = 'dmap.itemname,dmap.itemid,dmap.persistentid,daap.songartist,daap.groupalbumcount,daap.songartistid'
|
274
|
+
query = "('daap.songartist!:'+('com.apple.itunes.extended-media-kind:1','com.apple.itunes.extended-media-kind:32'))"
|
275
|
+
do_action(url, meta: meta, type: 'music', :'group-type' => 'artists', sort: 'album', :'include-sort-headers' => 1, query: query, clean_url: true, model: Artists).items
|
276
|
+
end
|
277
|
+
|
278
|
+
def albums(db = default_db)
|
279
|
+
url = "databases/#{db.item_id}/groups"
|
280
|
+
meta = 'dmap.itemname,dmap.itemid,dmap.persistentid,daap.songartist,daap.songalbumartist'
|
281
|
+
query = "('daap.songartist!:'+('com.apple.itunes.extended-media-kind:1','com.apple.itunes.extended-media-kind:32'))"
|
282
|
+
do_action(url, meta: meta, type: 'music', :'group-type' => 'albums', sort: 'artist', :'include-sort-headers' => 1, query: query, clean_url: true, model: Albums).items
|
265
283
|
end
|
266
284
|
|
267
285
|
private
|
@@ -286,6 +304,7 @@ module DACPClient
|
|
286
304
|
params['session-id'] = @session_id.to_s
|
287
305
|
action = '/ctrl-int/1' + action unless clean_url
|
288
306
|
end
|
307
|
+
|
289
308
|
params['hsgid'] = @hsgid unless @hsgid.nil?
|
290
309
|
params = filter_param_keys(params)
|
291
310
|
result = @client.get do |request|
|
@@ -299,13 +318,13 @@ module DACPClient
|
|
299
318
|
end
|
300
319
|
|
301
320
|
def filter_param_keys(params)
|
302
|
-
Hash[
|
321
|
+
Hash[params.map { |k, v| [k.to_s.tr('_', '-'), v] }]
|
303
322
|
end
|
304
323
|
|
305
324
|
def parse_result(result, model)
|
306
325
|
if !result.success?
|
307
326
|
fail DACPForbiddenError, result
|
308
|
-
elsif result.headers['Content-Type'] == 'application/x-dmap-tagged'
|
327
|
+
elsif result.headers['Content-Type'] == 'application/x-dmap-tagged' && result.body.length > 0
|
309
328
|
res = DMAPParser::Parser.parse(result.body)
|
310
329
|
model ? model.new(res) : res
|
311
330
|
else
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module DACPClient
|
2
|
+
class Albums < Model
|
3
|
+
dmap_tag :agal
|
4
|
+
dmap_attribute :status, :mstt
|
5
|
+
dmap_attribute :update_type, :muty
|
6
|
+
dmap_attribute :container_count, :mtco
|
7
|
+
dmap_attribute :returned_count, :mrco
|
8
|
+
dmap_container :items, :mlcl, DACPClient::Album
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module DACPClient
|
2
|
+
class Artist < Model
|
3
|
+
dmap_tag :mlit
|
4
|
+
dmap_attribute :item_id, :miid
|
5
|
+
dmap_attribute :name, :minm
|
6
|
+
dmap_attribute :count, :mimc
|
7
|
+
dmap_attribute :album_count, :agac
|
8
|
+
dmap_attribute :song_artist_id, :asri
|
9
|
+
dmap_attribute :persistent_id, :mper
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module DACPClient
|
2
|
+
class Artists < Model
|
3
|
+
dmap_tag :agar
|
4
|
+
dmap_attribute :status, :mstt
|
5
|
+
dmap_attribute :update_type, :muty
|
6
|
+
dmap_attribute :container_count, :mtco
|
7
|
+
dmap_attribute :returned_count, :mrco
|
8
|
+
dmap_container :items, :mlcl, DACPClient::Artist
|
9
|
+
end
|
10
|
+
end
|
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.4
|
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-
|
11
|
+
date: 2014-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.2.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.2.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: thor
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +150,34 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.27.1
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.27.1
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: minitest
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 5.4.0
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 5.4.0
|
153
181
|
description: A DACP (iTunes Remote protocol) client
|
154
182
|
email:
|
155
183
|
- email@jurriaanpruis.nl
|
@@ -174,6 +202,10 @@ files:
|
|
174
202
|
- lib/dacpclient/faraday/flatter_params_encoder.rb
|
175
203
|
- lib/dacpclient/faraday/gzip.rb
|
176
204
|
- lib/dacpclient/model.rb
|
205
|
+
- lib/dacpclient/models/album.rb
|
206
|
+
- lib/dacpclient/models/albums.rb
|
207
|
+
- lib/dacpclient/models/artist.rb
|
208
|
+
- lib/dacpclient/models/artists.rb
|
177
209
|
- lib/dacpclient/models/database.rb
|
178
210
|
- lib/dacpclient/models/databases.rb
|
179
211
|
- lib/dacpclient/models/pair_info.rb
|
@@ -204,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
236
|
version: '0'
|
205
237
|
requirements: []
|
206
238
|
rubyforge_project:
|
207
|
-
rubygems_version: 2.
|
239
|
+
rubygems_version: 2.4.4
|
208
240
|
signing_key:
|
209
241
|
specification_version: 4
|
210
242
|
summary: A DACP (iTunes Remote protocol) client
|