remoku 2.0.0__py3-none-any.whl

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.
remoku/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """remoku: a native desktop remote for Roku devices."""
2
+
3
+ __version__ = "2.0.0"
remoku/__main__.py ADDED
@@ -0,0 +1,53 @@
1
+ """Command line entry point for remoku."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import sys
7
+
8
+ from .discovery import discover, last_used_ip
9
+ from .ecp import Roku, RokuError
10
+
11
+
12
+ def main(argv: list[str] | None = None) -> int:
13
+ parser = argparse.ArgumentParser(prog="remoku", description="Control Roku devices over the local network.")
14
+ parser.add_argument("--ip", help="device IP to use instead of the last one")
15
+ parser.add_argument("--list", action="store_true", help="list discovered devices and exit")
16
+ parser.add_argument("--apps", action="store_true", help="list the device's apps and inputs, then exit")
17
+ parser.add_argument("--key", metavar="KEY", help="send one keypress to the device, then exit")
18
+ args = parser.parse_args(argv)
19
+
20
+ if args.list:
21
+ devices = discover(progress=lambda message: print(message, file=sys.stderr))
22
+ if not devices:
23
+ print("No Roku devices found.", file=sys.stderr)
24
+ return 1
25
+ for device in devices:
26
+ print(f"{device['ip']:16} {device['name']:28} {device['model']}")
27
+ return 0
28
+
29
+ if args.apps or args.key:
30
+ ip = args.ip or last_used_ip()
31
+ if not ip:
32
+ print("No device specified and none remembered; pass --ip.", file=sys.stderr)
33
+ return 1
34
+ device = Roku(ip)
35
+ try:
36
+ if args.apps:
37
+ for app in device.apps():
38
+ print(f"{app.kind:5} {app.id:24} {app.name}")
39
+ if args.key:
40
+ device.keypress(args.key)
41
+ print(f"Sent {args.key} to {ip}")
42
+ except RokuError as exc:
43
+ print(f"Error: {exc}", file=sys.stderr)
44
+ return 1
45
+ return 0
46
+
47
+ from .app import run_gui
48
+
49
+ return run_gui()
50
+
51
+
52
+ if __name__ == "__main__":
53
+ raise SystemExit(main())