spotify-claw: 完整的 Spotify 控制与音乐分析 - Openclaw Skills

作者:互联网

2026-03-30

AI教程

什么是 spotify-claw?

spotify-claw 为 AI 智能体管理 Spotify Premium 账户提供了一个全面的接口,涵盖从基础播放控制到深度听歌习惯分析的所有功能。通过利用 Openclaw Skills 框架,它允许开发者将音乐管理集成到自动化工作流中,利用智能发现逻辑和安全的 macOS Keychain 凭据管理,绕过标准 API 的限制。

该技能专为追求超越简单播放功能的进阶用户设计。它能够详细分析不同时段的热门曲目、艺人和流派画像。此外,它还拥有独特的发现引擎,通过关联艺人图谱遍历来绕过 Spotify API 最近的限制,从而发现新音乐。

下载入口:https://github.com/openclaw/skills/tree/main/skills/mixx85/spotify-claw

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install spotify-claw

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 spotify-claw。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

spotify-claw 应用场景

  • 根据工作专注度或时间段自动化音乐播放。
  • 生成关于音乐品味和流派画像的详细个人分析报告。
  • 通过爬取关联艺人网络构建自动发现播放列表。
  • 通过 CLI 命令管理 Spotify 媒体库,包括喜欢的歌曲和自定义播放列表。
  • 通过智能体驱动的命令在多个设备间同步播放。
spotify-claw 工作原理
  1. 智能体从 macOS Keychain 安全地获取 Spotify API 凭据以确保隐私。
  2. 使用 spotipy 库建立与 Spotify Web API 的连接。
  3. 用户发布自然语言指令,智能体将其转换为 Openclaw Skills 环境中特定的 Python CLI 调用。
  4. 该技能处理播放状态,如果 Spotify 桌面应用当前未运行,则会自动启动它。
  5. 发现等复杂任务通过遍历艺人关系来处理,以规避受限的推荐端点。

spotify-claw 配置指南

首先,安装所需的依赖项:

pip install spotipy

接下来,配置您的 Spotify 开发者凭据:

  1. 在 developer.spotify.com 创建一个应用,并将重定向 URI 设置为 http://127.0.0.1:8888/callback。
  2. 将您的凭据存储在 macOS Keychain 中,供 Openclaw Skills 使用:
security add-generic-password -a openclaw -s openclaw.spotify.client_id -w "CLIENT_ID"
security add-generic-password -a openclaw -s openclaw.spotify.client_secret -w "CLIENT_SECRET"
  1. 初始化首次身份验证会话:
python3 ~/.openclaw/scripts/spotify.py now

spotify-claw 数据架构与分类体系

数据类型 描述
凭据 存储在 macOS Keychain 的 openclaw 服务下。
令牌 由 spotipy 本地缓存以保持会话。
时间范围 分析支持短期(4周)、中期(6个月)和长期(全部)。
发现 对关联艺人使用基于图的方法(深度/跳数)。
name: spotify-claw
description: "Full Spotify Premium control + music analysis. Playback: play/pause/next/prev/volume/shuffle/queue. Analysis: top tracks, top artists, liked songs, genre profile, taste breakdown. Discovery: find similar artists & music without Recommendations API. Playlist builder: make-playlist, liked-by-artist, discover. Auto-launches Spotify if closed. Credentials via macOS Keychain. Triggers: play music, pause, next track, what's playing, top tracks, playlist, genres, similar music, open spotify."
homepage: https://github.com/mixx85/spotify-claw
metadata:
  {
    "openclaw":
      {
        "emoji": "??",
        "requires": { "bins": [] },
        "install":
          [
            {
              "id": "pip",
              "kind": "pip",
              "package": "spotipy",
              "label": "Install spotipy (pip)",
            },
          ],
      },
  }

spotify-claw

Full Spotify Premium control with music analysis and smart discovery.

ALWAYS run python3 ~/.openclaw/scripts/spotify.py [cmd] — never respond with text only.


