微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🎵

Linux 终端音乐控制中心

spotify-cli · vv1.0.0
入口已确认,内容待校验 文件树里有 SKILL.md,但正文还没采回,frontmatter 未核对。
专业技能 安全 A 级 作者 ShawnPana 公开目录收录
1.1k 下载 299 安装 4.3k 收藏 15.6k 浏览

简介

基于 Spotify Web API 的命令行音乐遥控器,让 Linux 及树莓派用户无需切换应用即可通过终端精准控制跨设备音乐播放。

原始描述

Control Spotify playback on any Linux device via command line, requiring Spotify Premium and an active Spotify session on another device.

通过你的 Agent 添加

安装目录:spotify-cli/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/spotify-cli/
Codex CLI~/.codex/skills/spotify-cli/
DeepSeek Harness~/.agents/skills/spotify-cli/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

中文使用说明 来自收录源

核心用法

Spotify CLI 是一个轻量级命令行工具,用于在 Raspberry Pi 或其他 Linux 系统上远程控制 Spotify 播放。它通过 Spotify Web API 与已登录的设备(手机、电脑或网页播放器)通信,实现搜索、播放、暂停、切歌等操作。

主要功能:

  • spotify search <query> — 搜索歌曲(显示前5个结果)
  • spotify play <song> — 搜索并播放指定歌曲
  • spotify pause/resume/next/prev — 播放控制
  • spotify status — 查看当前播放信息
  • spotify devices — 列出可用设备

认证流程: 首次使用需配置 Spotify Developer 应用的 Client ID/Secret,通过 OAuth 2.0 授权获取访问令牌。

显著优点

  1. 纯文档型 Skill:T-MD 分类,无实际可执行代码,风险可控
  2. 官方 API 支持:基于 Spotify 官方开发者接口,稳定性有保障
  3. 场景适配:专为无图形界面的 Linux 服务器/IoT 设备设计
  4. 搜索先行模式:内置最佳实践,避免误播放(先搜索确认再播放)

潜在缺点与局限性

  1. Premium 门槛:必须订阅 Spotify Premium 才能控制播放
  2. 依赖外部设备:音频不在本地播放,需另一台设备保持 Spotify 开启
  3. T3 来源风险:个人开发者维护,长期更新和维护不确定
  4. 配置复杂度:需手动创建开发者应用、配置 OAuth、处理回调
  5. 无实际代码:该 Skill 仅为 Markdown 文档,用户需自行安装 Python 脚本

适合人群

  • Raspberry Pi 或 Linux 服务器用户,希望通过命令行控制音乐
  • 已订阅 Spotify Premium 的技术爱好者
  • 需要为智能家居/自动化场景集成音乐控制的开发者
  • 熟悉 OAuth 流程、能自行排查配置问题的用户

常规风险

  1. 凭证安全:需妥善保管 Client ID/Secret,建议配置文件权限设为 600
  2. sudo 使用:安装说明建议使用 sudo 写入系统路径,可考虑 --user 或虚拟环境替代
  3. 令牌过期:OAuth 令牌可能过期,需定期重新授权
  4. 设备状态依赖:控制命令依赖 Spotify Connect 设备的在线状态

技能正文

Spotify CLI

A simple command-line interface for controlling Spotify playback from a Raspberry Pi (or any Linux system).

Requirements

  • Python 3
  • Spotify Premium account
  • spotipy Python library
  • Spotify app open on another device (phone, computer, or web player)

Installation

1. Install dependencies

pip3 install spotipy --break-system-packages

2. Create a Spotify Developer App

  1. Go to https://developer.spotify.com/dashboard
  2. Log in and click "Create App"
  3. Set Redirect URI to http://127.0.0.1:8888/callback
  4. Copy the Client ID and Client Secret

3. Create config file

mkdir -p ~/.config/spotify-cli
cat << EOF > ~/.config/spotify-cli/config
SPOTIPY_CLIENT_ID=your_client_id
SPOTIPY_CLIENT_SECRET=your_client_secret
SPOTIPY_REDIRECT_URI=http://127.0.0.1:8888/callback
EOF

The script automatically loads credentials from ~/.config/spotify-cli/config.

4. Install the script

sudo cp spotify /usr/local/bin/spotify
sudo chmod +x /usr/local/bin/spotify

5. Authenticate

Run any command (e.g., spotify status). On first run, you'll get a URL to open in your browser. After authorizing, copy the redirect URL (even if the page doesn't load) and paste it when prompted.

Commands

Command Description
spotify search <query> Search for songs (shows top 5 results)
spotify play <song> Search and play a song
spotify pause Pause playback
spotify resume Resume playback
spotify next Skip to next track
spotify prev Previous track
spotify status Show currently playing track
spotify devices List available Spotify devices

Examples

# Search for a song
spotify search "stairway to heaven"

# Play a song (tip: include artist for better results)
spotify play "stairway to heaven led zeppelin"

# Check what's playing
spotify status

# Control playback
spotify pause
spotify resume
spotify next

Best Practices (for AI agents)

When using this tool on behalf of a user:

  1. Always search first before playing. Use spotify search "query" to see results.
  2. Verify the match - confirm with the user that the search results match what they were looking for.
  3. Then play - once confirmed, use spotify play "exact song name artist" with the correct title/artist from the search results.

This avoids playing the wrong song due to Spotify's fuzzy search matching.

Example workflow:

# User asks: "play voice actor u projected 2"

# Step 1: Search first
spotify search "voice actor u projected 2"
# Results show: "U Projected 2 - Voice Actor, Yarrow.co"

# Step 2: Confirm with user that this is the right song

# Step 3: Play with exact match
spotify play "U Projected 2 Voice Actor"

Notes

  • This CLI controls playback on an existing Spotify session. You need Spotify open on another device (phone, computer, or https://open.spotify.com).
  • The CLI sends commands to that device - audio plays there, not on the Pi.
  • Requires Spotify Premium for playback control.

Troubleshooting

"No active device found"

Open Spotify on your phone/computer and play something, then try again.

"No devices found"

Make sure Spotify is open on at least one device and logged into the same account.

Auth token expired

Delete ~/.cache-* files and re-authenticate.

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

content-mediaproductivityautomationlinuxmusic

同类 Skill