Skip to content

Commit dae0f5a

Browse files
Merge pull request #62 from JeffLIrion/master
Bump version to 1.0.6 and fix requirements
2 parents 16f80c6 + 0c0c11d commit dae0f5a

3 files changed

Lines changed: 51 additions & 52 deletions

File tree

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# python-firetv
22

3-
`firetv` is a Python 2.x package that provides state information and some control of an Amazon Fire TV device over a network. This is achieved via ADB, so therefore requires [ADB Debugging](https://developer.amazon.com/public/solutions/devices/fire-tv/docs/connecting-adb-over-network) to be turned on. It includes `firetv-server`, an HTTP server to facilitate RESTful access to configured devices.
3+
`firetv` is a Python 2 and 3 package that provides state information and some control of an Amazon Fire TV device over a network. This is achieved via ADB, so therefore requires [ADB Debugging](https://developer.amazon.com/public/solutions/devices/fire-tv/docs/connecting-adb-over-network) to be turned on. It includes `firetv-server`, an HTTP server to facilitate RESTful access to configured devices.
44

55
## Installation
66

@@ -10,7 +10,7 @@ with `apt-get`: `swig libssl-dev python-dev libusb-1.0-0`
1010

1111
with `yum`: `swig openssl-devel python-devel libusbx-devel`
1212

13-
Be sure you install into a Python 2.x environment.
13+
Install the package using the command:
1414

1515
`pip install firetv`
1616

@@ -129,9 +129,6 @@ You can start or stop an app with the following commands:
129129

130130
app_id must be a package name, e.g. org.xbmc.kodi or com.netflix.ninja
131131

132-
## Python 3
133-
`firetv` depends on [python-adb](https://github.com/google/python-adb), a pure-python implementation of the ADB protocol. It and its dependency [M2Crypto](https://github.com/martinpaljak/M2Crypto) are written for Python 2. Until they support Python 3, or an alternative is available, `firetv` will not support Python 3. The HTTP server is provided as a way for Python 3 (or other) software to utilize the features of `firetv`.
134-
135132
## Contribution
136133

137134
This package does not fully exploit the potential of ADB access to Amazon Fire TV devices, and lacks some robustness. Contributions are welcome.

firetv/__init__.py

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
VOLUME_UP = 24
2626
VOLUME_DOWN = 25
2727
POWER = 26
28+
SLEEP = 223
2829
PLAY_PAUSE = 85
2930
NEXT = 87
3031
PREVIOUS = 88
@@ -82,7 +83,7 @@
8283
STATE_PLAYING = 'play'
8384
STATE_PAUSED = 'pause'
8485
STATE_STANDBY = 'standby'
85-
STATE_DISCONNECTED = 'disconnected'
86+
STATE_UNKNOWN = 'unknown'
8687

8788
PACKAGE_LAUNCHER = "com.amazon.tv.launcher"
8889
PACKAGE_SETTINGS = "com.amazon.tv.settings"
@@ -108,7 +109,7 @@ def connect(self):
108109
""" Connect to an Amazon Fire TV device.
109110
110111
Will attempt to establish ADB connection to the given host.
111-
Failure sets state to DISCONNECTED and disables sending actions.
112+
Failure sets state to UNKNOWN and disables sending actions.
112113
"""
113114
try:
114115
if self.adbkey:
@@ -129,7 +130,7 @@ def state(self):
129130
"""
130131
# Check if device is disconnected.
131132
if not self._adb:
132-
return STATE_DISCONNECTED
133+
return STATE_UNKNOWN
133134
# Check if device is off.
134135
if not self._screen_on:
135136
return STATE_OFF
@@ -151,21 +152,21 @@ def running_apps(self):
151152

152153
def app_state(self, app):
153154
""" Informs if application is running """
154-
if self.state == STATE_OFF or self.state == STATE_DISCONNECTED:
155+
if not self._adb or not self._screen_on:
155156
return STATE_OFF
156157
if self.current_app["package"] == app:
157158
return STATE_ON
158159
return STATE_OFF
159160

160161
def turn_on(self):
161162
""" Send power action if device is off. """
162-
if self.state == STATE_OFF:
163+
if self._adb and not self._screen_on:
163164
self._power()
164165

165166
def turn_off(self):
166167
""" Send power action if device is not off. """
167-
if self.state != STATE_OFF:
168-
self._power()
168+
if self._adb and self._screen_on:
169+
self._key(SLEEP)
169170

170171
def home(self):
171172
""" Send home action. """
@@ -226,151 +227,151 @@ def media_next(self):
226227
def media_previous(self):
227228
""" Send media previous action (results in rewind). """
228229
self._key(PREVIOUS)
229-
230+
230231
def space(self):
231232
""" Send space keypress. """
232233
self._key(SPACE)
233-
234+
234235
def key_0(self):
235236
""" Send 0 keypress. """
236237
self._key(KEY_0)
237-
238+
238239
def key_1(self):
239240
""" Send 1 keypress. """
240241
self._key(KEY_1)
241-
242+
242243
def key_2(self):
243244
""" Send 2 keypress. """
244245
self._key(KEY_2)
245-
246+
246247
def key_3(self):
247248
""" Send 3 keypress. """
248249
self._key(KEY_3)
249-
250+
250251
def key_4(self):
251252
""" Send 4 keypress. """
252253
self._key(KEY_4)
253-
254+
254255
def key_5(self):
255256
""" Send 5 keypress. """
256257
self._key(KEY_5)
257-
258+
258259
def key_6(self):
259260
""" Send 6 keypress. """
260261
self._key(KEY_6)
261-
262+
262263
def key_7(self):
263264
""" Send 7 keypress. """
264265
self._key(KEY_7)
265-
266+
266267
def key_8(self):
267268
""" Send 8 keypress. """
268269
self._key(KEY_8)
269-
270+
270271
def key_9(self):
271272
""" Send 9 keypress. """
272273
self._key(KEY_9)
273-
274+
274275
def key_a(self):
275276
""" Send a keypress. """
276277
self._key(KEY_A)
277-
278+
278279
def key_b(self):
279280
""" Send b keypress. """
280281
self._key(KEY_B)
281-
282+
282283
def key_c(self):
283284
""" Send c keypress. """
284285
self._key(KEY_C)
285-
286+
286287
def key_d(self):
287288
""" Send d keypress. """
288289
self._key(KEY_D)
289-
290+
290291
def key_e(self):
291292
""" Send e keypress. """
292293
self._key(KEY_E)
293-
294+
294295
def key_f(self):
295296
""" Send f keypress. """
296297
self._key(KEY_F)
297-
298+
298299
def key_g(self):
299300
""" Send g keypress. """
300301
self._key(KEY_G)
301-
302+
302303
def key_h(self):
303304
""" Send h keypress. """
304305
self._key(KEY_H)
305-
306+
306307
def key_i(self):
307308
""" Send i keypress. """
308-
self._key(KEY_I)
309-
309+
self._key(KEY_I)
310+
310311
def key_j(self):
311312
""" Send j keypress. """
312313
self._key(KEY_J)
313-
314+
314315
def key_k(self):
315316
""" Send k keypress. """
316317
self._key(KEY_K)
317-
318+
318319
def key_l(self):
319320
""" Send l keypress. """
320321
self._key(KEY_L)
321-
322+
322323
def key_m(self):
323324
""" Send m keypress. """
324325
self._key(KEY_M)
325-
326+
326327
def key_n(self):
327328
""" Send n keypress. """
328329
self._key(KEY_N)
329-
330+
330331
def key_o(self):
331332
""" Send o keypress. """
332333
self._key(KEY_O)
333-
334+
334335
def key_p(self):
335336
""" Send p keypress. """
336337
self._key(KEY_P)
337-
338+
338339
def key_q(self):
339340
""" Send q keypress. """
340341
self._key(KEY_Q)
341-
342+
342343
def key_r(self):
343344
""" Send r keypress. """
344345
self._key(KEY_R)
345-
346+
346347
def key_s(self):
347348
""" Send s keypress. """
348349
self._key(KEY_S)
349-
350+
350351
def key_t(self):
351352
""" Send t keypress. """
352353
self._key(KEY_T)
353-
354+
354355
def key_u(self):
355356
""" Send u keypress. """
356357
self._key(KEY_U)
357-
358+
358359
def key_v(self):
359360
""" Send v keypress. """
360361
self._key(KEY_V)
361-
362+
362363
def key_w(self):
363364
""" Send w keypress. """
364365
self._key(KEY_W)
365-
366+
366367
def key_x(self):
367368
""" Send x keypress. """
368369
self._key(KEY_X)
369-
370+
370371
def key_y(self):
371372
""" Send y keypress. """
372373
self._key(KEY_Y)
373-
374+
374375
def key_z(self):
375376
""" Send z keypress. """
376377
self._key(KEY_Z)

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
setup(
44
name='firetv',
5-
version='1.0.5.dev',
5+
version='1.0.6',
66
description='Communicate with an Amazon Fire TV device via ADB over a network.',
77
url='https://github.com/happyleavesaoc/python-firetv/',
88
license='MIT',
99
author='happyleaves',
1010
author_email='happyleaves.tfr@gmail.com',
1111
packages=['firetv'],
12-
install_requires=['adb==1.3.0.dev'],
12+
install_requires=['pycryptodome', 'rsa', 'adb-homeassistant'],
1313
extras_require={
1414
'firetv-server': ['Flask>=0.10.1', 'PyYAML>=3.12']
1515
},
@@ -22,5 +22,6 @@
2222
'License :: OSI Approved :: MIT License',
2323
'Operating System :: OS Independent',
2424
'Programming Language :: Python :: 2',
25+
'Programming Language :: Python :: 3'
2526
]
2627
)

0 commit comments

Comments
 (0)