技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
lastfm【数据与研究】Interact with the Last.fm music data API: lookup user listening history, get artist/album/track metadata, discover similar music via collaborative filtering, explore global and per-country charts, search by artist/album/track, manage tags, and scrobble listening events. Use when the user asks about music data, listening statistics, music recommendati…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
lastfm-cli CLI tool must be on PATH.
metadata:
tags: music, lastfm, scrobbling, api-client, music-discovery
source: https://www.last.fm/apiexport LASTFM_API_KEY="your_api_key_here"
# For write operations only:
export LASTFM_API_SECRET="your_api_secret"
export LASTFM_SESSION_KEY="your_session_key"
Get an API key at https://www.last.fm/api/account/create (free, requires a Last.fm account).
Configurable via LASTFM_USERNAME env var. Defaults to <username> if unset.
lastfm-cli user info <username> # Profile + stats
lastfm-cli user recent-tracks <username> --limit 10 # Recent listening
lastfm-cli user top-artists <username> --period 7day # Weekly top artists
lastfm-cli user top-tracks <username> --period overall # All-time faves
lastfm-cli user loved-tracks <username> # Loved tracks
lastfm-cli user friends <username> # Social graph
lastfm-cli user weekly-charts <username> # Available chart periods
lastfm-cli artist similar <artist> --limit 10 # Taste graph neighbors
lastfm-cli artist info <artist> # Bio, stats, tags
lastfm-cli artist top-tracks <artist> # Their most popular
lastfm-cli track similar <artist> "<track>" # Track-level similarity
lastfm-cli album info <artist> "<album>" # Tracklist, metadata
lastfm-cli tag top-artists <tag> # Genre browsing
lastfm-cli chart top-artists --limit 20 # Global
lastfm-cli geo top-artists "Japan" --limit 20 # Per-country
lastfm-cli geo top-tracks "Germany" --limit 20
lastfm-cli tag top-tracks "electronic" --limit 15 # By genre tag
lastfm-cli artist search "Radiohead" # Find by name
lastfm-cli album search "OK Computer" # Find albums
lastfm-cli track search "Karma Police" # Find tracks
lastfm-cli track scrobble "Artist" "Song" --album "Album"
lastfm-cli track now-playing "Artist" "Song"
lastfm-cli track love "Artist" "Song"
# 1. Get a token
lastfm-cli auth get-token
# 2. User visits: https://www.last.fm/api/auth/?api_key=KEY&token=TOKEN
# 3. Exchange for session key
lastfm-cli auth get-session <token>
# → Set export LASTFM_SESSION_KEY=<key>
references/auth-flow.md — Full walkthrough for setting up write operation auth (scrobble, love, now-playing). Read this before attempting write operations.The core flow for turning liked tracks into recommendations:
Get user's top artists/tracks from Last.fm:
lastfm-cli user top-artists <username> --period 1month --limit 5 --json
lastfm-cli user top-tracks <username> --period 1month --limit 10 --json
lastfm-cli user loved-tracks <username> --json
For each artist, find similar artists via Last.fm's collaborative filtering:
lastfm-cli artist similar "<artist>" --limit 5 --json
For each track, find similar tracks for more granular recommendations:
lastfm-cli track similar "<artist>" "<track>" --limit 5 --json
Cross-reference against what they've already scrobbled (recent-tracks) to filter out already-heard material.
Check against the user's own collection (via Radarr/Sonarr/jellyfin or Spotify library) to see what's already in the library vs genuinely new discovery.
# Pipe to jq for structured queries
lastfm-cli artist similar "Radiohead" --limit 5 --json | jq '.similarartists.artist[] | {name, match}'
# Get a user's all-time top artists with playcounts
lastfm-cli user top-artists <username> --period overall --limit 3 --json | jq '.topartists.artist[] | {name, playcount}'
# Find most popular tracks by a genre
lastfm-cli tag top-tracks "electronic" --limit 10 --json | jq '.tracks.track[] | {name, artist: .artist.name, listeners}'
lastfm-cli/1.0 (hermes-agent). Last.fm's docs explicitly ask for an identifiable User-Agent.format=json. Without it, responses come back as XML.--autocorrect flag on artist commands to let Last.fm correct misspellings.artist.getSimilar returns algorithmic similarity based on aggregate listening patterns, not human-curated recommendations.--from and --to on recent-tracks accept ISO 8601 date strings (e.g., 2026-05-27).overall, 7day, 1month, 3month, 6month, 12month.| Script | Purpose | Invocation |
|---|---|---|
scripts/lastfm-cli | The CLI tool this skill drives: read-only queries (user info/recent-tracks/top-artists/top-tracks/loved-tracks/friends/weekly-charts), discovery (artist similar, track similar), charts and geo charts, search, tags, and — with session auth — scrobble, now-playing, and love. Run it for every Last.fm data question above; see Essential Commands for the full command surface. | scripts/lastfm-cli user top-artists <username> --period 7day --limit 10 |
scripts/test-lastfm.sh | Shell test suite covering the CLI's argument handling and output formatting without network calls. Run it after modifying scripts/lastfm-cli or when auditing a change to its behavior; CI runs it via scripts/check-skill-tests.py. | bash scripts/test-lastfm.sh |
LASTFM_API_KEY (create one at https://www.last.fm/api/account/create); every request fails without it.LASTFM_API_SECRET plus a session key from the one-time auth flow in references/auth-flow.md, exported as LASTFM_SESSION_KEY.python3 scripts/lastfm-cli ... if it is not executable directly; the SKILL.md examples assume lastfm-cli resolves on PATH.LASTFM_USERNAME to set the default user for user queries; jq when piping --json output for structured processing.overall, 7day, 1month, 3month, 6month, and 12month; arbitrary date ranges are only available via --from/--to on recent-tracks.--autocorrect is used.Do not use this skill for music playback control (local players, streaming queues), for non-Last.fm catalog data (MusicBrainz, Spotify metadata), or as a lyrics source — the API covers listening history, metadata, charts, tags, similarity, and scrobbling only.