Skip to content

Instantly share code, notes, and snippets.

@alejandroandreu
Created September 4, 2017 10:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alejandroandreu/a488b8d99ea63904b6bdb784dd52055a to your computer and use it in GitHub Desktop.
Save alejandroandreu/a488b8d99ea63904b6bdb784dd52055a to your computer and use it in GitHub Desktop.
Download any user's Bandcamp wishlist via youtube-dl
#!/bin/bash
# Don't do anything if youtube-dl is not installed
which youtube-dl >/dev/null || ( echo "Aborting, youtube-dl is not installed!" >&1 && exit 1; )
# Main vars
user="alejandroandreu"
baseurl="https://bandcamp.com/${user}/wishlist"
targetdir="~/Music/Wishlist"
# Each item in wishlist is represented in the HTML like:
# <a class="fav-track-link" href="https://dodjoma.bandcamp.com/album/syntropia-ep" target="_blank">Là</a>
htmlclass="fav-track-link"
# Download each album
albums=$(curl -s $baseurl | grep $htmlclass | cut -d "=" -f 3 | cut -d " " -f 1 | tr -d '"')
for album in $albums; do
artist=$(echo $album | cut -d "/" -f 3 | cut -d "." -f 1) # Artist can't be retrieved reliably by youtube-dl
echo "[+] Downloading ${album}..."
youtube-dl -w -o "${targetdir}/${artist^}"' - %(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' $album
done
exit 0
@n355
Copy link

n355 commented Apr 4, 2020

Hi, thank you for this.
I've set htmlclass variable to 'item-link' to match the current version of the html but it only loads elements before the 'view all items' button. Is it possible to modify the script to work with the actual version of bandcamp?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment