Skip to content

Instantly share code, notes, and snippets.

@drench
Last active April 12, 2026 20:44
Show Gist options
  • Select an option

  • Save drench/1ee94c38021a77f48c08f791a18b8b25 to your computer and use it in GitHub Desktop.

Select an option

Save drench/1ee94c38021a77f48c08f791a18b8b25 to your computer and use it in GitHub Desktop.
CLI for bandcamp
#!/bin/sh
# bcamp: a CLI for bandcamp
#
# Examples:
#
# bcamp album json https://pedalrecords.bandcamp.com/album/will-2024-remastered
# bcamp fan json drench
CACHEDIR=~/.cache/bc-info
test -d "$CACHEDIR" || mkdir -p "$CACHEDIR"
bc_html() {
url=$1
fn=$CACHEDIR/$(jq -rn --arg url "$url" '$url | @uri')
if [ ! -r "$fn" ]; then
curl "$url" > "$fn"
fi
cat "$fn"
}
bc_album_json() {
pup 'script[type=application/ld+json] text{}' | jq .
}
bc_fan_json() {
pup --plain '#pagedata attr{data-blob}' | jq .
}
case "$1" in
album)
case "$2" in
date)
bc_html "$3" | bc_album_json | jq -r '.datePublished | strptime("%d %b %Y %H:%M:%S %Z") | strftime("%Y-%m-%d")'
;;
json)
bc_html "$3" | bc_album_json
;;
*)
echo TK
;;
esac
;;
fan)
case "$2" in
json)
bc_html "https://bandcamp.com/$3" | bc_fan_json
;;
*)
echo TK
;;
esac
;;
*)
echo USAGE GOES HERE
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment