Skip to content

Instantly share code, notes, and snippets.

@overthink
Created December 9, 2017 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save overthink/db2e6f760f9b97af39eb641caec39369 to your computer and use it in GitHub Desktop.
Save overthink/db2e6f760f9b97af39eb641caec39369 to your computer and use it in GitHub Desktop.
Get artist, track name, url from last.fm loved tracks for a user.
#!/bin/bash
set -euo pipefail
API_KEY=$(cat ~/.lastfm_api_key)
LASTFM_USER="overthink"
LIMIT=1000
getpage() {
local page="${1?need page number to fetch}"
curl -s "http://ws.audioscrobbler.com/2.0/?method=user.getlovedtracks&user=$LASTFM_USER&api_key=$API_KEY&format=json&limit=$LIMIT&page=$page" \
| jq -r '.lovedtracks.track[] | [.artist.name, .name, .url] | @tsv'
}
getpage 1
getpage 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment