name: now-playing description: "记录当前 Apple Music 正在播放的歌曲到 journal。当用户提到 now playing、在听什么、记录音乐、/now-playing 时触发。" user_invocable: true
Now Playing
抓取 Apple Music 当前播放的歌曲,记录到 journal Notes。
执行流程
- 通过 AppleScript 获取 Apple Music 当前播放信息
- 写入当天 journal 的 Notes 区块
AppleScript
osascript -e '
tell application "Music"
if player state is playing then
set trackName to name of current track
set trackArtist to artist of current track
set trackAlbum to album of current track
set trackDuration to duration of current track
return trackName & " | " & trackArtist & " | " & trackAlbum
else
return "NOT_PLAYING"
end if
end tell'
写入格式
在 journal Notes 区块追加:
- 🎵 **Now Playing**:{trackName} — {trackArtist} ({trackAlbum})
对话展示
🎵 Now Playing: {trackName} — {trackArtist}
已记录到今天的 journal。
注意事项
- Apple Music 必须正在播放才能获取信息
- 如果 Music app 没有运行或没在播放,提示用户
- 不要自动启动 Music app
- 多次调用会追加多条记录(不去重,因为可能听了不同的歌)