androidtvremote2 0.1.0__tar.gz → 0.1.2__tar.gz
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.
- {androidtvremote2-0.1.0/src/androidtvremote2.egg-info → androidtvremote2-0.1.2}/PKG-INFO +1 -1
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/pyproject.toml +1 -1
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2/androidtv_remote.py +17 -10
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2/src/androidtvremote2.egg-info}/PKG-INFO +1 -1
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/LICENSE +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/README.md +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/setup.cfg +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2/__init__.py +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2/base.py +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2/certificate_generator.py +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2/const.py +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2/exceptions.py +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2/pairing.py +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2/polo_pb2.py +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2/polo_pb2.pyi +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2/remote.py +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2/remotemessage_pb2.py +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2/remotemessage_pb2.pyi +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2.egg-info/SOURCES.txt +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2.egg-info/dependency_links.txt +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2.egg-info/requires.txt +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2.egg-info/top_level.txt +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/demo.py +0 -0
- {androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/tests/test_androidtv_remote.py +0 -0
|
@@ -6,6 +6,7 @@ import asyncio
|
|
|
6
6
|
from collections.abc import Callable
|
|
7
7
|
import os
|
|
8
8
|
import ssl
|
|
9
|
+
from urllib.parse import urlparse
|
|
9
10
|
|
|
10
11
|
import aiofiles
|
|
11
12
|
from cryptography import x509
|
|
@@ -18,6 +19,14 @@ from .remote import RemoteProtocol
|
|
|
18
19
|
from .remotemessage_pb2 import RemoteDirection
|
|
19
20
|
|
|
20
21
|
|
|
22
|
+
def _load_cert_chain(certfile: str, keyfile: str) -> ssl.SSLContext:
|
|
23
|
+
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
|
24
|
+
ssl_context.check_hostname = False
|
|
25
|
+
ssl_context.verify_mode = ssl.VerifyMode.CERT_NONE
|
|
26
|
+
ssl_context.load_cert_chain(certfile, keyfile)
|
|
27
|
+
return ssl_context
|
|
28
|
+
|
|
29
|
+
|
|
21
30
|
class AndroidTVRemote:
|
|
22
31
|
"""Pairing and connecting to an Android TV for remotely sending commands to it."""
|
|
23
32
|
|
|
@@ -169,18 +178,16 @@ class AndroidTVRemote:
|
|
|
169
178
|
await out.write(key_pem.decode("utf-8"))
|
|
170
179
|
return True
|
|
171
180
|
|
|
172
|
-
def _create_ssl_context(self) -> ssl.SSLContext:
|
|
181
|
+
async def _create_ssl_context(self) -> ssl.SSLContext:
|
|
173
182
|
if self._ssl_context:
|
|
174
183
|
return self._ssl_context
|
|
175
|
-
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
|
176
|
-
ssl_context.check_hostname = False
|
|
177
|
-
ssl_context.verify_mode = ssl.VerifyMode.CERT_NONE
|
|
178
184
|
try:
|
|
179
|
-
ssl_context
|
|
185
|
+
ssl_context = await self._loop.run_in_executor(
|
|
186
|
+
None, _load_cert_chain, self._certfile, self._keyfile
|
|
187
|
+
)
|
|
180
188
|
except FileNotFoundError as exc:
|
|
181
189
|
LOGGER.debug("Missing certificate. Error: %s", exc)
|
|
182
190
|
raise InvalidAuth from exc
|
|
183
|
-
ssl_context.load_cert_chain(self._certfile, self._keyfile)
|
|
184
191
|
self._ssl_context = ssl_context
|
|
185
192
|
return self._ssl_context
|
|
186
193
|
|
|
@@ -191,7 +198,7 @@ class AndroidTVRemote:
|
|
|
191
198
|
:raises ConnectionClosed: if connection was lost while waiting for the remote to start.
|
|
192
199
|
:raises InvalidAuth: if pairing is needed first.
|
|
193
200
|
"""
|
|
194
|
-
ssl_context = self._create_ssl_context()
|
|
201
|
+
ssl_context = await self._create_ssl_context()
|
|
195
202
|
on_con_lost = self._loop.create_future()
|
|
196
203
|
on_remote_started = self._loop.create_future()
|
|
197
204
|
try:
|
|
@@ -296,7 +303,7 @@ class AndroidTVRemote:
|
|
|
296
303
|
|
|
297
304
|
:raises CannotConnect: if couldn't connect, e.g. invalid IP address.
|
|
298
305
|
"""
|
|
299
|
-
ssl_context = self._create_ssl_context()
|
|
306
|
+
ssl_context = await self._create_ssl_context()
|
|
300
307
|
try:
|
|
301
308
|
_, writer = await asyncio.open_connection(
|
|
302
309
|
self.host, self._pair_port, ssl=ssl_context
|
|
@@ -332,7 +339,7 @@ class AndroidTVRemote:
|
|
|
332
339
|
:raises ConnectionClosed: if connection was lost.
|
|
333
340
|
"""
|
|
334
341
|
self.disconnect()
|
|
335
|
-
ssl_context = self._create_ssl_context()
|
|
342
|
+
ssl_context = await self._create_ssl_context()
|
|
336
343
|
on_con_lost = self._loop.create_future()
|
|
337
344
|
try:
|
|
338
345
|
(
|
|
@@ -397,7 +404,7 @@ class AndroidTVRemote:
|
|
|
397
404
|
if not self._remote_message_protocol:
|
|
398
405
|
LOGGER.debug("Called send_launch_app_command after disconnect")
|
|
399
406
|
raise ConnectionClosed("Called send_launch_app_command after disconnect")
|
|
400
|
-
prefix = "" if
|
|
407
|
+
prefix = "" if urlparse(app_link_or_app_id).scheme else "market://launch?id="
|
|
401
408
|
self._remote_message_protocol.send_launch_app_command(
|
|
402
409
|
f"{prefix}{app_link_or_app_id}"
|
|
403
410
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2/certificate_generator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2/remotemessage_pb2.pyi
RENAMED
|
File without changes
|
|
File without changes
|
{androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2.egg-info/requires.txt
RENAMED
|
File without changes
|
{androidtvremote2-0.1.0 → androidtvremote2-0.1.2}/src/androidtvremote2.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|