alexa_remotectl 0.4.2 → 0.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 769f37b93490b3ab472fea0e8bc15dc1ce3c2e34cb3b4c01ce0ddc6c296fdff9
4
- data.tar.gz: 66bdfb5add38d18635c34469ebd2a508a152daa76319c043ccfc81c67569781d
3
+ metadata.gz: f3390f693c5318ae22b5c79fbe464dacd839ef331c4d3f2a07e9aeed38229be2
4
+ data.tar.gz: adb89f569f0f47f88304c5032b963e171c556d340f928dd70de0437318c9b09f
5
5
  SHA512:
6
- metadata.gz: 50ae6554ebe0f56317439880759316c90cfcd154d564cf45db4d517c5471115a10d0f4bad197e74090f96cc952fa9bf8f5f1dd43c0889285c78822022fd488ad
7
- data.tar.gz: ab6a5c377f4575298d29dbe02592a7a3a20949a7a88326926ab968d725cd2a3e9ec7ccc3cf71aca1300f2fa56dd14964653aff09f9d501538031639ca04fe07f
6
+ metadata.gz: 874e773c33e46ab1843c655ba49f138ffff68f9ef7a088cf550f5791c3e6fa567545f1e1a8fab52083b860c3c512ffdebd86f312059c2fc9d1e5def5a9881539
7
+ data.tar.gz: f0f91e9861f1cd68e3d2494341f6bbc28f2d482d5766b124b66f65e9cab60fa34d03f199516bc1f75936320e620096f40d9b33c9a98dfb2991575529c1736bbe
checksums.yaml.gz.sig CHANGED
Binary file
@@ -62,7 +62,8 @@ class AlexaRemoteCtl
62
62
 
63
63
  # note: Added the Cross-site request forgery (crsf) variable
64
64
  #
65
- def initialize(domain: 'alexa.amazon.co.uk', device: {}, cookie: '', customerid: '', csrf: '')
65
+ def initialize(domain: 'alexa.amazon.co.uk', device: {}, cookie: '',
66
+ customerid: '', csrf: '')
66
67
 
67
68
  @domain, @device, @cookie, @customerid = domain, device, cookie, customerid
68
69
  @csrf = csrf
@@ -78,6 +79,12 @@ class AlexaRemoteCtl
78
79
  "&nextToken=&size=50"
79
80
  end
80
81
 
82
+ # list historical queue (hq)
83
+ #
84
+ def list_hq()
85
+ get_json '/api/media/historical-queue', "size=50&offset=-1"
86
+ end
87
+
81
88
  def mute?()
82
89
  info()[:volume][:muted]
83
90
  end
@@ -115,8 +122,11 @@ class AlexaRemoteCtl
115
122
 
116
123
  end
117
124
 
118
- def play_hq(id)
119
- device_phq(id)
125
+ # play historical queue
126
+ # note: You can find the queueid from an entry in the list_hq() result
127
+ #
128
+ def play_hq(queueid)
129
+ device_phq(queueid)
120
130
  end
121
131
 
122
132
  def playing?()
@@ -293,70 +303,84 @@ class AlexaDevices
293
303
  #
294
304
  def initialize(devicesx=[], devices: devicesx,
295
305
  domain: 'alexa.amazon.co.uk', cookie: '', customerid: '',
296
- csrf: '')
306
+ csrf: '', debug: false)
297
307
 
298
308
  @devices, @domain, @cookie = devices, domain, cookie
299
- @customerid, @csrf = customerid, csrf
309
+ @customerid, @csrf, @debug = customerid, csrf, debug
300
310
 
301
311
  end
302
312
 
313
+ def info(id=nil) invoke(:info, id) end
314
+ def list_ebooks(id) invoke(:list_ebooks, id) end
315
+ def list_hq(id=nil) invoke(:list_hq, id) end
316
+ def mute?(id=nil) invoke2(:mute?, id) end
317
+ def next(id) invoke2(:next, id) end
318
+
303
319
  def playing()
304
320
 
305
- @devices.map do |device, label|
321
+ devices = @devices.map do |device, label|
322
+
323
+ puts 'label: ' + label.inspect if @debug
324
+ puts 'device: ' + device.inspect if @debug
325
+
306
326
  alexa = get_alexa device
