Skip to content

Commit

Permalink
Support launching any app by package name (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
tronikos authored May 6, 2024
1 parent 950abf3 commit 98c01ee
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.12"]

steps:
- uses: actions/checkout@v3
Expand All @@ -43,6 +43,7 @@ jobs:
ruff .
- name: Static typing with mypy
run: |
mkdir -p .mypy_cache
mypy --install-types --non-interactive .
- name: Test with pytest
run: |
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "androidtvremote2"
version = "0.0.15"
version = "0.1.0"
license = {text = "Apache-2.0"}
authors = [
{ name="tronikos", email="[email protected]" },
Expand Down
7 changes: 5 additions & 2 deletions src/androidtvremote2/androidtv_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def send_key_command(
raise ConnectionClosed("Called send_key_command after disconnect")
self._remote_message_protocol.send_key_command(key_code, direction)

def send_launch_app_command(self, app_link: str) -> None:
def send_launch_app_command(self, app_link_or_app_id: str) -> None:
"""Launch an app on Android TV.
This does not block; it buffers the data and arranges for it to be sent out asynchronously.
Expand All @@ -397,4 +397,7 @@ def send_launch_app_command(self, app_link: str) -> None:
if not self._remote_message_protocol:
LOGGER.debug("Called send_launch_app_command after disconnect")
raise ConnectionClosed("Called send_launch_app_command after disconnect")
self._remote_message_protocol.send_launch_app_command(app_link)
prefix = "" if "://" in app_link_or_app_id else "market://launch?id="
self._remote_message_protocol.send_launch_app_command(
f"{prefix}{app_link_or_app_id}"
)
9 changes: 6 additions & 3 deletions src/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def _bind_keyboard(remote: AndroidTVRemote) -> None:
"\n- 'n': Netflix"
"\n- 'd': Disney+"
"\n- 'a': Amazon Prime Video"
"\n- 'k': Kodi"
"\n- 'q': quit\n\n"
)
key_mappings = {
Expand Down Expand Up @@ -77,11 +78,13 @@ def on_press(key: keyboard.Key | keyboard.KeyCode | None) -> None:
elif key.char == "y":
remote.send_launch_app_command("https://www.youtube.com")
elif key.char == "n":
remote.send_launch_app_command("https://www.netflix.com/title")
remote.send_launch_app_command("com.netflix.ninja")
elif key.char == "d":
remote.send_launch_app_command("https://www.disneyplus.com")
remote.send_launch_app_command("com.disney.disneyplus")
elif key.char == "a":
remote.send_launch_app_command("https://app.primevideo.com")
remote.send_launch_app_command("com.amazon.amazonvideo.livingroom")
elif key.char == "k":
remote.send_launch_app_command("org.xbmc.kodi")


async def _host_from_zeroconf(timeout: float) -> str:
Expand Down

0 comments on commit 98c01ee

Please sign in to comment.