bcdl (1050B)
1 #!/bin/sh 2 # Wrapper for youtube-dl, configured specifically for Bandcamp 3 # $1 is the URL 4 5 DOWNLOAD_DIR="$HOME"/Downloads/songs/listen\ to 6 cd "$DOWNLOAD_DIR" || { printf "Couldn't cd into download directory %s\n" "$DOWNLOAD_DIR"; exit 1; } 7 command -v youtube-dl 1>/dev/null 2>&1 || { printf "Youtube-dl required.\n"; exit 1; } 8 [ $# -eq 1 ] || { printf "One argument required: album url\n"; exit 1; } 9 10 url="$1" 11 name="${url##*/}" 12 artist="$(printf "%s" "$url" | sed 's|https*://||;s:\.bandcamp\.com.*::')" 13 14 [ -d "$artist" ] || mkdir -p "$artist" 15 cd "$artist" || { printf "Couldn't cd into directory %s\n" "$(pwd)/$artist"; exit 1; } 16 [ -d "$name" ] || mkdir -p "$name" 17 cd "$name" || { printf "Couldn't cd into directory %s\n" "$(pwd)/$name"; exit 1; } 18 youtube-dl -f mp3 -o "%(playlist_index)s %(title)s %(id)s.%(ext)s" "$url" 19 printf "#EXTM3U\n#PLAYLIST:%s\n#EXTART:%s\n" "$name" "$artist" > "$name".m3u 20 youtube-dl -f mp3 --get-filename -o "%(playlist_index)s %(title)s %(id)s.%(ext)s" "$url" >> "$name".m3u 21 notify "Downloaded $artist - $name" "$url" bcdl