SuperAPI AI 工具集

spotify

通用与其它

查看项目

更新于 10-16 07:26

技能介绍

用途:在 macOS 上通过 AppleScript 控制 Spotify 桌面应用,实现播放、暂停、切歌、音量与进度调节、随机/循环模式切换,以及获取当前曲目和播放器状态。

主要能力:脚本位于 ./scripts/ 目录,从插件根目录用 bash 执行。播放控制包括 play.sh、pause.sh、toggle-playback.sh、next-track.sh、previous-track.sh、play-uri.sh(参数 <spotify_uri> [context_uri])。搜索方面 search.sh <query> 会在 Spotify 中打开搜索界面;推荐做法是用网络搜索 site:open.spotify.com [query] 找到 URL 后交给 play-uri.sh 播放,支持曲目、专辑、歌单和艺人。信息类脚本有 get-current-track.sh、get-player-state.sh。音量控制有 get-volume.sh、set-volume.sh <0-100>、volume-up.sh、volume-down.sh。进度控制有 get-position.sh、set-position.sh <seconds>、fast-forward.sh、rewind.sh。模式控制有 toggle-shuffle.sh、toggle-repeat.sh、get-modes.sh。工具类有 is-running.sh、launch.sh、quit.sh。

输出格式:字段以 <<>> 分隔,错误以 ERROR: 前缀标识。曲目记录字段依次为 name、artist、album、albumArtist、duration、position、trackNumber、discNumber、id、spotifyUrl、artworkUrl、popularity;播放器状态为 state、position、volume、shuffling、repeating;模式为 shuffling、repeating。时长与位置单位为秒。

使用方式:需 macOS 且安装 Spotify 桌面应用,免费或 Premium 账户均可,无需认证或 API 密钥;首次运行可能触发 macOS 自动化权限提示。Spotify URI 格式为 spotify:track:<id>、spotify:album:<id>、spotify:playlist:<id>、spotify:artist:<id>,可从桌面端右键分享或网页 URL 转换获得。

限制:AppleScript API 不支持添加到歌单、查看或管理播放队列、喜欢/保存曲目、浏览音乐库,也无法搜索私有/个人歌单(可改用 play-uri.sh 传入歌单 URI)。这些功能需使用 Spotify Web API(要求 Premium 与 OAuth)。