Created
December 9, 2017 05:16
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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