xbmc-client 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/README.rdoc +379 -7
- data/Rakefile +21 -2
- data/VERSION +1 -1
- data/examples/audio_library.rb +3 -7
- data/examples/example_environment.rb +8 -0
- data/lib/xbmc-client.rb +1 -1
- data/lib/xbmc/command.rb +14 -5
- data/xbmc-client.gemspec +6 -4
- metadata +6 -4
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
= XBMC-Client
|
2
2
|
|
3
|
-
This is a simple Ruby client for the XBMC
|
3
|
+
This is a simple Ruby HTTP-based client for the XBMC Media Center JSON-RPC API.
|
4
4
|
|
5
5
|
It does not define all the API methods explicitly, but rather loads and defines them
|
6
|
-
on the fly by pulling the available namespaces and methods from the JSONRPC.Introspect
|
6
|
+
on the fly by pulling the available namespaces and methods from the <code>JSONRPC.Introspect</code>
|
7
7
|
call baked into the XBMC Api and thus has all methods described there available via
|
8
|
-
Xbmc::NAMESPACE.method_name_in_underscore_writing
|
9
|
-
|
8
|
+
<code>Xbmc::NAMESPACE.method_name_in_underscore_writing</code>, so for example the JSON RPC call
|
9
|
+
<code>AudioPlayer.PlayPause</code> becomes <code>Xbmc::AudioPlayer.play_pause</code> in Ruby.
|
10
10
|
|
11
11
|
Parameters can be passed in to all methods via the optional first argument to each
|
12
|
-
method call, which is expected to be a hash:
|
12
|
+
method call, which is expected to be a hash:
|
13
|
+
|
14
|
+
Xbmc::AudioLibrary.get_songs(:albumid => 1)
|
13
15
|
|
14
16
|
Note that this is a very early release and is considered experimental. There will
|
15
17
|
be bugs.
|
@@ -47,8 +49,8 @@ The client is being developed against Ruby 1.9.2, but should work with Ruby 1.8
|
|
47
49
|
Xbmc.invoke_and_process('JSONRPC.Introspect, :getdescriptions => 'true') # Will return the JSON-parsed response body's result subcollection
|
48
50
|
|
49
51
|
|
50
|
-
As you'll notice, it tries to automatically pull the correct collection for
|
51
|
-
calls, which means that you don't have to go to the subcollection [:result][:artists] in the
|
52
|
+
As you'll notice, it tries to automatically pull the correct collection for <code>get_xyz</code>
|
53
|
+
calls, which means that you don't have to go to the subcollection <code>[:result][:artists]</code> in the
|
52
54
|
above example like you would if the response would be returned unprocessed.
|
53
55
|
|
54
56
|
See the examples directory in the repository for further usage examples!
|
@@ -56,6 +58,376 @@ See the examples directory in the repository for further usage examples!
|
|
56
58
|
Also, be sure to check out the API docs at the XBMC wiki:
|
57
59
|
http://wiki.xbmc.org/index.php?title=JSON_RPC
|
58
60
|
|
61
|
+
== Available API Methods
|
62
|
+
|
63
|
+
Please note that the API is loaded dynamically and thus this ultimately depends on your version of XBMC. This listing is generated automatically using <code>rake rdoc:apidoc</code>
|
64
|
+
|
65
|
+
=== Xbmc::JSONRPC.introspect
|
66
|
+
|
67
|
+
Enumerates all actions and descriptions. Parameter example {"getdescriptions": true, "getpermissions": true, "filterbytransport": true }. All parameters optional
|
68
|
+
|
69
|
+
=== Xbmc::JSONRPC.version
|
70
|
+
|
71
|
+
Retrieve the jsonrpc protocol version
|
72
|
+
|
73
|
+
=== Xbmc::JSONRPC.permission
|
74
|
+
|
75
|
+
Retrieve the clients permissions
|
76
|
+
|
77
|
+
=== Xbmc::JSONRPC.ping
|
78
|
+
|
79
|
+
Ping responder
|
80
|
+
|
81
|
+
=== Xbmc::JSONRPC.announce
|
82
|
+
|
83
|
+
Announce to other connected clients. Parameter example {"sender": "foo", "message": "bar", "data": "somedata" }. data is optional
|
84
|
+
|
85
|
+
=== Xbmc::Player.get_active_players
|
86
|
+
|
87
|
+
Returns all active players IDs
|
88
|
+
|
89
|
+
=== Xbmc::AudioPlayer.state
|
90
|
+
|
91
|
+
Returns Current Playback state
|
92
|
+
|
93
|
+
=== Xbmc::AudioPlayer.play_pause
|
94
|
+
|
95
|
+
Pauses or unpause playback, returns new state
|
96
|
+
|
97
|
+
=== Xbmc::AudioPlayer.stop
|
98
|
+
|
99
|
+
Stops playback
|
100
|
+
|
101
|
+
=== Xbmc::AudioPlayer.skip_previous
|
102
|
+
|
103
|
+
Skips to previous item on the playlist
|
104
|
+
|
105
|
+
=== Xbmc::AudioPlayer.skip_next
|
106
|
+
|
107
|
+
Skips to next item on the playlist
|
108
|
+
|
109
|
+
=== Xbmc::AudioPlayer.big_skip_backward
|
110
|
+
|
111
|
+
=== Xbmc::AudioPlayer.big_skip_forward
|
112
|
+
|
113
|
+
=== Xbmc::AudioPlayer.small_skip_backward
|
114
|
+
|
115
|
+
=== Xbmc::AudioPlayer.small_skip_forward
|
116
|
+
|
117
|
+
=== Xbmc::AudioPlayer.rewind
|
118
|
+
|
119
|
+
Rewind current playback
|
120
|
+
|
121
|
+
=== Xbmc::AudioPlayer.forward
|
122
|
+
|
123
|
+
Forward current playback
|
124
|
+
|
125
|
+
=== Xbmc::AudioPlayer.get_time
|
126
|
+
|
127
|
+
Retrieve time
|
128
|
+
|
129
|
+
=== Xbmc::AudioPlayer.get_time_ms
|
130
|
+
|
131
|
+
Retrieve time in MS
|
132
|
+
|
133
|
+
=== Xbmc::AudioPlayer.get_percentage
|
134
|
+
|
135
|
+
Retrieve percentage
|
136
|
+
|
137
|
+
=== Xbmc::AudioPlayer.seek_time
|
138
|
+
|
139
|
+
Seek to a specific time. Parameter integer in seconds
|
140
|
+
|
141
|
+
=== Xbmc::AudioPlayer.seek_percentage
|
142
|
+
|
143
|
+
Seek to a specific percentage. Parameter float or integer from 0 to 100
|
144
|
+
|
145
|
+
=== Xbmc::AudioPlayer.record
|
146
|
+
|
147
|
+
=== Xbmc::VideoPlayer.state
|
148
|
+
|
149
|
+
Returns Current Playback state
|
150
|
+
|
151
|
+
=== Xbmc::VideoPlayer.play_pause
|
152
|
+
|
153
|
+
Pauses or unpause playback, returns new state
|
154
|
+
|
155
|
+
=== Xbmc::VideoPlayer.stop
|
156
|
+
|
157
|
+
Stops playback
|
158
|
+
|
159
|
+
=== Xbmc::VideoPlayer.skip_previous
|
160
|
+
|
161
|
+
Skips to previous item on the playlist
|
162
|
+
|
163
|
+
=== Xbmc::VideoPlayer.skip_next
|
164
|
+
|
165
|
+
Skips to next item on the playlist
|
166
|
+
|
167
|
+
=== Xbmc::VideoPlayer.big_skip_backward
|
168
|
+
|
169
|
+
=== Xbmc::VideoPlayer.big_skip_forward
|
170
|
+
|
171
|
+
=== Xbmc::VideoPlayer.small_skip_backward
|
172
|
+
|
173
|
+
=== Xbmc::VideoPlayer.small_skip_forward
|
174
|
+
|
175
|
+
=== Xbmc::VideoPlayer.rewind
|
176
|
+
|
177
|
+
Rewind current playback
|
178
|
+
|
179
|
+
=== Xbmc::VideoPlayer.forward
|
180
|
+
|
181
|
+
Forward current playback
|
182
|
+
|
183
|
+
=== Xbmc::VideoPlayer.get_time
|
184
|
+
|
185
|
+
Retrieve time
|
186
|
+
|
187
|
+
=== Xbmc::VideoPlayer.get_time_ms
|
188
|
+
|
189
|
+
Retrieve time in MS
|
190
|
+
|
191
|
+
=== Xbmc::VideoPlayer.get_percentage
|
192
|
+
|
193
|
+
Retrieve percentage
|
194
|
+
|
195
|
+
=== Xbmc::VideoPlayer.seek_time
|
196
|
+
|
197
|
+
Seek to a specific time. Parameter integer in seconds
|
198
|
+
|
199
|
+
=== Xbmc::VideoPlayer.seek_percentage
|
200
|
+
|
201
|
+
Seek to a specific percentage. Parameter float or integer from 0 to 100
|
202
|
+
|
203
|
+
=== Xbmc::PicturePlayer.play_pause
|
204
|
+
|
205
|
+
Pauses or unpause slideshow
|
206
|
+
|
207
|
+
=== Xbmc::PicturePlayer.stop
|
208
|
+
|
209
|
+
Stops slideshow
|
210
|
+
|
211
|
+
=== Xbmc::PicturePlayer.skip_previous
|
212
|
+
|
213
|
+
Skips to previous picture in the slideshow
|
214
|
+
|
215
|
+
=== Xbmc::PicturePlayer.skip_next
|
216
|
+
|
217
|
+
Skips to next picture in the slideshow
|
218
|
+
|
219
|
+
=== Xbmc::PicturePlayer.move_left
|
220
|
+
|
221
|
+
If picture is zoomed move viewport left otherwise skip previous
|
222
|
+
|
223
|
+
=== Xbmc::PicturePlayer.move_right
|
224
|
+
|
225
|
+
If picture is zoomed move viewport right otherwise skip previous
|
226
|
+
|
227
|
+
=== Xbmc::PicturePlayer.move_down
|
228
|
+
|
229
|
+
If picture is zoomed move viewport down
|
230
|
+
|
231
|
+
=== Xbmc::PicturePlayer.move_up
|
232
|
+
|
233
|
+
If picture is zoomed move viewport up
|
234
|
+
|
235
|
+
=== Xbmc::PicturePlayer.zoom_out
|
236
|
+
|
237
|
+
Zoom out once
|
238
|
+
|
239
|
+
=== Xbmc::PicturePlayer.zoom_in
|
240
|
+
|
241
|
+
Zoom in once
|
242
|
+
|
243
|
+
=== Xbmc::PicturePlayer.zoom
|
244
|
+
|
245
|
+
Zooms current picture. Parameter integer of zoom level
|
246
|
+
|
247
|
+
=== Xbmc::PicturePlayer.rotate
|
248
|
+
|
249
|
+
Rotates current picture
|
250
|
+
|
251
|
+
=== Xbmc::VideoPlaylist.play
|
252
|
+
|
253
|
+
=== Xbmc::VideoPlaylist.skip_previous
|
254
|
+
|
255
|
+
=== Xbmc::VideoPlaylist.skip_next
|
256
|
+
|
257
|
+
=== Xbmc::VideoPlaylist.get_items
|
258
|
+
|
259
|
+
=== Xbmc::VideoPlaylist.add
|
260
|
+
|
261
|
+
=== Xbmc::VideoPlaylist.clear
|
262
|
+
|
263
|
+
Clear video playlist
|
264
|
+
|
265
|
+
=== Xbmc::VideoPlaylist.shuffle
|
266
|
+
|
267
|
+
Shuffle video playlist
|
268
|
+
|
269
|
+
=== Xbmc::VideoPlaylist.un_shuffle
|
270
|
+
|
271
|
+
UnShuffle video playlist
|
272
|
+
|
273
|
+
=== Xbmc::AudioPlaylist.play
|
274
|
+
|
275
|
+
=== Xbmc::AudioPlaylist.skip_previous
|
276
|
+
|
277
|
+
=== Xbmc::AudioPlaylist.skip_next
|
278
|
+
|
279
|
+
=== Xbmc::AudioPlaylist.get_items
|
280
|
+
|
281
|
+
=== Xbmc::AudioPlaylist.add
|
282
|
+
|
283
|
+
=== Xbmc::AudioPlaylist.clear
|
284
|
+
|
285
|
+
Clear audio playlist
|
286
|
+
|
287
|
+
=== Xbmc::AudioPlaylist.shuffle
|
288
|
+
|
289
|
+
Shuffle audio playlist
|
290
|
+
|
291
|
+
=== Xbmc::AudioPlaylist.un_shuffle
|
292
|
+
|
293
|
+
UnShuffle audio playlist
|
294
|
+
|
295
|
+
=== Xbmc::Playlist.create
|
296
|
+
|
297
|
+
Creates a virtual playlist from a given one from a file
|
298
|
+
|
299
|
+
=== Xbmc::Playlist.destroy
|
300
|
+
|
301
|
+
Destroys a virtual playlist
|
302
|
+
|
303
|
+
=== Xbmc::Playlist.get_items
|
304
|
+
|
305
|
+
Retrieve items in the playlist. Parameter example {"playlist": "music" }. playlist optional.
|
306
|
+
|
307
|
+
=== Xbmc::Playlist.add
|
308
|
+
|
309
|
+
Add items to the playlist. Parameter example {"playlist": "music", "file": "/foo/bar.mp3" }. playlist optional.
|
310
|
+
|
311
|
+
=== Xbmc::Playlist.remove
|
312
|
+
|
313
|
+
Remove items in the playlist. Parameter example {"playlist": "music", "item": 0 }. playlist optional.
|
314
|
+
|
315
|
+
=== Xbmc::Playlist.swap
|
316
|
+
|
317
|
+
Swap items in the playlist. Parameter example {"playlist": "music", "item1": 0, "item2": 1 }. playlist optional.
|
318
|
+
|
319
|
+
=== Xbmc::Playlist.shuffle
|
320
|
+
|
321
|
+
Shuffle playlist
|
322
|
+
|
323
|
+
=== Xbmc::Playlist.un_shuffle
|
324
|
+
|
325
|
+
UnShuffle playlist
|
326
|
+
|
327
|
+
=== Xbmc::Files.get_sources
|
328
|
+
|
329
|
+
Get the sources of the media windows. Parameter example {"media": "video"}. Media can be video, music, pictures or files
|
330
|
+
|
331
|
+
=== Xbmc::Files.download
|
332
|
+
|
333
|
+
Specify a file to download to get info about how to download it, i.e a proper URL
|
334
|
+
|
335
|
+
=== Xbmc::Files.get_directory
|
336
|
+
|
337
|
+
Retrieve the specified directory. Parameter example {"directory": "foo/bar", "media": "video"}. Media can be video, music, pictures or files
|
338
|
+
|
339
|
+
=== Xbmc::AudioLibrary.get_artists
|
340
|
+
|
341
|
+
Retrieve all artists
|
342
|
+
|
343
|
+
=== Xbmc::AudioLibrary.get_albums
|
344
|
+
|
345
|
+
Retrieve all albums from specified artist or genre, Fields: album_description, album_theme, album_mood, album_style, album_type, album_label, album_artist, album_genre, album_rating, album_title
|
346
|
+
|
347
|
+
=== Xbmc::AudioLibrary.get_songs
|
348
|
+
|
349
|
+
Retrieve all songs from specified album, artist or genre
|
350
|
+
|
351
|
+
=== Xbmc::AudioLibrary.scan_for_content
|
352
|
+
|
353
|
+
=== Xbmc::VideoLibrary.get_movies
|
354
|
+
|
355
|
+
Retrieve all movies. Parameter example { "fields": ["plot"], "sortmethod": "title", "sortorder": "ascending", "start": 0, "end": 3}. fields, sortorder, sortmethod, start and end are optional
|
356
|
+
|
357
|
+
=== Xbmc::VideoLibrary.get_tv_shows
|
358
|
+
|
359
|
+
Parameter example { "fields": ["plot"], "sortmethod": "label", "sortorder": "ascending", "start": 0, "end": 3}. sortorder, sortmethod, start and end are optional
|
360
|
+
|
361
|
+
=== Xbmc::VideoLibrary.get_seasons
|
362
|
+
|
363
|
+
Parameter example { "tvshowid": 0, "fields": ["season"], "sortmethod": "label", "sortorder": "ascending", "start": 0, "end": 3}. sortorder, sortmethod, start and end are optional
|
364
|
+
|
365
|
+
=== Xbmc::VideoLibrary.get_episodes
|
366
|
+
|
367
|
+
Parameter example { "tvshowid": 0, "season": 1, "fields": ["plot"], "sortmethod": "episode", "sortorder": "ascending", "start": 0, "end": 3}. sortorder, sortmethod, start and end are optional
|
368
|
+
|
369
|
+
=== Xbmc::VideoLibrary.get_music_videos
|
370
|
+
|
371
|
+
Parameter example { "artistid": 0, "albumid": 0, "fields": ["plot"], "sortmethod": "artistignorethe", "sortorder": "ascending", "start": 0, "end": 3}. sortorder, sortmethod, start and end are optional
|
372
|
+
|
373
|
+
=== Xbmc::VideoLibrary.get_recently_added_movies
|
374
|
+
|
375
|
+
Retrieve all recently added movies. Parameter example { "fields": ["plot"], "sortmethod": "title", "sortorder": "ascending", "start": 0, "end": 3}. fields, sortorder, sortmethod, start and end are optional
|
376
|
+
|
377
|
+
=== Xbmc::VideoLibrary.get_recently_added_episodes
|
378
|
+
|
379
|
+
Retrieve all recently added episodes. Parameter example { "fields": ["plot"], "sortmethod": "title", "sortorder": "ascending", "start": 0, "end": 3}. fields, sortorder, sortmethod, start and end are optional
|
380
|
+
|
381
|
+
=== Xbmc::VideoLibrary.get_recently_added_music_videos
|
382
|
+
|
383
|
+
Retrieve all recently added music videos. Parameter example { "fields": ["plot"], "sortmethod": "title", "sortorder": "ascending", "start": 0, "end": 3}. fields, sortorder, sortmethod, start and end are optional
|
384
|
+
|
385
|
+
=== Xbmc::VideoLibrary.scan_for_content
|
386
|
+
|
387
|
+
=== Xbmc::System.shutdown
|
388
|
+
|
389
|
+
=== Xbmc::System.suspend
|
390
|
+
|
391
|
+
=== Xbmc::System.hibernate
|
392
|
+
|
393
|
+
=== Xbmc::System.reboot
|
394
|
+
|
395
|
+
=== Xbmc::System.get_info_labels
|
396
|
+
|
397
|
+
Retrieve info labels about the system
|
398
|
+
|
399
|
+
=== Xbmc::System.get_info_booleans
|
400
|
+
|
401
|
+
Retrieve info booleans about the system
|
402
|
+
|
403
|
+
=== Xbmc::XBMC.get_volume
|
404
|
+
|
405
|
+
Retrieve the current volume
|
406
|
+
|
407
|
+
=== Xbmc::XBMC.set_volume
|
408
|
+
|
409
|
+
Set volume. Parameter integer between 0 amd 100
|
410
|
+
|
411
|
+
=== Xbmc::XBMC.toggle_mute
|
412
|
+
|
413
|
+
Toggle mute
|
414
|
+
|
415
|
+
=== Xbmc::XBMC.play
|
416
|
+
|
417
|
+
Starts playback
|
418
|
+
|
419
|
+
=== Xbmc::XBMC.start_slideshow
|
420
|
+
|
421
|
+
Starts slideshow. Parameter example {"directory": "/foo/", "random": true, "recursive": true} or just string to recursively and random run directory
|
422
|
+
|
423
|
+
=== Xbmc::XBMC.log
|
424
|
+
|
425
|
+
Logs a line in the xbmc.log. Parameter example {"message": "foo", "level": "info"} or just a string to log message with level debug
|
426
|
+
|
427
|
+
=== Xbmc::XBMC.quit
|
428
|
+
|
429
|
+
Quit xbmc
|
430
|
+
|
59
431
|
== Issues
|
60
432
|
|
61
433
|
* No unit tests
|
data/Rakefile
CHANGED
@@ -5,8 +5,8 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "xbmc-client"
|
8
|
-
gem.summary = %Q{A simple API client for the XBMC JSON-RPC API}
|
9
|
-
gem.description = %Q{A simple API client for the XBMC JSON-RPC API}
|
8
|
+
gem.summary = %Q{A simple API client for the XBMC Media Center JSON-RPC API}
|
9
|
+
gem.description = %Q{A simple API client for the XBMC Media Center JSON-RPC API}
|
10
10
|
gem.email = "christoph at olszowka de"
|
11
11
|
gem.homepage = "http://github.com/colszowka/xbmc-client"
|
12
12
|
|
@@ -57,3 +57,22 @@ Rake::RDocTask.new do |rdoc|
|
|
57
57
|
rdoc.rdoc_files.include('README*')
|
58
58
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
59
59
|
end
|
60
|
+
|
61
|
+
namespace :rdoc do
|
62
|
+
desc "Generates an RDOC-formatted list of available commands"
|
63
|
+
task :apidoc do
|
64
|
+
require File.join(File.dirname(__FILE__), 'lib/xbmc-client')
|
65
|
+
# Configure to your settings!
|
66
|
+
Xbmc.base_uri "http://localhost:8435"
|
67
|
+
Xbmc.basic_auth "xbmc", "xbmc"
|
68
|
+
|
69
|
+
puts "== Available API Methods", ""
|
70
|
+
puts "Please note that the API is loaded dynamically and thus this ultimately depends on your version of XBMC. This listing is generated automatically using <code>rake rdoc:apidoc</code>", ""
|
71
|
+
|
72
|
+
Xbmc.commands.each do |command|
|
73
|
+
puts "=== #{command.klass_name}.#{command.method_name}"
|
74
|
+
puts "\n#{command.description}" if command.description.present?
|
75
|
+
puts
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/examples/audio_library.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
|
2
|
-
require './' + File.join(File.dirname(__FILE__), '../lib', 'xbmc-client')
|
1
|
+
# Some example calls for interacting with the Audio Library in XBMC
|
3
2
|
|
4
|
-
|
5
|
-
Xbmc.basic_auth "xbmc", "xbmc"
|
6
|
-
|
7
|
-
Xbmc.load_api!
|
3
|
+
require "./" + File.join(File.dirname(__FILE__), 'example_environment')
|
8
4
|
|
9
5
|
pp Xbmc::AudioLibrary.get_artists
|
10
6
|
puts "="*60
|
@@ -12,4 +8,4 @@ pp Xbmc::AudioLibrary.get_albums(:artistid => Xbmc::AudioLibrary.get_artists.fir
|
|
12
8
|
puts "="*60
|
13
9
|
pp Xbmc::AudioLibrary.get_songs(:albumid => 1)
|
14
10
|
|
15
|
-
pp Xbmc::AudioPlayer.play_pause
|
11
|
+
pp Xbmc::AudioPlayer.play_pause
|
data/lib/xbmc-client.rb
CHANGED
@@ -35,7 +35,7 @@ class Xbmc
|
|
35
35
|
|
36
36
|
# Returns an array of available api commands instantiated as Xbmc::Command objects
|
37
37
|
def commands
|
38
|
-
@commands ||= invoke_and_process("JSONRPC.Introspect", :getdescriptions => true)[:commands].map {|c| Xbmc::Command.new(c
|
38
|
+
@commands ||= invoke_and_process("JSONRPC.Introspect", :getdescriptions => true)[:commands].map {|c| Xbmc::Command.new(c)}
|
39
39
|
end
|
40
40
|
|
41
41
|
# Loads the available commands via JSONRPC.Introspect and defines the namespace classes and corresponding methods
|
data/lib/xbmc/command.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
# Representation of a XBMC JSON RPC method
|
2
2
|
class Xbmc::Command
|
3
|
-
attr_reader :command, :namespace, :method_name, :original_method
|
3
|
+
attr_reader :command, :namespace, :method_name, :original_method, :description
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
# Initializes a new command from the meta data hash given in JSONRPC.Introspect
|
6
|
+
def initialize(command_meta)
|
7
|
+
@command_meta = command_meta.with_indifferent_access
|
8
|
+
@description = command_meta[:description]
|
9
|
+
@command = command_meta[:command]
|
7
10
|
parse_command!
|
8
11
|
end
|
9
12
|
|
@@ -11,7 +14,12 @@ class Xbmc::Command
|
|
11
14
|
def invoke(params={})
|
12
15
|
process_result(Xbmc.invoke_and_process(command, params))
|
13
16
|
end
|
14
|
-
|
17
|
+
|
18
|
+
# The ruby class name this command should end up in
|
19
|
+
def klass_name
|
20
|
+
"Xbmc::#{namespace}"
|
21
|
+
end
|
22
|
+
|
15
23
|
private
|
16
24
|
|
17
25
|
# Extract the namespace and method names from the given JSON RPC raw command name
|
@@ -23,7 +31,6 @@ class Xbmc::Command
|
|
23
31
|
# Will create the corresponding class for namespace if not defined yet
|
24
32
|
# and also define the given method
|
25
33
|
def define_method!
|
26
|
-
klass_name = "Xbmc::#{namespace}"
|
27
34
|
begin
|
28
35
|
klass = klass_name.constantize
|
29
36
|
rescue NameError => err
|
@@ -31,7 +38,9 @@ class Xbmc::Command
|
|
31
38
|
klass = klass_name.constantize
|
32
39
|
end
|
33
40
|
|
41
|
+
# Need to assign instance to local var because "self" is out of scope inside the method definition
|
34
42
|
command_object = self
|
43
|
+
# Define class method in corresponding namespace class
|
35
44
|
klass.metaclass.send(:define_method, method_name.to_sym) do |*args|
|
36
45
|
command_object.invoke(*args)
|
37
46
|
end
|
data/xbmc-client.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{xbmc-client}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Christoph Olszowka"]
|
12
12
|
s.date = %q{2010-11-25}
|
13
|
-
s.description = %q{A simple API client for the XBMC JSON-RPC API}
|
13
|
+
s.description = %q{A simple API client for the XBMC Media Center JSON-RPC API}
|
14
14
|
s.email = %q{christoph at olszowka de}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"Rakefile",
|
28
28
|
"VERSION",
|
29
29
|
"examples/audio_library.rb",
|
30
|
+
"examples/example_environment.rb",
|
30
31
|
"lib/ruby_ext.rb",
|
31
32
|
"lib/xbmc-client.rb",
|
32
33
|
"lib/xbmc/command.rb",
|
@@ -38,11 +39,12 @@ Gem::Specification.new do |s|
|
|
38
39
|
s.rdoc_options = ["--charset=UTF-8"]
|
39
40
|
s.require_paths = ["lib"]
|
40
41
|
s.rubygems_version = %q{1.3.7}
|
41
|
-
s.summary = %q{A simple API client for the XBMC JSON-RPC API}
|
42
|
+
s.summary = %q{A simple API client for the XBMC Media Center JSON-RPC API}
|
42
43
|
s.test_files = [
|
43
44
|
"test/helper.rb",
|
44
45
|
"test/test_xbmc-client.rb",
|
45
|
-
"examples/audio_library.rb"
|
46
|
+
"examples/audio_library.rb",
|
47
|
+
"examples/example_environment.rb"
|
46
48
|
]
|
47
49
|
|
48
50
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Christoph Olszowka
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
version: 2.10.3
|
91
91
|
type: :development
|
92
92
|
version_requirements: *id005
|
93
|
-
description: A simple API client for the XBMC JSON-RPC API
|
93
|
+
description: A simple API client for the XBMC Media Center JSON-RPC API
|
94
94
|
email: christoph at olszowka de
|
95
95
|
executables: []
|
96
96
|
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- Rakefile
|
111
111
|
- VERSION
|
112
112
|
- examples/audio_library.rb
|
113
|
+
- examples/example_environment.rb
|
113
114
|
- lib/ruby_ext.rb
|
114
115
|
- lib/xbmc-client.rb
|
115
116
|
- lib/xbmc/command.rb
|
@@ -147,8 +148,9 @@ rubyforge_project:
|
|
147
148
|
rubygems_version: 1.3.7
|
148
149
|
signing_key:
|
149
150
|
specification_version: 3
|
150
|
-
summary: A simple API client for the XBMC JSON-RPC API
|
151
|
+
summary: A simple API client for the XBMC Media Center JSON-RPC API
|
151
152
|
test_files:
|
152
153
|
- test/helper.rb
|
153
154
|
- test/test_xbmc-client.rb
|
154
155
|
- examples/audio_library.rb
|
156
|
+
- examples/example_environment.rb
|