commit a8d9f5e100c2bacc81c979bbe3b72792c3e3cab1 parent 90756934e6830237ddaf6332e95de6af88209d0c Author: Alex Balgavy <a.balgavy@gmail.com> Date: Mon, 2 Nov 2020 22:47:27 +0100 bcdl: script to download from BC as playlist Former-commit-id: c278638d4940f6f0c581e49d1fa077dd231a5b67 Diffstat:
A | scripts/bcdl | | | 17 | +++++++++++++++++ |
1 file changed, 17 insertions(+), 0 deletions(-)
diff --git a/scripts/bcdl b/scripts/bcdl @@ -0,0 +1,17 @@ +#!/bin/sh +DOWNLOAD_DIR="$HOME"/Downloads/songs/listen\ to +cd "$DOWNLOAD_DIR" || { printf "Couldn't cd into download directory %s\n" "$DOWNLOAD_DIR"; exit 1; } +command -v youtube-dlc 1>/dev/null 2>&1 || { printf "Youtube-dlc required.\n"; exit 1; } +[ $# -eq 1 ] || { printf "One argument required: album url\n"; exit 1; } + +url="$1" +name="${url##*/}" +artist="$(printf "%s" "$url" | sed 's|https*://||;s:\.bandcamp\.com.*::')" + +[ -d "$artist" ] || mkdir -p "$artist" +cd "$artist" || { printf "Couldn't cd into directory %s\n" "$(pwd)/$artist"; exit 1; } +[ -d "$name" ] || mkdir -p "$name" +cd "$name" || { printf "Couldn't cd into directory %s\n" "$(pwd)/$name"; exit 1; } +youtube-dlc -f mp3 -o "%(playlist_index)s %(title)s %(id)s.%(ext)s" "$url" +printf "#EXTM3U\n#PLAYLIST:%s\n#EXTART:%s\n" "$name" "$artist" > "$name".m3u +youtube-dlc -f mp3 --get-filename -o "%(playlist_index)s %(title)s %(id)s.%(ext)s" "$url" >> "$name".m3u