Setup (first time)

  1. Create app at developer.spotify.com/dashboard — Add redirect URI: http://127.0.0.1:8888/callback

  2. Add to macOS Keychain:

security add-generic-password -a openclaw -s openclaw.spotify.client_id -w "CLIENT_ID"
security add-generic-password -a openclaw -s openclaw.spotify.client_secret -w "CLIENT_SECRET"
  1. First auth — run now, browser opens, log in once:
python3 ~/.openclaw/scripts/spotify.py now

Playback Commands

python3 ~/.openclaw/scripts/spotify.py play                          # resume
python3 ~/.openclaw/scripts/spotify.py play "track name"             # search & play
python3 ~/.openclaw/scripts/spotify.py play spotify:track:URI        # by URI
python3 ~/.openclaw/scripts/spotify.py play spotify:playlist:ID      # playlist
python3 ~/.openclaw/scripts/spotify.py pause
python3 ~/.openclaw/scripts/spotify.py next
python3 ~/.openclaw/scripts/spotify.py prev
python3 ~/.openclaw/scripts/spotify.py volume 70
python3 ~/.openclaw/scripts/spotify.py volume up
python3 ~/.openclaw/scripts/spotify.py volume down
python3 ~/.openclaw/scripts/spotify.py shuffle on
python3 ~/.openclaw/scripts/spotify.py shuffle off
python3 ~/.openclaw/scripts/spotify.py queue "track name"
python3 ~/.openclaw/scripts/spotify.py now
python3 ~/.openclaw/scripts/spotify.py devices

Auto-launch: If Spotify is closed, play opens the app automatically, waits for init, then plays.


Analysis Commands

python3 ~/.openclaw/scripts/spotify.py top-tracks [short|medium|long] [limit]
python3 ~/.openclaw/scripts/spotify.py top-artists [short|medium|long] [limit]
python3 ~/.openclaw/scripts/spotify.py recent [limit]
python3 ~/.openclaw/scripts/spotify.py liked [limit]
python3 ~/.openclaw/scripts/spotify.py liked-all
python3 ~/.openclaw/scripts/spotify.py liked-by-artist "Artist Name"
python3 ~/.openclaw/scripts/spotify.py genres [short|medium|long]
python3 ~/.openclaw/scripts/spotify.py playlists
python3 ~/.openclaw/scripts/spotify.py search "query" [track|artist|album] [limit]
python3 ~/.openclaw/scripts/spotify.py track-info URI

Periods: short = 4 weeks · medium = 6 months · long = all time


Discovery & Playlist Builder

# Find new music by genre profile
python3 ~/.openclaw/scripts/spotify.py discover

# Expand from specific artist (depth=hops, n=tracks per artist)
python3 ~/.openclaw/scripts/spotify.py discover "Portishead" 3 3

# Related artists
python3 ~/.openclaw/scripts/spotify.py related-artists "The Cure" 10

# Top tracks of any artist
python3 ~/.openclaw/scripts/spotify.py artist-top-tracks "Massive Attack" 5

# Create playlist from top tracks (one command: creates + fills)
python3 ~/.openclaw/scripts/spotify.py make-playlist "Top March 2026" short 20

# Manage playlists
python3 ~/.openclaw/scripts/spotify.py create-playlist "My Playlist" "Description"
python3 ~/.openclaw/scripts/spotify.py add-to-playlist PLAYLIST_ID URI1 URI2

Note: Spotify's recommendations and audio_features APIs are blocked for new developer apps (return 403/404). This skill uses related_artists + artist_top_tracks for discovery instead.


Agent Tips

  • Use playlists to list user's playlists with IDs before playing one
  • Use now to confirm what's playing after a play command
  • Use liked-by-artist to find tracks for a themed playlist
  • Chain: related-artistsartist-top-tracksadd-to-playlist for smart playlist building
  • genres long gives the most accurate taste profile