OA0 = Omni AI 0
OA0 是一个探索 AI 的论坛
现在注册
已注册用户请  登录
OA0  ›  技能包  ›  lastfm:访问 Last.fm 听歌历史数据与音乐偏好统计偏好统计

lastfm:访问 Last.fm 听歌历史数据与音乐偏好统计偏好统计

 
  authorization ·  2026-02-25 15:29:01 · 2 次点击  · 0 条评论  

名称: lastfm
描述: 访问 Last.fm 的收听历史、音乐统计数据及发现功能。可查询最近播放的曲目、热门艺人/专辑/曲目、收藏曲目、相似艺人及全球榜单。


Last.fm API 技能

访问 Last.fm 的收听历史、音乐统计数据及发现功能。

配置

必需的环境变量(请添加到你的 shell 配置文件或可选的 ~/.clawdbot/.env 文件中):
- LASTFM_API_KEY — 你的 Last.fm API 密钥(在此获取
- LASTFM_USER — 你的 Last.fm 用户名

基础 URLhttp://ws.audioscrobbler.com/2.0/
官方文档:https://lastfm-docs.github.io/api-docs/

示例输出

以下是 17 年以上收听记录的示例:

总播放记录数:519,778
独立艺人数量:13,763
独立曲目数量:68,435
独立专辑数量:33,637

历史热门艺人:
• System of a Down (播放 52,775 次)
• Eminem (播放 15,400 次)
• Dashboard Confessional (播放 10,166 次)
• Edguy (播放 10,161 次)
• Metallica (播放 9,927 次)

历史热门曲目:
• System of a Down - Aerials (播放 1,405 次)
• System of a Down - Toxicity (播放 1,215 次)
• System of a Down - Sugar (播放 1,149 次)
• System of a Down - Chop Suey (播放 1,116 次)
• System of a Down - Prison Song (播放 1,102 次)

快速参考

所有请求均使用 GET 方法,并包含以下基础参数:

?api_key=$LASTFM_API_KEY&format=json&user=$LASTFM_USER

用户相关端点

最近播放曲目(正在播放 / 最近播放)

curl -s "http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=$LASTFM_USER&api_key=$LASTFM_API_KEY&format=json&limit=10"
  • 首条 @attr.nowplaying=true 的曲目为当前正在播放
  • 返回:艺人、曲目名称、专辑、时间戳、图片

用户信息(个人资料统计)

curl -s "http://ws.audioscrobbler.com/2.0/?method=user.getinfo&user=$LASTFM_USER&api_key=$LASTFM_API_KEY&format=json"
  • 返回:播放次数、艺人数量、曲目数量、专辑数量、注册日期

热门艺人

curl -s "http://ws.audioscrobbler.com/2.0/?method=user.gettopartists&user=$LASTFM_USER&api_key=$LASTFM_API_KEY&format=json&period=7day&limit=10"
  • period 可选:overall | 7day | 1month | 3month | 6month | 12month

热门专辑

curl -s "http://ws.audioscrobbler.com/2.0/?method=user.gettopalbums&user=$LASTFM_USER&api_key=$LASTFM_API_KEY&format=json&period=7day&limit=10"

热门曲目

curl -s "http://ws.audioscrobbler.com/2.0/?method=user.gettoptracks&user=$LASTFM_USER&api_key=$LASTFM_API_KEY&format=json&period=7day&limit=10"

收藏曲目

curl -s "http://ws.audioscrobbler.com/2.0/?method=user.getlovedtracks&user=$LASTFM_USER&api_key=$LASTFM_API_KEY&format=json&limit=10"

每周榜单

# 每周艺人榜单
curl -s "http://ws.audioscrobbler.com/2.0/?method=user.getweeklyartistchart&user=$LASTFM_USER&api_key=$LASTFM_API_KEY&format=json"

# 每周曲目榜单
curl -s "http://ws.audioscrobbler.com/2.0/?method=user.getweeklytrackchart&user=$LASTFM_USER&api_key=$LASTFM_API_KEY&format=json"

# 每周专辑榜单
curl -s "http://ws.audioscrobbler.com/2.0/?method=user.getweeklyalbumchart&user=$LASTFM_USER&api_key=$LASTFM_API_KEY&format=json"

艺人/曲目/专辑信息

艺人信息

curl -s "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=Tame+Impala&api_key=$LASTFM_API_KEY&format=json&username=$LASTFM_USER"
  • 添加 username 参数可包含该用户对该艺人的播放次数

相似艺人

curl -s "http://ws.audioscrobbler.com/2.0/?method=artist.getsimilar&artist=Tame+Impala&api_key=$LASTFM_API_KEY&format=json&limit=10"

艺人热门曲目

curl -s "http://ws.audioscrobbler.com/2.0/?method=artist.gettoptracks&artist=Tame+Impala&api_key=$LASTFM_API_KEY&format=json&limit=10"

曲目信息

curl -s "http://ws.audioscrobbler.com/2.0/?method=track.getinfo&artist=Tame+Impala&track=The+Less+I+Know+The+Better&api_key=$LASTFM_API_KEY&format=json&username=$LASTFM_USER"

相似曲目

curl -s "http://ws.audioscrobbler.com/2.0/?method=track.getsimilar&artist=Tame+Impala&track=Elephant&api_key=$LASTFM_API_KEY&format=json&limit=10"

专辑信息

curl -s "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&artist=Tame+Impala&album=Currents&api_key=$LASTFM_API_KEY&format=json&username=$LASTFM_USER"

搜索

搜索艺人

curl -s "http://ws.audioscrobbler.com/2.0/?method=artist.search&artist=tame&api_key=$LASTFM_API_KEY&format=json&limit=5"

搜索曲目

curl -s "http://ws.audioscrobbler.com/2.0/?method=track.search&track=elephant&api_key=$LASTFM_API_KEY&format=json&limit=5"

搜索专辑

curl -s "http://ws.audioscrobbler.com/2.0/?method=album.search&album=currents&api_key=$LASTFM_API_KEY&format=json&limit=5"

全球榜单

# 全球热门艺人
curl -s "http://ws.audioscrobbler.com/2.0/?method=chart.gettopartists&api_key=$LASTFM_API_KEY&format=json&limit=10"

# 全球热门曲目
curl -s "http://ws.audioscrobbler.com/2.0/?method=chart.gettoptracks&api_key=$LASTFM_API_KEY&format=json&limit=10"

标签

# 特定标签/流派的热门专辑
curl -s "http://ws.audioscrobbler.com/2.0/?method=tag.gettopalbums&tag=psychedelic&api_key=$LASTFM_API_KEY&format=json&limit=10"

# 特定标签的热门艺人
curl -s "http://ws.audioscrobbler.com/2.0/?method=tag.gettopartists&tag=brazilian&api_key=$LASTFM_API_KEY&format=json&limit=10"

实用的 jq 过滤器

如需处理 JSON 数据,请参考 ClawdHub 上的 jq 技能

# 最近播放曲目:艺人 - 曲目
jq '.recenttracks.track[] | "\(.artist["#text"]) - \(.name)"'

# 热门艺人:名称 (播放次数)
jq '.topartists.artist[] | "\(.name) (\(.playcount))"'

# 检查当前是否正在播放
jq '.recenttracks.track[0] | if .["@attr"].nowplaying == "true" then "正在播放: \(.artist["#text"]) - \(.name)" else "最近播放: \(.artist["#text"]) - \(.name)" end'

注意事项

  • 只读端点无需认证(仅需 API 密钥)
  • 频率限制:请合理使用,官方未明确说明硬性限制
  • 对艺人/曲目/专辑名称进行 URL 编码(空格替换为 +%20
  • 图片提供多种尺寸:small, medium, large, extralarge
2 次点击  ∙  0 人收藏  
登录后收藏  
目前尚无回复
0 条回复
About   ·   Help   ·    
OA0 - Omni AI 0 一个探索 AI 的社区
沪ICP备2024103595号-2
Developed with Cursor