307
327
  alexa.playing? ? [alexa, label] : nil
308
- end.compact
309
-
310
- end
311
328
 
312
- def pause(id=nil)
329
+ end.compact
313
330
 
314
- a = playing()
331
+ puts 'devices: ' + devices.inspect if @debug
332
+ return devices
315
333
 
316
- if id then
334
+ end
317
335
 
318
- alexa, _ = a.find {|_, label| label.to_sym == id.to_sym}
319
- alexa.pause
336
+ def pause(id=nil) invoke2(:pause, id) end
337
+ def play(id) invoke(:play, id) end
338
+ def play_ebook(id) invoke(:list_hq, id) end
339
+ def play_hq(id,qid) invoke(:play_hq, id, qid) end
340
+ def playing?(id=nil) invoke(:playing, id) end
341
+ def text1(id=nil) invoke2(:text1, id) end
342
+ def text2(id=nil) invoke2(:text2, id) end
343
+ def title(id=nil) invoke2(:title, id) end
344
+ def vol(id=nil) invoke(:vol, id) end
345
+ def vol=(id=nil) invoke(:vol=, id) end
320
346
 
321
- else
347
+ private
322
348
 
323
- a.each do |alexa, label|
324
- puts 'Pausing @' + label.inspect
325
- alexa.pause
326
- end
349
+ def get_alexa(device)
327
350
 
328
- end
351
+ AlexaRemoteCtl.new(cookie: @cookie, device: device,
352
+ customerid: @customerid, csrf: @csrf)
329
353
  end
330
354
 
331
- def play(id=nil)
332
-
333
- a = @devices
355
+ def apply_cmd(a, cmd, id, args)
334
356
 
335
357
  if id then
336
358
 
337
359
  device, _ = a.find {|_, label| label.to_sym == id.to_sym}
338
360
  alexa = get_alexa device
339
- alexa.play
361
+ alexa.method(cmd).call(*args)
340
362
 
341
363
  else
342
364
 
343
- a.each do |device, label|
365
+ a.map do |device, label|
344
366
 
345
- puts 'Pausing @' + label.inspect
367
+ puts cmd.to_s + ' @' + label.inspect
346
368
  alexa = get_alexa device
347
- alexa.play
369
+ alexa.method(cmd).call(*args)
348
370
 
349
371
  end
350
372
 
351
373
  end
352
374
  end
353
375
 
354
- private
355
-
356
- def get_alexa(device)
376
+ def invoke(cmd, id, *args)
377
+ apply_cmd(@devices, cmd, id, args)
378
+ end
357
379
 
358
- AlexaRemoteCtl.new(cookie: @cookie, device: device,
359
- customerid: @customerid, csrf: @csrf)
380
+ # apply command to an Alexa device which is currently playing
381
+ #
382
+ def invoke2(cmd, id, *args)
383
+ apply_cmd(playing(), cmd, id, args)
360
384
  end
361
385
 
362
386
  end
data.tar.gz.sig CHANGED
@@ -1,3 +1,3 @@
1
- Z�?.
2
- V�{��Ȏ��d��ïAr�Ѯp
3
- z�%7�9GA�A���f�y�8*a���y����R��
1
+ :�c>j<�;Iy6A�-=�i)�+4��b
2
+ �"M�b�*��+�jM`|����L_WM�+ѫ�5�GX�T�E>u�T�ehK�[oO�P�ф�^e�)�MƢฮ�$����k�I�9�~b��Ӭ*�Ȩ+�22��,GA-��*ϑ`�[V��83ݽ�snf�՜L
3
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alexa_remotectl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  d/gEwBtUmduwWZNX2NOJehf8s1cnH9OBP7s1ziHjdkZCgkQm3QewRRcdfZeYwFi6
36
36
  4kVEcApgAgd+04ctE6uiRn5o
37
37
  -----END CERTIFICATE-----
38
- date: 2022-05-22 00:00:00.000000000 Z
38
+ date: 2022-05-23 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: clipboard
metadata.gz.sig CHANGED
Binary file