简介
基于开源 pyatv 库的 Apple 设备远程控制方案,实现 Apple TV、HomePod 的播放、导航、投流等全功能操控。
原始描述
Control Apple TV, HomePod, and AirPlay devices via pyatv (scan, stream, playback, volume, navigation).
通过你的 Agent 添加
安装目录:apple-media/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
apple-media 是一个纯文档型 Skill,通过封装 pyatv 项目的 atvremote 命令行工具,提供对 Apple TV、HomePod 及 AirPlay 设备的完整控制能力。用户需先通过 pipx install pyatv 安装依赖,随后即可使用 atvremote scan 发现局域网内的苹果设备,并通过设备名称、IP 地址或标识符进行精准控制。
该 Skill 覆盖五大核心场景:设备发现与配对(scan/pair/wizard)、播放控制(play/pause/seek/shuffle/repeat)、音量管理(set_volume/volume_up/down)、内容投流(stream_file/play_url)以及 Apple TV 专属交互(方向键导航、键盘输入、应用启动、电源管理)。特别值得一提的是其多房间音频管理能力,支持通过 add_output_devices 等命令将多个 HomePod 组成立体声或全屋播放组。
显著优点
- 协议完整度高:基于
pyatv 逆向工程实现,支持 MRP(Media Remote Protocol)、AirPlay、Companion 等多种协议,功能覆盖度远超普通遥控器 App。
- 局域网自动化友好:纯命令行交互,易于集成到 Home Assistant、Shell 脚本或定时任务中,实现"到家自动播放音乐"等场景。
- 跨平台兼容:
pyatv 本身支持 Linux/macOS/Windows,配合 Python 3.13 环境即可运行,打破苹果生态的封闭性。
- 实时状态推送:
push_updates 命令可监听播放状态变化,为开发状态面板或自动化触发提供数据基础。
潜在缺点与局限性
- Python 版本锁死:明确不兼容 Python 3.14+,安装时需显式指定
--python python3.13,对新手有一定门槛。
- 配对流程繁琐:Apple TV 通常需要多协议配对,首次配置需交互式 PIN 码验证,无法完全无人值守。
- 网络环境敏感:设备发现依赖 mDNS/Bonjour,跨 VLAN 或复杂网络拓扑下可能出现扫描失败。
- 功能边界模糊:导航和键盘命令仅适用于 Apple TV,对 HomePod 无效,文档虽注明但易误用。
适合的目标群体
- 智能家居极客:希望将 Apple TV/HomePod 接入非 HomeKit 自动化体系的技术用户
- 多平台开发者:需要在 Linux 服务器或 Windows 环境中远程调试 Apple 设备的工程师
- 家庭影音集成商:为客户部署全屋音频方案,需批量配置多房间音频分组的专业人员
- CLI 爱好者:偏好终端操作效率,反感频繁切换遥控器 App 的进阶用户
使用风险
- 依赖项维护:
pyatv 作为社区逆向项目,可能随 tvOS 更新出现协议兼容性问题,需关注版本更新。
- 凭证安全:配对凭证明文存储于
~/.pyatv.conf,多用户系统需注意文件权限(建议 600)。
- 网络暴露风险:
play_url 功能可接受任意远程流地址,若脚本参数未做校验,可能存在 SSRF 隐患。
- 设备误操作:
turn_off 与 stop 命令不可逆,自动化脚本中需谨慎使用,避免中断重要播放会话。
pyatv 逆向工程实现,支持 MRP(Media Remote Protocol)、AirPlay、Companion 等多种协议,功能覆盖度远超普通遥控器 App。pyatv 本身支持 Linux/macOS/Windows,配合 Python 3.13 环境即可运行,打破苹果生态的封闭性。push_updates 命令可监听播放状态变化,为开发状态面板或自动化触发提供数据基础。- Python 版本锁死:明确不兼容 Python 3.14+,安装时需显式指定
--python python3.13,对新手有一定门槛。 - 配对流程繁琐:Apple TV 通常需要多协议配对,首次配置需交互式 PIN 码验证,无法完全无人值守。
- 网络环境敏感:设备发现依赖 mDNS/Bonjour,跨 VLAN 或复杂网络拓扑下可能出现扫描失败。
- 功能边界模糊:导航和键盘命令仅适用于 Apple TV,对 HomePod 无效,文档虽注明但易误用。
适合的目标群体
- 智能家居极客:希望将 Apple TV/HomePod 接入非 HomeKit 自动化体系的技术用户
- 多平台开发者:需要在 Linux 服务器或 Windows 环境中远程调试 Apple 设备的工程师
- 家庭影音集成商:为客户部署全屋音频方案,需批量配置多房间音频分组的专业人员
- CLI 爱好者:偏好终端操作效率,反感频繁切换遥控器 App 的进阶用户
使用风险
- 依赖项维护:
pyatv 作为社区逆向项目,可能随 tvOS 更新出现协议兼容性问题,需关注版本更新。
- 凭证安全:配对凭证明文存储于
~/.pyatv.conf,多用户系统需注意文件权限(建议 600)。
- 网络暴露风险:
play_url 功能可接受任意远程流地址,若脚本参数未做校验,可能存在 SSRF 隐患。
- 设备误操作:
turn_off 与 stop 命令不可逆,自动化脚本中需谨慎使用,避免中断重要播放会话。
- 依赖项维护:
pyatv作为社区逆向项目,可能随 tvOS 更新出现协议兼容性问题,需关注版本更新。 - 凭证安全:配对凭证明文存储于
~/.pyatv.conf,多用户系统需注意文件权限(建议 600)。 - 网络暴露风险:
play_url功能可接受任意远程流地址,若脚本参数未做校验,可能存在 SSRF 隐患。 - 设备误操作:
turn_off与stop命令不可逆,自动化脚本中需谨慎使用,避免中断重要播放会话。
技能正文
name: apple-media
description: Control Apple TV, HomePod, and AirPlay devices via pyatv (scan, stream, playback, volume, navigation).
homepage: https://github.com/aaronn/clawd-apple-media-skill
metadata: {"clawdbot":{"emoji":"🎛️","requires":{"bins":["atvremote"]},"install":[{"id":"pipx","kind":"shell","command":"pipx install pyatv --python python3.13","bins":["atvremote"],"label":"Install pyatv via pipx (Python 3.13)"}]}}
Apple Media Remote
Control Apple TV, HomePod, and AirPlay devices from the command line using atvremote.
Setup Notes
- pyatv has a compatibility issue with Python 3.14+. Use
--python python3.13 (or any version ≤3.13) when installing.
- If
~/.local/bin isn't on your PATH after install, run: pipx ensurepath
- If your default Python is 3.14+, you can also call directly:
python3.13 -m pyatv.scripts.atvremote <command>
Scan for Devices
atvremote scan
atvremote --scan-hosts 10.0.0.50 scan # Scan specific IP (faster)
atvremote --scan-hosts 10.0.0.50,10.0.0.51 scan # Multiple IPs
--python python3.13 (or any version ≤3.13) when installing.~/.local/bin isn't on your PATH after install, run: pipx ensurepathpython3.13 -m pyatv.scripts.atvremote <command>atvremote scan
atvremote --scan-hosts 10.0.0.50 scan # Scan specific IP (faster)
atvremote --scan-hosts 10.0.0.50,10.0.0.51 scan # Multiple IPs
Returns all discoverable Apple TV, HomePod, and AirPlay devices on the local network with their names, addresses, protocols, and pairing status.
Target a Device
Use -n <name> (device name), -s <ip> (address), or -i <id> (identifier) to target:
atvremote -n "Kitchen" <command>
atvremote -s 10.0.0.50 <command>
atvremote -i AA:BB:CC:DD:EE:FF <command>
Playback Control
atvremote -n "Kitchen" playing # Now playing info (title, artist, album, position, etc.)
atvremote -n "Kitchen" play # Resume playback
atvremote -n "Kitchen" pause # Pause playback (resumable with play)
atvremote -n "Kitchen" play_pause # Toggle play/pause
atvremote -n "Kitchen" stop # Stop playback (ends session, cannot resume)
atvremote -n "Kitchen" next # Next track
atvremote -n "Kitchen" previous # Previous track
atvremote -n "Kitchen" skip_forward # Skip forward (~10-30s, app-dependent)
atvremote -n "Kitchen" skip_backward # Skip backward (~10-30s, app-dependent)
atvremote -n "Kitchen" skip_forward=30 # Skip forward specific seconds
atvremote -n "Kitchen" set_position=120 # Seek to position (seconds)
atvremote -n "Kitchen" set_shuffle=Songs # Shuffle: Off, Songs, Albums
atvremote -n "Kitchen" set_repeat=All # Repeat: Off, Track, All
Volume
atvremote -n "Kitchen" volume # Get current volume (0-100)
atvremote -n "Kitchen" set_volume=50 # Set volume (0-100)
atvremote -n "Kitchen" volume_up # Step up (~2.5%)
atvremote -n "Kitchen" volume_down # Step down (~2.5%)
Streaming
atvremote -n "Kitchen" playing # Now playing info (title, artist, album, position, etc.)
atvremote -n "Kitchen" play # Resume playback
atvremote -n "Kitchen" pause # Pause playback (resumable with play)
atvremote -n "Kitchen" play_pause # Toggle play/pause
atvremote -n "Kitchen" stop # Stop playback (ends session, cannot resume)
atvremote -n "Kitchen" next # Next track
atvremote -n "Kitchen" previous # Previous track
atvremote -n "Kitchen" skip_forward # Skip forward (~10-30s, app-dependent)
atvremote -n "Kitchen" skip_backward # Skip backward (~10-30s, app-dependent)
atvremote -n "Kitchen" skip_forward=30 # Skip forward specific seconds
atvremote -n "Kitchen" set_position=120 # Seek to position (seconds)
atvremote -n "Kitchen" set_shuffle=Songs # Shuffle: Off, Songs, Albums
atvremote -n "Kitchen" set_repeat=All # Repeat: Off, Track, All
atvremote -n "Kitchen" volume # Get current volume (0-100)
atvremote -n "Kitchen" set_volume=50 # Set volume (0-100)
atvremote -n "Kitchen" volume_up # Step up (~2.5%)
atvremote -n "Kitchen" volume_down # Step down (~2.5%)
Streaming
Stream local files or URLs to a device:
atvremote -n "Kitchen" stream_file=/path/to/audio.mp3 # Local file
atvremote -n "Kitchen" play_url=http://example.com/stream.mp3 # Remote URL
Supports common audio formats (MP3, WAV, AAC, FLAC, etc.).
Power Management
atvremote -n "Apple TV" power_state # Check power state
atvremote -n "Apple TV" turn_on # Wake device
atvremote -n "Apple TV" turn_off # Sleep device
Navigation (Apple TV)
atvremote -n "Apple TV" up # D-pad up
atvremote -n "Apple TV" down # D-pad down
atvremote -n "Apple TV" left # D-pad left
atvremote -n "Apple TV" right # D-pad right
atvremote -n "Apple TV" select # Press select/enter
atvremote -n "Apple TV" menu # Back/menu button
atvremote -n "Apple TV" home # Home button
atvremote -n "Apple TV" home_hold # Long press home (app switcher)
atvremote -n "Apple TV" top_menu # Go to main menu
atvremote -n "Apple TV" control_center # Open control center
atvremote -n "Apple TV" guide # Show EPG/guide
atvremote -n "Apple TV" channel_up # Next channel
atvremote -n "Apple TV" channel_down # Previous channel
atvremote -n "Apple TV" screensaver # Activate screensaver
Keyboard Input (Apple TV)
atvremote -n "Apple TV" power_state # Check power state
atvremote -n "Apple TV" turn_on # Wake device
atvremote -n "Apple TV" turn_off # Sleep device
atvremote -n "Apple TV" up # D-pad up
atvremote -n "Apple TV" down # D-pad down
atvremote -n "Apple TV" left # D-pad left
atvremote -n "Apple TV" right # D-pad right
atvremote -n "Apple TV" select # Press select/enter
atvremote -n "Apple TV" menu # Back/menu button
atvremote -n "Apple TV" home # Home button
atvremote -n "Apple TV" home_hold # Long press home (app switcher)
atvremote -n "Apple TV" top_menu # Go to main menu
atvremote -n "Apple TV" control_center # Open control center
atvremote -n "Apple TV" guide # Show EPG/guide
atvremote -n "Apple TV" channel_up # Next channel
atvremote -n "Apple TV" channel_down # Previous channel
atvremote -n "Apple TV" screensaver # Activate screensaver
Keyboard Input (Apple TV)
When a text field is focused:
atvremote -n "Apple TV" text_get # Get current text
atvremote -n "Apple TV" text_set="search query" # Replace text
atvremote -n "Apple TV" text_append=" more" # Append text
atvremote -n "Apple TV" text_clear # Clear text
App Control (Apple TV)
atvremote -n "Apple TV" app_list # List installed apps
atvremote -n "Apple TV" launch_app=com.apple.TVMusic # Launch by bundle ID or URL
Output Devices (Multi-room)
atvremote -n "Apple TV" app_list # List installed apps
atvremote -n "Apple TV" launch_app=com.apple.TVMusic # Launch by bundle ID or URL
Manage connected audio outputs (e.g. grouping HomePods):
atvremote -n "Apple TV" output_devices # List current output device IDs
atvremote -n "Apple TV" add_output_devices=<device_id> # Add speaker to group
atvremote -n "Apple TV" remove_output_devices=<device_id> # Remove from group
atvremote -n "Apple TV" set_output_devices=<device_id> # Set specific output(s)
Push Updates (Live Monitoring)
Watch for real-time playback changes:
atvremote -n "Kitchen" push_updates # Prints updates as they occur (ENTER to stop)
Pairing
Some devices (especially Apple TV) require pairing before control:
atvremote -n "Living Room" pair # Pair (follow PIN prompt)
atvremote -n "Living Room" --protocol airplay pair # Pair specific protocol
atvremote wizard # Interactive guided setup
Credentials are stored automatically in ~/.pyatv.conf after pairing.
Device Info
atvremote -n "Kitchen" device_info # Model, OS version, MAC
atvremote -n "Kitchen" features # List all supported features
atvremote -n "Kitchen" app # Current app playing media
Tips
- Pause vs Stop: Use
pause/play to suspend and resume. stop ends the session entirely — playback must be restarted from the source (Siri, Home app, etc.)
- HomePods with "Pairing: NotNeeded" can be streamed to immediately
- Apple TVs typically require pairing first (all protocols the device supports)
- The
playing command shows media type, title, artist, position, shuffle/repeat state
- For stereo HomePod pairs, target either unit by name
- Use
--scan-hosts for faster targeting when you know the device IP
- Navigation and keyboard commands are primarily for Apple TV (not HomePod)
atvremote -n "Kitchen" device_info # Model, OS version, MAC
atvremote -n "Kitchen" features # List all supported features
atvremote -n "Kitchen" app # Current app playing media
- Pause vs Stop: Use
pause/playto suspend and resume.stopends the session entirely — playback must be restarted from the source (Siri, Home app, etc.) - HomePods with "Pairing: NotNeeded" can be streamed to immediately
- Apple TVs typically require pairing first (all protocols the device supports)
- The
playingcommand shows media type, title, artist, position, shuffle/repeat state - For stereo HomePod pairs, target either unit by name
- Use
--scan-hostsfor faster targeting when you know the device IP - Navigation and keyboard commands are primarily for Apple TV (not HomePod)
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。