alexa_remotectl 0.4.3 → 0.4.6

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: f3390f693c5318ae22b5c79fbe464dacd839ef331c4d3f2a07e9aeed38229be2
4
- data.tar.gz: adb89f569f0f47f88304c5032b963e171c556d340f928dd70de0437318c9b09f
3
+ metadata.gz: 5b2029c701df7521e20261071499fcdd877858b75ef7c6257ada56fa0e83f390
4
+ data.tar.gz: 2cb5831f0c13db113c7991954940cef62e2a4ad90fd8ee66c50e17a028e3ae8a
5
5
  SHA512:
6
- metadata.gz: 874e773c33e46ab1843c655ba49f138ffff68f9ef7a088cf550f5791c3e6fa567545f1e1a8fab52083b860c3c512ffdebd86f312059c2fc9d1e5def5a9881539
7
- data.tar.gz: f0f91e9861f1cd68e3d2494341f6bbc28f2d482d5766b124b66f65e9cab60fa34d03f199516bc1f75936320e620096f40d9b33c9a98dfb2991575529c1736bbe
6
+ metadata.gz: 282e5aad4855e6a1aa67057d4f71ad786044c3c379ecfce3070c34770b396e5dca16de73d604d6a37b6713e29fbe854c44f0fcdf336276680cbaeab5fc2a91e9
7
+ data.tar.gz: 8af80f421ff7423c5bd729ea3bd9ef0c4b3f150e35cbb79eb28abfbd3771a223f939d31d904e665a09bf69187c75625e8256e66474182072e3b138327a2aa830
checksums.yaml.gz.sig CHANGED
Binary file
@@ -13,7 +13,7 @@ require 'json'
13
13
  # Use the CodeWizard with the cURL command you've copied using Developer
14
14
  # tools on Alexa's SPA page (within the web browser).
15
15
  #
16
- # note: to find the correct url to convert, try clickin on pause or play to
16
+ # note: to find the correct url to convert, try clicking on pause or play to
17
17
  # invoke an AJAX request
18
18
 
19
19
  class CodeWizard
@@ -70,13 +70,29 @@ class AlexaRemoteCtl
70
70
 
71
71
  end
72
72
 
73
+ # Some audio streams can't be paused through the SPA API. Playing a
74
+ # historical queue, and then pausing it, is the best next option.
75
+ #
76
+ def force_pause()
77
+
78
+ r = list_hq()
79
+ queueid = r[:media][0][:queueId]
80
+
81
+ play_hq queueid
82
+ sleep 1
83
+
84
+ pause()
85
+
86
+ end
87
+
73
88
  def info()
74
89
  device_player()[:playerInfo]
75
90
  end
76
91
 
77
92
  def list_ebooks()
78
- get_json '/api/ebooks/library', "mediaOwnerCustomerId=#{@customerid}" +
93
+ r = get_json '/api/ebooks/library', "mediaOwnerCustomerId=#{@customerid}" +
79
94
  "&nextToken=&size=50"
95
+ r[:metadataList]
80
96
  end
81
97
 
82
98
  # list historical queue (hq)
@@ -104,7 +120,13 @@ class AlexaRemoteCtl
104
120
  pp_cmd('Play')
105
121
  end
106
122
 
107
- def play_ebook(id)
123
+ def play_ebook(obj)
124
+
125
+ id = if obj.is_a? Integer then
126
+ list_ebook()[obj][:asin]
127
+ else
128
+ obj
129
+ end
108
130
 
109
131
  serialno = @device[:serialno]
110
132
  type = @device[:type]
@@ -125,7 +147,15 @@ class AlexaRemoteCtl
125
147
  # play historical queue
126
148
  # note: You can find the queueid from an entry in the list_hq() result
127
149
  #
128
- def play_hq(queueid)
150
+ def play_hq(obj)
151
+
152
+ queueid = if obj.is_a? Integer then
153
+ r = list_hq()
154
+ r[:media][obj][:queueId]
155
+ else
156
+ obj
157
+ end
158
+
129
159
  device_phq(queueid)
130
160
  end
131
161
 
@@ -164,6 +194,8 @@ class AlexaRemoteCtl
164
194
  device_cmd(body)
165
195
  end
166
196
 
197
+ alias setvol vol=
198
+
167
199
  private
168
200
 
169
201
  # play, pause, or next
@@ -310,6 +342,7 @@ class AlexaDevices
310
342
 
311
343
  end
312
344
 
345
+ def force_pause(id) invoke(:force_pause, id) end
313
346
  def info(id=nil) invoke(:info, id) end
314
347
  def list_ebooks(id) invoke(:list_ebooks, id) end
315
348
  def list_hq(id=nil) invoke(:list_hq, id) end
@@ -337,12 +370,12 @@ class AlexaDevices
337
370
  def play(id) invoke(:play, id) end
338
371
  def play_ebook(id) invoke(:list_hq, id) end
339
372
  def play_hq(id,qid) invoke(:play_hq, id, qid) end
340
- def playing?(id=nil) invoke(:playing, id) end
373
+ def playing?(id=nil) invoke(:playing?, id) end
341
374
  def text1(id=nil) invoke2(:text1, id) end
342
375
  def text2(id=nil) invoke2(:text2, id) end
343
376
  def title(id=nil) invoke2(:title, id) end
344
377
  def vol(id=nil) invoke(:vol, id) end
345
- def vol=(id=nil) invoke(:vol=, id) end
378
+ def setvol(id=nil, level) invoke(:setvol, id, level) end
346
379
 
347
380
  private
348
381
 
@@ -373,6 +406,25 @@ class AlexaDevices
373
406
  end
374
407
  end
375
408
 
409
+ def apply_cmd2(a, cmd, id, args)
410
+
411
+ if id then
412
+
413
+ alexa, _ = a.find {|_, label| label.to_sym == id.to_sym}
414
+ alexa.method(cmd).call(*args)
415
+
416
+ else
417
+
418
+ a.map do |alexa, label|
419
+
420
+ puts cmd.to_s + ' @' + label.inspect
421
+ alexa.method(cmd).call(*args)
422
+
423
+ end
424
+
425
+ end
426
+ end
427
+
376
428
  def invoke(cmd, id, *args)
377
429
  apply_cmd(@devices, cmd, id, args)
378
430
  end
@@ -380,7 +432,7 @@ class AlexaDevices
380
432
  # apply command to an Alexa device which is currently playing
381
433
  #
382
434
  def invoke2(cmd, id, *args)
383
- apply_cmd(playing(), cmd, id, args)
435
+ apply_cmd2(playing(), cmd, id, args)
384
436
  end
385
437
 
386
438
  end
data.tar.gz.sig CHANGED
Binary file
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.3
4
+ version: 0.4.6
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-23 00:00:00.000000000 Z
38
+ date: 2022-05-24 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: clipboard
metadata.gz.sig CHANGED
Binary file