ClawSkills logoClawSkills

roku

通过 CLI 控制 Roku 设备。发现、远程控制、应用启动、搜索以及用于实时控制的 HTTP 桥接模式。

介绍

# Roku CLI

用于通过 ECP API 控制 Roku 设备的快速 TypeScript CLI。

## 安装

```bash npm install -g roku-ts-cli@latest ```

## 快速开始

```bash # Discover devices and save an alias roku discover --save livingroom --index 1

# Use the alias roku --host livingroom device-info roku --host livingroom apps ```

## 命令

| 命令 | 描述 | |---------|-------------| | `roku discover` | 在网络上查找 Roku 设备 | | `roku --host <ip> device-info` | 获取设备信息 | | `roku --host <ip> apps` | 列出已安装的应用 | | `roku --host <ip> command <key>` | 发送遥控按键 | | `roku --host <ip> literal <text>` | 输入文本 | | `roku --host <ip> search --title <query>` | 搜索内容 | | `roku --host <ip> launch <app>` | 启动应用 | | `roku --host <ip> interactive` | 交互式遥控模式 |

## 交互模式

```bash roku livingroom # interactive control roku --host livingroom interactive # same thing ```

使用方向键、回车键、Esc 键进行类似遥控器的控制。

## 桥接服务

将持久的 HTTP 桥接作为原生操作系统服务运行:

```bash # Install and start the service roku bridge install-service --port 19839 --token secret --host livingroom --user roku bridge start --user

# Service management roku bridge status --user roku bridge stop --user roku bridge uninstall --user ```

通过 HTTP 发送命令:

```bash # Send key curl -X POST http://127.0.0.1:19839/key \ -H "Content-Type: application/json" \ -H "Authorization: Bearer secret" \ -d '{"key":"home"}'

# Type text curl -X POST http://127.0.0.1:19839/text \ -H "Content-Type: application/json" \ -H "Authorization: Bearer secret" \ -d '{"text":"hello"}'

# Launch app curl -X POST http://127.0.0.1:19839/launch \ -H "Content-Type: application/json" \ -H "Authorization: Bearer secret" \ -d '{"app":"plex"}'

# Health check curl http://127.0.0.1:19839/health -H "Authorization: Bearer secret" ```

### 桥接端点

| 端点 | 请求体 | |----------|------| | `POST /key` | `{"key": "home"}` | | `POST /text` | `{"text": "hello"}` | | `POST /search` | `{"title": "Stargate"}` | | `POST /launch` | `{"app": "plex"}` | | `GET /health` | — | | `GET /health?deep=1` | 深度健康检查(探测 Roku) |

## 别名

```bash # Save device alias roku discover --save livingroom --index 1 roku alias set office 192.168.1.20

# Save app alias roku alias set plex 13535

# List aliases roku alias list

# Use aliases roku --host livingroom launch plex ```

## 遥控按键

home, back, select, up, down, left, right, play, pause, rev, fwd, replay, info, power, volume_up, volume_down, mute

## 注意事项

- Roku 必须与 CLI 位于同一网络 - 桥接服务作为原生 launchd (macOS) 或 systemd (Linux) 服务运行 - 使用 `--user` 标志指定用户空间服务(无需 sudo) - 在桥接模式下使用 `--token` 进行身份验证

## 源码

https://github.com/gumadeiras/roku-cli

更多产品