Skip to content

Instantly share code, notes, and snippets.

@cab404
Last active January 2, 2018 16:26
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 cab404/c47f43e7debe4b52502c to your computer and use it in GitHub Desktop.
Save cab404/c47f43e7debe4b52502c to your computer and use it in GitHub Desktop.
bandcamp album download script
#!/bin/bash
# Made by cab404
# Licenced under GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html)
# Musicians need food too, please pay for everything you download. Or at least something.
echo 'loading info'
wget $1 -qO- | grep 'trackinfo' > data.txt
OUTDIR=$(echo $1 | sed 's/\//\n/g' | sed '/^$/d' | tail -n 1)
mkdir $OUTDIR
TMP=/tmp/.bcdlxargp
URLS=$(cat data.txt | grep -Po '(mp3-128":".*})' | sed 's/"/\n/g' | grep 'popplers')
cat data.txt | sed 's/},/\n/g;s/,"/\n/g' | grep -Po '(?<=title":").*(?=")' > tracklist.txt
rm data.txt
echo "downloading to "$OUTDIR
echo "==== track list ===="
cat tracklist.txt
echo "====-==-====-==-===="
N=0
for URL in $URLS; do
N=$(dc -e "$N 1 + p")
MP3NUM=$N
MP3NAME=$(head tracklist.txt -n $N | tail -n 1)
FILENAME="$OUTDIR/${MP3NUM}. ${MP3NAME}.mp3"
echo "wget -qc --show-progress --output-document=\"$FILENAME\" \"http:$URL\" |" >> $TMP
done
echo "echo downloading now" >> $TMP
bash $TMP
echo "complete"
rm $TMP
@cab404
Copy link
Author

cab404 commented Oct 21, 2015

This thing downloads album by it's url.
'mediainfo' package should be installed.

@cab404
Copy link
Author

cab404 commented Oct 21, 2015

Now it doesn't need 'mediainfo'.

@cab404
Copy link
Author

cab404 commented Oct 21, 2015

Now it makes directory for album

@cab404
Copy link
Author

cab404 commented Nov 14, 2015

Now it works for singles

@cab404
Copy link
Author

cab404 commented Nov 14, 2015

~like me

@r0om3
Copy link

r0om3 commented Jan 2, 2018

Hi, I'm new to Linux and I'd like to know how to use the script

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