ClawShorts
YouTube Shorts limiter for Fire TV. Monitors watch time per device and auto-blocks when daily limit is reached.
Invocation
Primary entry point:
CODEBLOCK0
Commands
| Command | When to use |
|---|
| INLINECODE0 | Check today's usage, remaining quota, daemon health |
| INLINECODE1 |
Reset today's counter (all devices or specific IP) |
|
start | Start the daemon if not running |
|
stop | Stop the daemon |
|
history [days] | Show watch history (default 30 days) |
|
logs [N] | Show last N daemon log lines (default 50) |
|
list | List all configured devices with per-device config |
|
setup <IP> [NAME] | First-time setup for a new device |
|
add <IP> [NAME] | Add another Fire TV |
|
connect <IP> | Connect ADB to device + auto-detect screen |
|
enable <IP> /
disable <IP> | Enable/disable a device |
|
config [show\|get\|set\|reset] | View/set global or per-device config |
|
detect <IP> | Re-detect screen resolution via ADB, update DB |
Detection Logic
Detection requires both conditions to be true simultaneously:
- 1. Player width < 30% of screen width (configurable per-device)
- Aspect ratio < 1.3 (portrait — distinguishes Shorts from 16:9 landscape previews)
- - Poll interval: 3 seconds via ADB
- Shorts: ~32% screen width, 9:16 portrait (ar ~0.56)
- Regular video: ~100% screen width, 16:9 landscape (ar ~1.78)
- Home/browse: no video active
- Only actual Shorts playback counts toward limit
Configuration
All detection parameters are stored in SQLite with global defaults and per-device overrides.
Global defaults (shorts config):
| key | default | description |
|---|
| INLINECODE15 | 0.30 | player width must be < this ratio of screen width |
| INLINECODE16 |
1.3 | portrait if ar < this value |
|
shorts_fallback_height_ratio | 0.4 | fallback: player height must exceed this ratio of screen height |
|
shorts_delta_cap | 300 | max seconds accumulated per poll |
|
default_screen_width | 1920 | fallback assumed screen width |
|
default_screen_height | 1080 | fallback assumed screen height |
Per-device overrides — any of the above can be set per-device in the devices table. NULL = use global default.
Config commands:
CODEBLOCK1
Data Locations
- - Database:
~/.clawshorts/clawshorts.db (SQLite)
-
config — global detection defaults
-
devices — per-device settings (IP, name, limit, screen size, thresholds)
-
daily_usage — daily watch time per device
- - Daemon log: INLINECODE26
- LaunchAgent: INLINECODE27
Requirements
- -
adb (Android platform tools) - Python 3
- Fire TV with ADB debugging enabled
- INLINECODE29 symlink at
/opt/homebrew/bin/shorts (optional)
⚠️ Security Notes
ADB has no built-in authentication. Only enable ADB Debugging on a trusted, password-protected home network. Never on public WiFi. Anyone on the same network with ADB enabled can connect to your Fire TV.
This tool only accepts private IP addresses (10.x.x.x, 172.16–31.x.x, 192.168.x.x). Public IPs are rejected to prevent accidental targeting of unrelated hosts.
ClawShorts
适用于Fire TV的YouTube Shorts限制器。监控每台设备的观看时长,达到每日限额时自动屏蔽。
调用方式
主要入口点:
bash
~/.openclaw/workspace/skills/clawshorts/scripts/clawshorts.sh <命令>
命令列表
| 命令 | 使用场景 |
|---|
| status | 查看今日使用量、剩余配额、守护进程健康状态 |
| reset [IP] |
重置今日计数器(所有设备或指定IP) |
| start | 启动守护进程(如未运行) |
| stop | 停止守护进程 |
| history [天数] | 显示观看历史记录(默认30天) |
| logs [N] | 显示最近N条守护进程日志(默认50条) |
| list | 列出所有已配置设备及其配置 |
| setup
[名称] | 首次设置新设备 |
| add [名称] | 添加另一台Fire TV |
| connect | 通过ADB连接设备并自动检测屏幕 |
| enable / disable | 启用/禁用某台设备 |
| config [show\|get\|set\|reset] | 查看/设置全局或设备级配置 |
| detect | 通过ADB重新检测屏幕分辨率并更新数据库 |
检测逻辑
检测需要同时满足以下两个条件:
- 1. 播放器宽度 < 屏幕宽度的30%(可逐设备配置)
- 宽高比 < 1.3(竖屏模式——区分Shorts与16:9横屏预览)
- - 轮询间隔:通过ADB每3秒一次
- Shorts:约32%屏幕宽度,9:16竖屏(宽高比约0.56)
- 普通视频:约100%屏幕宽度,16:9横屏(宽高比约1.78)
- 主页/浏览:无视频播放
- 仅实际Shorts播放计入限额
配置
所有检测参数存储在SQLite中,包含全局默认值和逐设备覆盖设置。
全局默认值(shorts config):
| 键名 | 默认值 | 描述 |
|---|
| shortswidththreshold | 0.30 | 播放器宽度必须小于屏幕宽度的此比例 |
| shortsmaxaspect_ratio |
1.3 | 宽高比小于此值视为竖屏 |
| shortsfallbackheight_ratio | 0.4 | 备用条件:播放器高度必须超过屏幕高度的此比例 |
| shortsdeltacap | 300 | 每次轮询累计的最大秒数 |
| defaultscreenwidth | 1920 | 备用屏幕宽度假设值 |
| defaultscreenheight | 1080 | 备用屏幕高度假设值 |
逐设备覆盖设置——以上任何参数均可通过devices表逐设备设置。NULL表示使用全局默认值。
配置命令:
bash
shorts config # 显示所有全局默认值
shorts config get <键名> # 获取特定值
shorts config set <键名> <值> # 设置全局默认值
shorts config set <列名> <值> # 设置逐设备覆盖
shorts config reset # 清除逐设备覆盖
shorts detect # 通过ADB重新检测屏幕
数据位置
- - 数据库:~/.clawshorts/clawshorts.db(SQLite)
- config — 全局检测默认值
- devices — 逐设备设置(IP、名称、限额、屏幕尺寸、阈值)
- daily_usage — 每台设备的每日观看时长
- - 守护进程日志:~/.clawshorts/daemon.log
- LaunchAgent:~/Library/LaunchAgents/com.fink.clawshorts.plist
系统要求
- - adb(Android平台工具)
- Python 3
- 已启用ADB调试的Fire TV
- shorts符号链接位于/opt/homebrew/bin/shorts(可选)
⚠️ 安全注意事项
ADB没有内置身份验证。 仅在受信任且受密码保护的家庭网络上启用ADB调试。切勿在公共WiFi上使用。同一网络中任何启用ADB的设备均可连接到您的Fire TV。
此工具仅接受私有IP地址(10.x.x.x、172.16–31.x.x、192.168.x.x)。拒绝公共IP,以防止意外定位无关主机。